LayoutTests/fast/files/create-blob-url-crash-expected.txt

11Test that createObjectURL with no argument should throw an exception.
2 PASS: Not enough arguments
 2PASS: Type error
33DONE
44

Source/WebCore/CMakeLists.txt

@@IF (ENABLE_MEDIA_STREAM)
20202020 p2p/PeerConnection.cpp
20212021 page/MediaStreamController.cpp
20222022 page/MediaStreamFrameController.cpp
 2023 platform/MediaStreamRegistry.cpp
20232024 )
20242025
20252026 LIST(APPEND WebCore_IDL_FILES

Source/WebCore/ChangeLog

 12011-08-09 Tommy Widenflycht <tommyw@google.com>
 2
 3 MediaStream API: add createObjectURL functionality
 4 https://bugs.webkit.org/show_bug.cgi?id=65925
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * CMakeLists.txt:
 9 * GNUmakefile.list.am:
 10 * WebCore.gypi:
 11 * WebCore.pro:
 12 * WebCore.vcproj/WebCore.vcproj:
 13 * WebCore.xcodeproj/project.pbxproj:
 14 * dom/ScriptExecutionContext.cpp:
 15 (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
 16 (WebCore::ScriptExecutionContext::createPublicBlobURL):
 17 (WebCore::ScriptExecutionContext::revokePublicBlobURL):
 18 * dom/ScriptExecutionContext.h:
 19 * html/DOMURL.cpp:
 20 (WebCore::DOMURL::createObjectURL):
 21 * html/DOMURL.h:
 22 * html/DOMURL.idl:
 23 * platform/MediaStreamRegistry.cpp: Added.
 24 (WebCore::mediaStreamRegistry):
 25 (WebCore::MediaStreamRegistry::registerStreamURL):
 26 (WebCore::MediaStreamRegistry::unregisterStreamURL):
 27 (WebCore::MediaStreamRegistry::getStream):
 28 * platform/MediaStreamRegistry.h: Added.
 29
1302011-08-10 Yuta Kitamura <yutak@chromium.org>
231
332 WebSocket: Add binaryType attribute

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
26382638 Source/WebCore/platform/Logging.h \
26392639 Source/WebCore/platform/MIMETypeRegistry.cpp \
26402640 Source/WebCore/platform/MIMETypeRegistry.h \
 2641 Source/WebCore/platform/MediaStreamRegistry.cpp \
 2642 Source/WebCore/platform/MediaStreamRegistry.h \
26412643 Source/WebCore/platform/MemoryPressureHandler.cpp \
26422644 Source/WebCore/platform/MemoryPressureHandler.h \
26432645 Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp \

Source/WebCore/WebCore.gypi

30243024 'platform/LinkHash.cpp',
30253025 'platform/LocalizedStrings.cpp',
30263026 'platform/Logging.cpp',
 3027 'platform/MediaStreamRegistry.cpp',
 3028 'platform/MediaStreamRegistry.h',
30273029 'platform/MemoryPressureHandler.cpp',
30283030 'platform/MIMETypeRegistry.cpp',
30293031 'platform/Pasteboard.h',

Source/WebCore/WebCore.pro

@@contains(DEFINES, ENABLE_MEDIA_STREAM=1) {
32603260 page/MediaStreamFrameController.h \
32613261 page/NavigatorUserMediaError.h \
32623262 page/NavigatorUserMediaErrorCallback.h \
3263  page/NavigatorUserMediaSuccessCallback.h
 3263 page/NavigatorUserMediaSuccessCallback.h \
 3264 platform/MediaStreamRegistry.h
32643265
32653266 SOURCES += \
32663267 dom/LocalMediaStream.cpp \

@@contains(DEFINES, ENABLE_MEDIA_STREAM=1) {
32713272 p2p/MediaStreamEvent.cpp \
32723273 p2p/PeerConnection.cpp \
32733274 page/MediaStreamController.cpp \
3274  page/MediaStreamFrameController.cpp
 3275 page/MediaStreamFrameController.cpp \
 3276 platform/MediaStreamRegistry.cpp
32753277
32763278 v8 {
32773279 SOURCES += \

Source/WebCore/WebCore.vcproj/WebCore.vcproj

2679426794 >
2679526795 </File>
2679626796 <File
 26797 RelativePath="..\platform\MediaStreamRegistry.cpp"
 26798 >
 26799 </File>
 26800 <File
 26801 RelativePath="..\platform\MediaStreamRegistry.h"
 26802 >
 26803 </File>
 26804 <File
2679726805 RelativePath="..\platform\MemoryPressureHandler.cpp"
2679826806 >
2679926807 </File>

Source/WebCore/WebCore.xcodeproj/project.pbxproj

11251125 4958782212A57DDF007238AC /* PlatformCALayerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4958782012A57DDF007238AC /* PlatformCALayerMac.mm */; };
11261126 4969B0F213D0B33F00DF3521 /* HitTestingTransformState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4969B0F013D0B33F00DF3521 /* HitTestingTransformState.cpp */; };
11271127 4969B0F313D0B33F00DF3521 /* HitTestingTransformState.h in Headers */ = {isa = PBXBuildFile; fileRef = 4969B0F113D0B33F00DF3521 /* HitTestingTransformState.h */; };
 1128 49785EE013F192F000A795AD /* MediaStreamRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49785EDE13F192F000A795AD /* MediaStreamRegistry.cpp */; };
 1129 49785EE113F192F000A795AD /* MediaStreamRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 49785EDF13F192F000A795AD /* MediaStreamRegistry.h */; };
11281130 4983913F0F1E767500C23782 /* JSWebKitCSSMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4983913D0F1E767500C23782 /* JSWebKitCSSMatrix.cpp */; };
11291131 498391400F1E767500C23782 /* JSWebKitCSSMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 4983913E0F1E767500C23782 /* JSWebKitCSSMatrix.h */; };
11301132 498391500F1E76B400C23782 /* DOMWebKitCSSMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 4983914D0F1E76B400C23782 /* DOMWebKitCSSMatrix.h */; };

