Changeset 105486 in webkit
- Timestamp:
- Jan 20, 2012 12:00:11 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r105485 r105486 1 2012-01-19 Kaustubh Atrawalkar <kaustubh@motorola.com> 2 3 Migrate createObjectURL & revokeObjectURL to static (Class) methods 4 https://bugs.webkit.org/show_bug.cgi?id=74386 5 6 Reviewed by Adam Barth. 7 8 Added test to check if createObjectURL & revokeObjectURL are static functions. 9 10 * fast/dom/DOMURL: Added. 11 * fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt: Added. 12 * fast/dom/DOMURL/check-instanceof-domurl-functions.html: Added. 13 1 14 2012-01-20 Alexandru Chiculita <achicu@adobe.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r105485 r105486 1 2012-01-19 Kaustubh Atrawalkar <kaustubh@motorola.com> & Erik Arvidsson <arv@chromium.org> 2 3 Migrate createObjectURL & revokeObjectURL to static (Class) methods. 4 https://bugs.webkit.org/show_bug.cgi?id=74386 5 6 Reviewed by Adam Barth. 7 8 Test: fast/dom/DOMURL/check-instanceof-domurl-functions.html 9 Already Existing - 10 fast/files/revoke-blob-url.html 11 fast/dom/window-domurl-crash.html 12 fast/files/apply-blob-url-to-img.html 13 fast/files/create-blob-url-crash.html 14 fast/files/workers/inline-worker-via-blob-url.html 15 16 * html/DOMURL.cpp: Added HashMap for local static objects. 17 (WebCore::PublicURLManager::PublicURLManager): 18 (WebCore::PublicURLManager::contextDestroyed): 19 (WebCore::PublicURLManager::blobURLs): 20 (WebCore::PublicURLManager::streamURLs): 21 (WebCore::publicURLManagerMap): 22 (WebCore::publicURLManager): 23 (WebCore::publicBlobURLs): 24 (WebCore::publicStreamURLs): 25 (WebCore::DOMURL::createObjectURL): Changed to static. 26 (WebCore::DOMURL::revokeObjectURL): ditto. 27 * html/DOMURL.h: 28 (WebCore::DOMURL::create): 29 (WebCore::DOMURL::~DOMURL): 30 (WebCore::DOMURL::DOMURL): 31 * html/DOMURL.idl: 32 * page/DOMWindow.cpp: Removed object initialization for DOMURL. 33 * page/DOMWindow.h: ditto. 34 * page/DOMWindow.idl: ditto. 35 * workers/WorkerContext.cpp: ditto. 36 * workers/WorkerContext.h: ditto. 37 * workers/WorkerContext.idl: ditto. 38 1 39 2012-01-20 Alexandru Chiculita <achicu@adobe.com> 2 40 -
trunk/Source/WebCore/html/DOMURL.cpp
r98802 r105486 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Motorola Mobility Inc. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 25 26 26 27 #include "config.h" 28 #include "DOMURL.h" 29 30 #include "ActiveDOMObject.h" 31 #include "KURL.h" 32 #include "SecurityOrigin.h" 33 #include <wtf/MainThread.h> 27 34 28 35 #if ENABLE(BLOB) 29 30 #include "DOMURL.h"31 32 36 #include "Blob.h" 33 37 #include "BlobURL.h" 34 #include "KURL.h"35 38 #include "ScriptExecutionContext.h" 36 39 #include "ThreadableBlobRegistry.h" 37 #include <wtf/MainThread.h> 38 40 #include <wtf/PassOwnPtr.h> 39 41 #if ENABLE(MEDIA_STREAM) 40 42 #include "MediaStream.h" 41 43 #include "MediaStreamRegistry.h" 42 44 #endif 45 #endif 43 46 44 47 namespace WebCore { 45 48 46 DOMURL::DOMURL(ScriptExecutionContext* scriptExecutionContext) 47 : ContextDestructionObserver(scriptExecutionContext) 49 #if ENABLE(BLOB) 50 class PublicURLManager; 51 typedef HashMap<ScriptExecutionContext*, OwnPtr<PublicURLManager> > PublicURLManagerMap; 52 static PublicURLManagerMap& publicURLManagerMap(); 53 54 class PublicURLManager : public ContextDestructionObserver { 55 public: 56 explicit PublicURLManager(ScriptExecutionContext* scriptExecutionContext) 57 : ContextDestructionObserver(scriptExecutionContext) { } 58 59 virtual void contextDestroyed() 60 { 61 HashSet<String>::iterator blobURLsEnd = m_blobURLs.end(); 62 for (HashSet<String>::iterator iter = m_blobURLs.begin(); iter != blobURLsEnd; ++iter) 63 ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter)); 64 65 #if ENABLE(MEDIA_STREAM) 66 HashSet<String>::iterator streamURLsEnd = m_streamURLs.end(); 67 for (HashSet<String>::iterator iter = m_streamURLs.begin(); iter != streamURLsEnd; ++iter) 68 MediaStreamRegistry::registry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter)); 69 #endif 70 71 ScriptExecutionContext* context = scriptExecutionContext(); 72 ContextDestructionObserver::contextDestroyed(); 73 publicURLManagerMap().remove(context); 74 } 75 76 HashSet<String>& blobURLs() { return m_blobURLs; } 77 #if ENABLE(MEDIA_STREAM) 78 HashSet<String>& streamURLs() { return m_streamURLs; } 79 #endif 80 81 private: 82 HashSet<String> m_blobURLs; 83 #if ENABLE(MEDIA_STREAM) 84 HashSet<String> m_streamURLs; 85 #endif 86 }; 87 88 static PublicURLManagerMap& publicURLManagerMap() 48 89 { 90 DEFINE_STATIC_LOCAL(PublicURLManagerMap, staticPublicURLManagers, ()); 91 return staticPublicURLManagers; 49 92 } 50 93 51 DOMURL::~DOMURL()94 static PublicURLManager& publicURLManager(ScriptExecutionContext* scriptExecutionContext) 52 95 { 96 PublicURLManagerMap& map = publicURLManagerMap(); 97 OwnPtr<PublicURLManager>& manager = map.add(scriptExecutionContext, nullptr).first->second; 98 if (!manager) 99 manager = adoptPtr(new PublicURLManager(scriptExecutionContext)); 100 return *manager; 53 101 } 54 102 55 void DOMURL::contextDestroyed()103 static HashSet<String>& publicBlobURLs(ScriptExecutionContext* scriptExecutionContext) 56 104 { 57 ContextDestructionObserver::contextDestroyed(); 58 59 HashSet<String>::iterator publicBlobURLsEnd = m_publicBlobURLs.end(); 60 for (HashSet<String>::iterator iter = m_publicBlobURLs.begin(); iter != publicBlobURLsEnd; ++iter) 61 ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter)); 62 63 #if ENABLE(MEDIA_STREAM) 64 HashSet<String>::iterator publicStreamURLsEnd = m_publicStreamURLs.end(); 65 for (HashSet<String>::iterator iter = m_publicStreamURLs.begin(); iter != publicStreamURLsEnd; ++iter) 66 MediaStreamRegistry::registry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter)); 67 #endif 105 return publicURLManager(scriptExecutionContext).blobURLs(); 68 106 } 69 107 70 108 #if ENABLE(MEDIA_STREAM) 71 String DOMURL::createObjectURL(MediaStream* stream)109 static HashSet<String>& publicStreamURLs(ScriptExecutionContext* scriptExecutionContext) 72 110 { 73 if (!m_scriptExecutionContext || !stream) 111 return publicURLManager(scriptExecutionContext).streamURLs(); 112 } 113 114 String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, MediaStream* stream) 115 { 116 if (!scriptExecutionContext || !stream) 74 117 return String(); 75 118 76 KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext ()->securityOrigin());119 KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin()); 77 120 if (publicURL.isEmpty()) 78 121 return String(); … … 82 125 83 126 MediaStreamRegistry::registry().registerMediaStreamURL(publicURL, stream); 84 m_publicStreamURLs.add(publicURL.string());127 publicStreamURLs(scriptExecutionContext).add(publicURL.string()); 85 128 86 129 return publicURL.string(); … … 88 131 #endif 89 132 90 String DOMURL::createObjectURL( Blob* blob)133 String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, Blob* blob) 91 134 { 92 if (! m_scriptExecutionContext || !blob)135 if (!scriptExecutionContext || !blob) 93 136 return String(); 94 137 95 KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext ()->securityOrigin());138 KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin()); 96 139 if (publicURL.isEmpty()) 97 140 return String(); 98 141 99 142 ThreadableBlobRegistry::registerBlobURL(publicURL, blob->url()); 100 m_publicBlobURLs.add(publicURL.string());143 publicBlobURLs(scriptExecutionContext).add(publicURL.string()); 101 144 102 145 return publicURL.string(); 103 146 } 104 147 105 void DOMURL::revokeObjectURL( const String& urlString)148 void DOMURL::revokeObjectURL(ScriptExecutionContext* scriptExecutionContext, const String& urlString) 106 149 { 107 if (! m_scriptExecutionContext)150 if (!scriptExecutionContext) 108 151 return; 109 152 110 153 KURL url(KURL(), urlString); 111 154 112 if (m_publicBlobURLs.contains(url.string())) { 155 HashSet<String>& blobURLs = publicBlobURLs(scriptExecutionContext); 156 if (blobURLs.contains(url.string())) { 113 157 ThreadableBlobRegistry::unregisterBlobURL(url); 114 m_publicBlobURLs.remove(url.string());158 blobURLs.remove(url.string()); 115 159 } 116 117 160 #if ENABLE(MEDIA_STREAM) 118 if (m_publicStreamURLs.contains(url.string())) { 161 HashSet<String>& streamURLs = publicStreamURLs(scriptExecutionContext); 162 if (streamURLs.contains(url.string())) { 119 163 // FIXME: make sure of this assertion below. Raise a spec question if required. 120 164 // Since WebWorkers cannot obtain Stream objects, we should be on the main thread. 121 165 ASSERT(isMainThread()); 122 166 MediaStreamRegistry::registry().unregisterMediaStreamURL(url); 123 m_publicStreamURLs.remove(url.string());167 streamURLs.remove(url.string()); 124 168 } 125 169 #endif 126 170 } 171 #endif // ENABLE(BLOB) 127 172 128 173 } // namespace WebCore 129 174 130 #endif // ENABLE(BLOB) -
trunk/Source/WebCore/html/DOMURL.h
r98802 r105486 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Motorola Mobility Inc. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 #define DOMURL_h 28 29 29 #if ENABLE(BLOB) 30 31 #include "ActiveDOMObject.h" 30 #include "KURL.h" 32 31 #include "PlatformString.h" 33 #include <wtf/HashSet.h>34 32 #include <wtf/PassRefPtr.h> 35 33 #include <wtf/RefCounted.h> … … 41 39 class ScriptExecutionContext; 42 40 43 class DOMURL : public RefCounted<DOMURL>, public ContextDestructionObserver { 41 class DOMURL : public RefCounted<DOMURL> { 42 44 43 public: 45 static PassRefPtr<DOMURL> create(ScriptExecutionContext* scriptExecutionContext) { return adoptRef(new DOMURL(scriptExecutionContext)); } 46 ~DOMURL(); 44 static PassRefPtr<DOMURL> create() { return adoptRef(new DOMURL); } 47 45 46 #if ENABLE(BLOB) 47 static void contextDestroyed(ScriptExecutionContext*); 48 49 static String createObjectURL(ScriptExecutionContext*, Blob*); 50 static void revokeObjectURL(ScriptExecutionContext*, const String&); 48 51 #if ENABLE(MEDIA_STREAM) 49 String createObjectURL(MediaStream*);52 static String createObjectURL(ScriptExecutionContext*, MediaStream*); 50 53 #endif 51 String createObjectURL(Blob*);52 void revokeObjectURL(const String&);53 54 private:55 explicit DOMURL(ScriptExecutionContext*);56 57 virtual void contextDestroyed();58 59 HashSet<String> m_publicBlobURLs;60 #if ENABLE(MEDIA_STREAM)61 HashSet<String> m_publicStreamURLs;62 54 #endif 63 55 }; … … 65 57 } // namespace WebCore 66 58 67 #endif // ENABLE(BLOB)68 69 59 #endif // DOMURL_h -
trunk/Source/WebCore/html/DOMURL.idl
r93713 r105486 1 1 /* 2 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Motorola Mobility Inc. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 interface [ 28 29 Conditional=BLOB, 29 OmitConstructor,30 30 GenerateNativeConverter, 31 31 GenerateToJS, 32 NoStaticTables32 Constructor 33 33 ] DOMURL { 34 34 #if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM 35 [ConvertNullStringTo=Undefined] DOMString createObjectURL(in MediaStream stream);35 static [ConvertNullStringTo=Undefined,CallWith=ScriptExecutionContext] DOMString createObjectURL(in MediaStream stream); 36 36 #endif 37 [ConvertNullStringTo=Undefined] DOMString createObjectURL(in Blob blob);38 void revokeObjectURL(in DOMString url);37 static [ConvertNullStringTo=Undefined,CallWith=ScriptExecutionContext] DOMString createObjectURL(in Blob blob); 38 static [CallWith=ScriptExecutionContext] void revokeObjectURL(in DOMString url); 39 39 }; 40 40 } -
trunk/Source/WebCore/page/DOMWindow.cpp
r105415 r105486 1893 1893 } 1894 1894 1895 #if ENABLE(BLOB)1896 DOMURL* DOMWindow::webkitURL() const1897 {1898 if (!m_domURL && isCurrentlyDisplayedInFrame())1899 m_domURL = DOMURL::create(this->scriptExecutionContext());1900 return m_domURL.get();1901 }1902 #endif1903 1904 1895 #if ENABLE(QUOTA) 1905 1896 StorageInfo* DOMWindow::webkitStorageInfo() const -
trunk/Source/WebCore/page/DOMWindow.h
r105395 r105486 352 352 using RefCounted<DOMWindow>::deref; 353 353 354 #if ENABLE(BLOB)355 DOMURL* webkitURL() const;356 #endif357 358 354 #if ENABLE(DEVICE_ORIENTATION) 359 355 DEFINE_ATTRIBUTE_EVENT_LISTENER(devicemotion); -
trunk/Source/WebCore/page/DOMWindow.idl
r105217 r105486 799 799 attribute [Conditional=BLOB] WebKitBlobBuilderConstructor WebKitBlobBuilder; 800 800 801 readonly attribute [Conditional=BLOB] DOMURLwebkitURL;801 attribute [Conditional=BLOB] DOMURLConstructor webkitURL; 802 802 803 803 #if defined(ENABLE_QUOTA) && ENABLE_QUOTA -
trunk/Source/WebCore/workers/WorkerContext.cpp
r105395 r105486 378 378 } 379 379 380 #if ENABLE(BLOB)381 DOMURL* WorkerContext::webkitURL() const382 {383 if (!m_domURL)384 m_domURL = DOMURL::create(this->scriptExecutionContext());385 return m_domURL.get();386 }387 #endif388 389 380 #if ENABLE(FILE_SYSTEM) 390 381 void WorkerContext::webkitRequestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) -
trunk/Source/WebCore/workers/WorkerContext.h
r104803 r105486 132 132 virtual bool isJSExecutionForbidden() const; 133 133 134 #if ENABLE(BLOB)135 DOMURL* webkitURL() const;136 #endif137 138 134 #if ENABLE(FILE_SYSTEM) 139 135 enum FileSystemType { -
trunk/Source/WebCore/workers/WorkerContext.idl
r104126 r105486 102 102 #endif 103 103 104 readonly attribute [Conditional=BLOB] DOMURLwebkitURL;104 attribute [Conditional=BLOB] DOMURLConstructor webkitURL; 105 105 106 106 #if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
Note: See TracChangeset
for help on using the changeset viewer.