77047706 4958782012A57DDF007238AC /* PlatformCALayerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PlatformCALayerMac.mm; path = ca/mac/PlatformCALayerMac.mm; sourceTree = "<group>"; };
77057707 4969B0F013D0B33F00DF3521 /* HitTestingTransformState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestingTransformState.cpp; sourceTree = "<group>"; };
77067708 4969B0F113D0B33F00DF3521 /* HitTestingTransformState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HitTestingTransformState.h; sourceTree = "<group>"; };
 7709 49785EDE13F192F000A795AD /* MediaStreamRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamRegistry.cpp; sourceTree = "<group>"; };
 7710 49785EDF13F192F000A795AD /* MediaStreamRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamRegistry.h; sourceTree = "<group>"; };
77077711 4983913D0F1E767500C23782 /* JSWebKitCSSMatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitCSSMatrix.cpp; sourceTree = "<group>"; };
77087712 4983913E0F1E767500C23782 /* JSWebKitCSSMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitCSSMatrix.h; sourceTree = "<group>"; };
77097713 4983914D0F1E76B400C23782 /* DOMWebKitCSSMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitCSSMatrix.h; sourceTree = "<group>"; };

1909219096 935207BD09BD410A00F2038D /* LocalizedStrings.h */,
1909319097 A8239DFE09B3CF8A00B60641 /* Logging.cpp */,
1909419098 A8239DFF09B3CF8A00B60641 /* Logging.h */,
 19099 49785EDE13F192F000A795AD /* MediaStreamRegistry.cpp */,
 19100 49785EDF13F192F000A795AD /* MediaStreamRegistry.h */,
1909519101 657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */,
1909619102 657EDA071385CB97004E0645 /* MemoryPressureHandler.h */,
1909719103 BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */,

2237922385 49A2CFDA13E9787E00579F13 /* MediaStreamEvent.h in Headers */,
2238022386 B1E54596134629C10092A545 /* MediaStreamFrameController.h in Headers */,
2238122387 B14353D6138EA8ED00D53276 /* MediaStreamList.h in Headers */,
 22388 49785EE113F192F000A795AD /* MediaStreamRegistry.h in Headers */,
2238222389 49C9F32613D574F90052600A /* MediaStreamTrack.h in Headers */,
2238322390 49C9F32313D574F90052600A /* MediaStreamTrackList.h in Headers */,
2238422391 BCB16C180979C3BD00467741 /* MemoryCache.h in Headers */,

2540125408 49A2CFD913E9787E00579F13 /* MediaStreamEvent.cpp in Sources */,
2540225409 B1E54595134629C10092A545 /* MediaStreamFrameController.cpp in Sources */,
2540325410 B14353D5138EA8ED00D53276 /* MediaStreamList.cpp in Sources */,
 25411 49785EE013F192F000A795AD /* MediaStreamRegistry.cpp in Sources */,
2540425412 49C9F32713D574F90052600A /* MediaStreamTrack.cpp in Sources */,
2540525413 49C9F32413D574F90052600A /* MediaStreamTrackList.cpp in Sources */,
2540625414 BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */,

Source/WebCore/dom/ScriptExecutionContext.cpp

3939#include "EventListener.h"
4040#include "EventTarget.h"
4141#include "FileThread.h"
 42#include "MediaStream.h"
 43#include "MediaStreamRegistry.h"
4244#include "MessagePort.h"
4345#include "ScriptCallStack.h"
4446#include "SecurityOrigin.h"

@@ScriptExecutionContext::~ScriptExecutionContext()
134136 (*iter)->contextDestroyed();
135137 }
136138#endif
 139
 140#if ENABLE(MEDIA_STREAM)
 141 HashSet<String>::iterator publicStreamURLsEnd = m_publicStreamURLs.end();
 142 for (HashSet<String>::iterator iter = m_publicStreamURLs.begin(); iter != publicStreamURLsEnd; ++iter)
 143 mediaStreamRegistry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter));
 144#endif
137145}
138146
139147#if ENABLE(DATABASE)

@@DOMTimer* ScriptExecutionContext::findTimeout(int timeoutId)
377385}
378386
379387#if ENABLE(BLOB)
 388
 389#if ENABLE(MEDIA_STREAM)
 390KURL ScriptExecutionContext::createPublicBlobURL(MediaStream* stream)
 391{
 392 if (!stream)
 393 return KURL();
 394
 395 KURL publicURL = BlobURL::createPublicURL(securityOrigin());
 396 publicURL.setProtocol("x-raw-media");
 397 // Since WebWorkers cannot obtain Stream objects, we should be on the main thread.
 398 ASSERT(isMainThread());
 399 mediaStreamRegistry().registerMediaStreamURL(publicURL, stream);
 400 m_publicStreamURLs.add(publicURL.string());
 401 return publicURL;
 402}
 403#endif // ENABLE(MEDIA_STREAM)
 404
380405KURL ScriptExecutionContext::createPublicBlobURL(Blob* blob)
381406{
382407 if (!blob)

@@void ScriptExecutionContext::revokePublicBlobURL(const KURL& url)
395420 ThreadableBlobRegistry::unregisterBlobURL(url);
396421 m_publicBlobURLs.remove(url.string());
397422 }
 423#if ENABLE(MEDIA_STREAM)
 424 if (m_publicStreamURLs.contains(url.string())) {
 425 // FIXME: make sure of this assertion below. Raise a spec question if required.
 426 // Since WebWorkers cannot obtain Stream objects, we should be on the main thread.
 427 ASSERT(isMainThread());
 428 mediaStreamRegistry().unregisterMediaStreamURL(url);
 429 m_publicStreamURLs.remove(url.string());
 430 }
 431#endif // ENABLE(MEDIA_STREAM)
398432}
399 #endif
 433#endif // ENABLE(BLOB)
400434
401435#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
402436FileThread* ScriptExecutionContext::fileThread()

Source/WebCore/dom/ScriptExecutionContext.h

@@namespace WebCore {
6666 class FileThread;
6767#endif
6868
 69#if ENABLE(MEDIA_STREAM)
 70 class MediaStream;
 71#endif
 72
6973 class ScriptExecutionContext {
7074 public:
7175 ScriptExecutionContext();

@@namespace WebCore {
144148 DOMTimer* findTimeout(int timeoutId);
145149
146150#if ENABLE(BLOB)
 151#if ENABLE(MEDIA_STREAM)
 152 KURL createPublicBlobURL(MediaStream*);
 153#endif // ENABLE(MEDIA_STREAM)
147154 KURL createPublicBlobURL(Blob*);
148155 void revokePublicBlobURL(const KURL&);
149 #endif
 156#endif // ENABLE(BLOB)
150157
151158#if USE(JSC)
152159 JSC::JSGlobalData* globalData();

@@namespace WebCore {
190197
191198#if ENABLE(BLOB)
192199 HashSet<String> m_publicBlobURLs;
 200 HashSet<String> m_publicStreamURLs;
193201 HashSet<DOMURL*> m_domUrls;
194202#endif
195203

Source/WebCore/html/DOMURL.cpp

@@void DOMURL::contextDestroyed()
5353 m_scriptExecutionContext = 0;
5454}
5555
 56#if ENABLE(MEDIA_STREAM)
 57String DOMURL::createObjectURL(MediaStream* stream)
 58{
 59 if (!m_scriptExecutionContext)
 60 return String();
 61 return m_scriptExecutionContext->createPublicBlobURL(stream).string();
 62}
 63#endif
 64
5665String DOMURL::createObjectURL(Blob* blob)
5766{
5867 if (!m_scriptExecutionContext)

Source/WebCore/html/DOMURL.h

3535namespace WebCore {
3636
3737class Blob;
 38class MediaStream;
3839class ScriptExecutionContext;
3940
4041class DOMURL : public RefCounted<DOMURL> {

@@public:
4243 static PassRefPtr<DOMURL> create(ScriptExecutionContext* scriptExecutionContext) { return adoptRef(new DOMURL(scriptExecutionContext)); }
4344 ~DOMURL();
4445
 46#if ENABLE(MEDIA_STREAM)
 47 String createObjectURL(MediaStream*);
 48#endif
4549 String createObjectURL(Blob*);
4650 void revokeObjectURL(const String&);
4751

Source/WebCore/html/DOMURL.idl

@@module html {
3131 GenerateToJS,
3232 NoStaticTables
3333 ] DOMURL {
 34#if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM
 35 [ConvertNullStringTo=Undefined] DOMString createObjectURL(in MediaStream stream);
 36#endif
3437 [ConvertNullStringTo=Undefined] DOMString createObjectURL(in Blob blob);
3538 void revokeObjectURL(in DOMString url);
3639 };

Source/WebCore/platform/MediaStreamRegistry.cpp

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#include "config.h"
 26#include "MediaStreamRegistry.h"
 27
 28#if ENABLE(MEDIA_STREAM)
 29
 30#include "KURL.h"
 31#include "MediaStream.h"
 32#include <wtf/MainThread.h>
 33
 34namespace WebCore {
 35
 36MediaStreamRegistry& mediaStreamRegistry()
 37{
 38 ASSERT(isMainThread());
 39 DEFINE_STATIC_LOCAL(MediaStreamRegistry, instance, ());
 40 return instance;
 41}
 42
 43void MediaStreamRegistry::registerMediaStreamURL(const KURL& url, PassRefPtr<MediaStream> stream)
 44{
 45 ASSERT(isMainThread());
 46 m_streams.add(url.string(), stream);
 47}
 48
 49void MediaStreamRegistry::unregisterMediaStreamURL(const KURL& url)
 50{
 51 ASSERT(isMainThread());
 52 m_streams.remove(url.string());
 53}
 54
 55PassRefPtr<MediaStream> MediaStreamRegistry::mediaStream(const KURL& url) const
 56{
 57 ASSERT(isMainThread());
 58 URLStreamMap::const_iterator it = m_streams.find(url.string());
 59 if (it != m_streams.end())
 60 return it->second;
 61 return 0;
 62}
 63
 64} // namespace WebCore
 65
 66#endif // ENABLE(MEDIA_STREAM)

Source/WebCore/platform/MediaStreamRegistry.h

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 23 */
 24
 25#ifndef MediaStreamRegistry_h
 26#define MediaStreamRegistry_h
 27
 28#include <wtf/HashMap.h>
 29#include <wtf/PassRefPtr.h>
 30#include <wtf/text/StringHash.h>
 31
 32namespace WebCore {
 33
 34class KURL;
 35class MediaStream;
 36
 37class MediaStreamRegistry {
 38public:
 39 // Registers a blob URL referring to the specified stream data.
 40 void registerMediaStreamURL(const KURL&, PassRefPtr<MediaStream>);
 41 void unregisterMediaStreamURL(const KURL&);
 42 PassRefPtr<MediaStream> mediaStream(const KURL&) const;
 43
 44private:
 45 // Currently assuming that the URLs keep alive their associated Streams.
 46 typedef HashMap<String, RefPtr<MediaStream> > URLStreamMap;
 47 URLStreamMap m_streams;
 48};
 49
 50// Returns a single instance of MediaStreamRegistry.
 51MediaStreamRegistry& mediaStreamRegistry();
 52
 53} // namespace WebCore
 54
 55#endif // MediaStreamRegistry_h