From: commit-queue@webkit.org Date: Wed, 8 Feb 2012 14:39:18 +0000 (+0000) Subject: Migrate createObjectURL & revokeObjectURL to static (Class) methods. X-Git-Tag: 070512121124~13462 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cd6827846a5e5d09e89e1d01d235cabf55b2ea5;p=profile%2Fivi%2Fwebkit-efl.git Migrate createObjectURL & revokeObjectURL to static (Class) methods. https://bugs.webkit.org/show_bug.cgi?id=74386 Patch by Kaustubh Atrawalkar on 2012-02-08 Reviewed by Kentaro Hara. Source/WebCore: Move createObjectURL & revokeObjectURL from DOMURL implementation to static methods as per specs - http://www.w3.org/TR/FileAPI/#creating-revoking Test: fast/dom/DOMURL/check-instanceof-domurl-functions.html Already Existing: fast/files/revoke-blob-url.html fast/dom/window-domurl-crash.html fast/files/apply-blob-url-to-img.html fast/files/create-blob-url-crash.html fast/files/workers/inline-worker-via-blob-url.html * GNUmakefile.list.am: * Target.pri: * WebCore.gypi: * WebCore.vcproj/WebCore.vcproj: * WebCore.xcodeproj/project.pbxproj: * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::~ScriptExecutionContext): (WebCore::ScriptExecutionContext::fileThread): (WebCore): (WebCore::ScriptExecutionContext::publicURLManager): * dom/ScriptExecutionContext.h: (WebCore): (ScriptExecutionContext): * html/DOMURL.cpp: (WebCore): (WebCore::DOMURL::createObjectURL): Changed to static. (WebCore::DOMURL::revokeObjectURL): ditto. * html/DOMURL.h: (DOMURL): (WebCore::DOMURL::create): * html/DOMURL.idl: * html/PublicURLManager.h: Added. (WebCore): (PublicURLManager): (WebCore::PublicURLManager::create): (WebCore::PublicURLManager::contextDestroyed): (WebCore::PublicURLManager::blobURLs): (WebCore::PublicURLManager::streamURLs): * page/DOMWindow.cpp: Removed object initialization for DOMURL. (WebCore): * page/DOMWindow.h: ditto. (DOMWindow): * page/DOMWindow.idl: * workers/WorkerContext.cpp: (WebCore): * workers/WorkerContext.h: (WorkerContext): * workers/WorkerContext.idl: LayoutTests: Added test to check if createObjectURL & revokeObjectURL are static functions. * fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt: Added. * fast/dom/DOMURL/check-instanceof-domurl-functions.html: Added. * platform/gtk/fast/dom/prototype-inheritance-2-expected.txt: GTK Rebaseline. * platform/gtk/fast/js/global-constructors-expected.txt: ditto. * platform/qt/fast/dom/constructed-objects-prototypes-expected.txt: Qt Rebaseline. * platform/qt/fast/dom/prototype-inheritance-2-expected.txt: ditto. * platform/qt/fast/js/global-constructors-expected.txt: ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107082 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 3912758..7c158fb 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,20 @@ +2012-02-08 Kaustubh Atrawalkar + + Migrate createObjectURL & revokeObjectURL to static (Class) methods. + https://bugs.webkit.org/show_bug.cgi?id=74386 + + Reviewed by Kentaro Hara. + + Added test to check if createObjectURL & revokeObjectURL are static functions. + + * fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt: Added. + * fast/dom/DOMURL/check-instanceof-domurl-functions.html: Added. + * platform/gtk/fast/dom/prototype-inheritance-2-expected.txt: GTK Rebaseline. + * platform/gtk/fast/js/global-constructors-expected.txt: ditto. + * platform/qt/fast/dom/constructed-objects-prototypes-expected.txt: Qt Rebaseline. + * platform/qt/fast/dom/prototype-inheritance-2-expected.txt: ditto. + * platform/qt/fast/js/global-constructors-expected.txt: ditto. + 2012-02-08 Pavel Podivilov Unreviewed, chromium expectations update: mark repaint-on-image-bounds-change.svg as IMAGE+TEXT IMAGE. diff --git a/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt b/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt new file mode 100644 index 0000000..1d8c3b2 --- /dev/null +++ b/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt @@ -0,0 +1,15 @@ +Test instanceof functions and properties of webkitURL. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS 'createObjectURL' in webkitURL is true +PASS 'revokeObjectURL' in webkitURL is true +PASS url.createObjectURL is undefined. +PASS url.revokeObjectURL is undefined. +PASS window.webkitURL.createObjectURL is defined. +PASS window.webkitURL.revokeObjectURL is defined. +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions.html b/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions.html new file mode 100644 index 0000000..3aa5c4d --- /dev/null +++ b/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions.html @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/LayoutTests/platform/gtk/fast/dom/prototype-inheritance-2-expected.txt b/LayoutTests/platform/gtk/fast/dom/prototype-inheritance-2-expected.txt index 1545868..3753408 100644 --- a/LayoutTests/platform/gtk/fast/dom/prototype-inheritance-2-expected.txt +++ b/LayoutTests/platform/gtk/fast/dom/prototype-inheritance-2-expected.txt @@ -240,6 +240,7 @@ Never found Clipboard Never found DOMParser Never found DOMSettableTokenList Never found DOMStringList +Never found DOMURL Never found Document Never found DocumentFragment Never found DocumentType diff --git a/LayoutTests/platform/gtk/fast/js/global-constructors-expected.txt b/LayoutTests/platform/gtk/fast/js/global-constructors-expected.txt index d871027..a964f66 100644 --- a/LayoutTests/platform/gtk/fast/js/global-constructors-expected.txt +++ b/LayoutTests/platform/gtk/fast/js/global-constructors-expected.txt @@ -333,6 +333,7 @@ PASS XPathException.toString() is '[object XPathExceptionConstructor]' PASS XPathResult.toString() is '[object XPathResultConstructor]' PASS XSLTProcessor.toString() is '[object XSLTProcessorConstructor]' FAIL webkitPeerConnection.toString() should be [object webkitPeerConnectionConstructor]. Was [object PeerConnectionConstructor]. +FAIL webkitURL.toString() should be [object webkitURLConstructor]. Was [object DOMURLConstructor]. PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/platform/qt/fast/dom/constructed-objects-prototypes-expected.txt b/LayoutTests/platform/qt/fast/dom/constructed-objects-prototypes-expected.txt index 97441e9..07074f8 100644 --- a/LayoutTests/platform/qt/fast/dom/constructed-objects-prototypes-expected.txt +++ b/LayoutTests/platform/qt/fast/dom/constructed-objects-prototypes-expected.txt @@ -61,6 +61,8 @@ PASS (new inner.XPathEvaluator()).isInner is true PASS (new inner.XPathEvaluator()).constructor.isInner is true PASS (new inner.XSLTProcessor()).isInner is true PASS (new inner.XSLTProcessor()).constructor.isInner is true +PASS (new inner.webkitURL()).isInner is true +PASS (new inner.webkitURL()).constructor.isInner is true PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/platform/qt/fast/dom/prototype-inheritance-2-expected.txt b/LayoutTests/platform/qt/fast/dom/prototype-inheritance-2-expected.txt index d32a5a3..bfad44c 100644 --- a/LayoutTests/platform/qt/fast/dom/prototype-inheritance-2-expected.txt +++ b/LayoutTests/platform/qt/fast/dom/prototype-inheritance-2-expected.txt @@ -240,6 +240,7 @@ Never found Clipboard Never found DOMParser Never found DOMSettableTokenList Never found DOMStringList +Never found DOMURL Never found Document Never found DocumentFragment Never found DocumentType diff --git a/LayoutTests/platform/qt/fast/js/global-constructors-expected.txt b/LayoutTests/platform/qt/fast/js/global-constructors-expected.txt index 047b28f..4ba51ea 100644 --- a/LayoutTests/platform/qt/fast/js/global-constructors-expected.txt +++ b/LayoutTests/platform/qt/fast/js/global-constructors-expected.txt @@ -315,6 +315,7 @@ PASS XPathEvaluator.toString() is '[object XPathEvaluatorConstructor]' PASS XPathException.toString() is '[object XPathExceptionConstructor]' PASS XPathResult.toString() is '[object XPathResultConstructor]' PASS XSLTProcessor.toString() is '[object XSLTProcessorConstructor]' +FAIL webkitURL.toString() should be [object webkitURLConstructor]. Was [object DOMURLConstructor]. PASS successfullyParsed is true TEST COMPLETE diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 705ba4b..08a25a9 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,60 @@ +2012-02-08 Kaustubh Atrawalkar + + Migrate createObjectURL & revokeObjectURL to static (Class) methods. + https://bugs.webkit.org/show_bug.cgi?id=74386 + + Reviewed by Kentaro Hara. + + Move createObjectURL & revokeObjectURL from DOMURL implementation to + static methods as per specs - http://www.w3.org/TR/FileAPI/#creating-revoking + + Test: fast/dom/DOMURL/check-instanceof-domurl-functions.html + Already Existing: + fast/files/revoke-blob-url.html + fast/dom/window-domurl-crash.html + fast/files/apply-blob-url-to-img.html + fast/files/create-blob-url-crash.html + fast/files/workers/inline-worker-via-blob-url.html + + * GNUmakefile.list.am: + * Target.pri: + * WebCore.gypi: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * dom/ScriptExecutionContext.cpp: + (WebCore::ScriptExecutionContext::~ScriptExecutionContext): + (WebCore::ScriptExecutionContext::fileThread): + (WebCore): + (WebCore::ScriptExecutionContext::publicURLManager): + * dom/ScriptExecutionContext.h: + (WebCore): + (ScriptExecutionContext): + * html/DOMURL.cpp: + (WebCore): + (WebCore::DOMURL::createObjectURL): Changed to static. + (WebCore::DOMURL::revokeObjectURL): ditto. + * html/DOMURL.h: + (DOMURL): + (WebCore::DOMURL::create): + * html/DOMURL.idl: + * html/PublicURLManager.h: Added. + (WebCore): + (PublicURLManager): + (WebCore::PublicURLManager::create): + (WebCore::PublicURLManager::contextDestroyed): + (WebCore::PublicURLManager::blobURLs): + (WebCore::PublicURLManager::streamURLs): + * page/DOMWindow.cpp: Removed object initialization for DOMURL. + (WebCore): + * page/DOMWindow.h: ditto. + (DOMWindow): + * page/DOMWindow.idl: + * workers/WorkerContext.cpp: + (WebCore): + * workers/WorkerContext.h: + (WorkerContext): + * workers/WorkerContext.idl: + 2012-02-01 Brian Grinstead Web Inspector: Add changes for Spectrum colorpicker diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index dfe4931..29a0097 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -2256,6 +2256,7 @@ webcore_sources += \ Source/WebCore/html/PasswordInputType.h \ Source/WebCore/html/PluginDocument.cpp \ Source/WebCore/html/PluginDocument.h \ + Source/WebCore/html/PublicURLManager.h \ Source/WebCore/html/RadioInputType.cpp \ Source/WebCore/html/RadioInputType.h \ Source/WebCore/html/RangeInputType.cpp \ diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index 811d249..023a41e 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -1880,6 +1880,7 @@ HEADERS += \ html/MediaFragmentURIParser.h \ html/MicroDataItemValue.h \ html/PluginDocument.h \ + html/PublicURLManager.h \ html/StepRange.h \ html/TextDocument.h \ html/TextTrack.h \ diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index ff24855..38fafda 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -5375,6 +5375,7 @@ 'html/PasswordInputType.h', 'html/PluginDocument.cpp', 'html/PluginDocument.h', + 'html/PublicURLManager.h', 'html/RadioInputType.cpp', 'html/RadioInputType.h', 'html/RangeInputType.cpp', diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj index 0f4dc47..fc4a218 100755 --- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj @@ -60494,6 +60494,10 @@ > + + diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj index be30a5c..9ce401b 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -279,6 +279,7 @@ 0FF5026A102BA9430066F39A /* JSStyleMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF50268102BA9430066F39A /* JSStyleMedia.h */; }; 0FF50271102BA96A0066F39A /* StyleMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF5026E102BA9660066F39A /* StyleMedia.cpp */; }; 0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF5026F102BA96A0066F39A /* StyleMedia.h */; }; + 10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */; }; 1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1402645D0AFDC19B005919E2 /* LoggingMac.mm */; }; 1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1403B99609EB13AF00797C7F /* DOMWindow.cpp */; }; @@ -6980,6 +6981,7 @@ 0FF5026E102BA9660066F39A /* StyleMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleMedia.cpp; sourceTree = ""; }; 0FF5026F102BA96A0066F39A /* StyleMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleMedia.h; sourceTree = ""; }; 0FF50270102BA96A0066F39A /* StyleMedia.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = StyleMedia.idl; sourceTree = ""; }; + 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicURLManager.h; sourceTree = ""; }; 1402645D0AFDC19B005919E2 /* LoggingMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingMac.mm; sourceTree = ""; }; 1403B90C09EB124500797C7F /* DOMWindow.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMWindow.idl; sourceTree = ""; }; 1403B99509EB13AF00797C7F /* DOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindow.h; sourceTree = ""; }; @@ -16941,6 +16943,7 @@ F55B3D961251F12D003EF269 /* PasswordInputType.h */, 97205AB91239292700B17380 /* PluginDocument.cpp */, 97205ABA1239292700B17380 /* PluginDocument.h */, + 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */, F55B3D971251F12D003EF269 /* RadioInputType.cpp */, F55B3D981251F12D003EF269 /* RadioInputType.h */, F55B3D991251F12D003EF269 /* RangeInputType.cpp */, @@ -24157,6 +24160,7 @@ 1AAADDBF14DC640700AF64B3 /* ScrollingTreeState.h in Headers */, 1AAADDE414DC8C8F00AF64B3 /* ScrollingTreeNode.h in Headers */, 1AAADDE914DC8DF800AF64B3 /* ScrollingTreeNodeMac.h in Headers */, + 10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */, 7A54858014E02D51006AE05A /* InspectorHistory.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Source/WebCore/dom/ScriptExecutionContext.cpp b/Source/WebCore/dom/ScriptExecutionContext.cpp index ef06c29..5670fe8 100644 --- a/Source/WebCore/dom/ScriptExecutionContext.cpp +++ b/Source/WebCore/dom/ScriptExecutionContext.cpp @@ -38,6 +38,7 @@ #include "EventTarget.h" #include "FileThread.h" #include "MessagePort.h" +#include "PublicURLManager.h" #include "ScriptCallStack.h" #include "SecurityOrigin.h" #include "Settings.h" @@ -126,6 +127,10 @@ ScriptExecutionContext::~ScriptExecutionContext() m_fileThread = 0; } #endif +#if ENABLE(BLOB) + if (m_publicURLManager) + m_publicURLManager->contextDestroyed(); +#endif } #if ENABLE(SQL_DATABASE) @@ -385,6 +390,15 @@ FileThread* ScriptExecutionContext::fileThread() } #endif +#if ENABLE(BLOB) +PublicURLManager& ScriptExecutionContext::publicURLManager() +{ + if (!m_publicURLManager) + m_publicURLManager = PublicURLManager::create(); + return *m_publicURLManager; +} +#endif + void ScriptExecutionContext::adjustMinimumTimerInterval(double oldMinimumTimerInterval) { if (minimumTimerInterval() != oldMinimumTimerInterval) { diff --git a/Source/WebCore/dom/ScriptExecutionContext.h b/Source/WebCore/dom/ScriptExecutionContext.h index aed3411..6cbdd02 100644 --- a/Source/WebCore/dom/ScriptExecutionContext.h +++ b/Source/WebCore/dom/ScriptExecutionContext.h @@ -53,6 +53,9 @@ class EventQueue; class EventTarget; class MessagePort; +#if ENABLE(BLOB) +class PublicURLManager; +#endif #if ENABLE(SQL_DATABASE) class Database; class DatabaseTaskSynchronizer; @@ -103,6 +106,9 @@ public: virtual void resumeActiveDOMObjects(); virtual void stopActiveDOMObjects(); +#if ENABLE(BLOB) + PublicURLManager& publicURLManager(); +#endif void didCreateActiveDOMObject(ActiveDOMObject*, void* upcastPointer); void willDestroyActiveDOMObject(ActiveDOMObject*); @@ -205,6 +211,9 @@ private: bool m_inDispatchErrorEvent; class PendingException; OwnPtr > > m_pendingExceptions; +#if ENABLE(BLOB) + OwnPtr m_publicURLManager; +#endif #if ENABLE(SQL_DATABASE) RefPtr m_databaseThread; diff --git a/Source/WebCore/html/DOMURL.cpp b/Source/WebCore/html/DOMURL.cpp index e42060d..086bf77 100644 --- a/Source/WebCore/html/DOMURL.cpp +++ b/Source/WebCore/html/DOMURL.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Motorola Mobility Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,11 +30,15 @@ #include "DOMURL.h" +#include "ActiveDOMObject.h" #include "Blob.h" #include "BlobURL.h" #include "KURL.h" +#include "PublicURLManager.h" #include "ScriptExecutionContext.h" +#include "SecurityOrigin.h" #include "ThreadableBlobRegistry.h" +#include #include #if ENABLE(MEDIA_STREAM) @@ -43,37 +48,13 @@ namespace WebCore { -DOMURL::DOMURL(ScriptExecutionContext* scriptExecutionContext) - : ContextDestructionObserver(scriptExecutionContext) -{ -} - -DOMURL::~DOMURL() -{ -} - -void DOMURL::contextDestroyed() -{ - ContextDestructionObserver::contextDestroyed(); - - HashSet::iterator publicBlobURLsEnd = m_publicBlobURLs.end(); - for (HashSet::iterator iter = m_publicBlobURLs.begin(); iter != publicBlobURLsEnd; ++iter) - ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter)); - -#if ENABLE(MEDIA_STREAM) - HashSet::iterator publicStreamURLsEnd = m_publicStreamURLs.end(); - for (HashSet::iterator iter = m_publicStreamURLs.begin(); iter != publicStreamURLsEnd; ++iter) - MediaStreamRegistry::registry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter)); -#endif -} - #if ENABLE(MEDIA_STREAM) -String DOMURL::createObjectURL(MediaStream* stream) +String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, MediaStream* stream) { - if (!m_scriptExecutionContext || !stream) + if (!scriptExecutionContext || !stream) return String(); - KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext()->securityOrigin()); + KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin()); if (publicURL.isEmpty()) return String(); @@ -81,46 +62,48 @@ String DOMURL::createObjectURL(MediaStream* stream) ASSERT(isMainThread()); MediaStreamRegistry::registry().registerMediaStreamURL(publicURL, stream); - m_publicStreamURLs.add(publicURL.string()); + scriptExecutionContext->publicURLManager().streamURLs().add(publicURL.string()); return publicURL.string(); } #endif -String DOMURL::createObjectURL(Blob* blob) +String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, Blob* blob) { - if (!m_scriptExecutionContext || !blob) + if (!scriptExecutionContext || !blob) return String(); - KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext()->securityOrigin()); + KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin()); if (publicURL.isEmpty()) return String(); ThreadableBlobRegistry::registerBlobURL(publicURL, blob->url()); - m_publicBlobURLs.add(publicURL.string()); + scriptExecutionContext->publicURLManager().blobURLs().add(publicURL.string()); return publicURL.string(); } -void DOMURL::revokeObjectURL(const String& urlString) +void DOMURL::revokeObjectURL(ScriptExecutionContext* scriptExecutionContext, const String& urlString) { - if (!m_scriptExecutionContext) + if (!scriptExecutionContext) return; KURL url(KURL(), urlString); - if (m_publicBlobURLs.contains(url.string())) { + HashSet& blobURLs = scriptExecutionContext->publicURLManager().blobURLs(); + if (blobURLs.contains(url.string())) { ThreadableBlobRegistry::unregisterBlobURL(url); - m_publicBlobURLs.remove(url.string()); + blobURLs.remove(url.string()); } #if ENABLE(MEDIA_STREAM) - if (m_publicStreamURLs.contains(url.string())) { + HashSet& streamURLs = scriptExecutionContext->publicURLManager().streamURLs(); + if (streamURLs.contains(url.string())) { // FIXME: make sure of this assertion below. Raise a spec question if required. // Since WebWorkers cannot obtain Stream objects, we should be on the main thread. ASSERT(isMainThread()); MediaStreamRegistry::registry().unregisterMediaStreamURL(url); - m_publicStreamURLs.remove(url.string()); + streamURLs.remove(url.string()); } #endif } diff --git a/Source/WebCore/html/DOMURL.h b/Source/WebCore/html/DOMURL.h index d02fe88..25ae013 100644 --- a/Source/WebCore/html/DOMURL.h +++ b/Source/WebCore/html/DOMURL.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Motorola Mobility Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,9 +27,7 @@ #ifndef DOMURL_h #define DOMURL_h -#if ENABLE(BLOB) - -#include "ActiveDOMObject.h" +#include "KURL.h" #include "PlatformString.h" #include #include @@ -40,30 +39,22 @@ class Blob; class MediaStream; class ScriptExecutionContext; -class DOMURL : public RefCounted, public ContextDestructionObserver { -public: - static PassRefPtr create(ScriptExecutionContext* scriptExecutionContext) { return adoptRef(new DOMURL(scriptExecutionContext)); } - ~DOMURL(); - -#if ENABLE(MEDIA_STREAM) - String createObjectURL(MediaStream*); -#endif - String createObjectURL(Blob*); - void revokeObjectURL(const String&); +class DOMURL : public RefCounted { -private: - explicit DOMURL(ScriptExecutionContext*); +public: + static PassRefPtr create() { return adoptRef(new DOMURL); } - virtual void contextDestroyed(); +#if ENABLE(BLOB) + static void contextDestroyed(ScriptExecutionContext*); - HashSet m_publicBlobURLs; + static String createObjectURL(ScriptExecutionContext*, Blob*); + static void revokeObjectURL(ScriptExecutionContext*, const String&); #if ENABLE(MEDIA_STREAM) - HashSet m_publicStreamURLs; + static String createObjectURL(ScriptExecutionContext*, MediaStream*); +#endif #endif }; } // namespace WebCore -#endif // ENABLE(BLOB) - #endif // DOMURL_h diff --git a/Source/WebCore/html/DOMURL.idl b/Source/WebCore/html/DOMURL.idl index 967b1be..4f9722d 100644 --- a/Source/WebCore/html/DOMURL.idl +++ b/Source/WebCore/html/DOMURL.idl @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2012 Motorola Mobility Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,15 +27,15 @@ module html { interface [ Conditional=BLOB, - OmitConstructor, + Constructor, JSGenerateToNativeObject, JSGenerateToJS, JSNoStaticTables ] DOMURL { #if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM - [ConvertNullStringTo=Undefined] DOMString createObjectURL(in MediaStream stream); + static [CallWith=ScriptExecutionContext,ConvertNullStringTo=Undefined] DOMString createObjectURL(in MediaStream stream); #endif - [ConvertNullStringTo=Undefined] DOMString createObjectURL(in Blob blob); - void revokeObjectURL(in DOMString url); + static [CallWith=ScriptExecutionContext,ConvertNullStringTo=Undefined] DOMString createObjectURL(in Blob blob); + static [CallWith=ScriptExecutionContext] void revokeObjectURL(in DOMString url); }; } diff --git a/Source/WebCore/html/PublicURLManager.h b/Source/WebCore/html/PublicURLManager.h new file mode 100644 index 0000000..258ac06 --- /dev/null +++ b/Source/WebCore/html/PublicURLManager.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2012 Motorola Mobility Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PublicURLManager_h +#define PublicURLManager_h + +#if ENABLE(BLOB) +#include "PlatformString.h" +#include "ScriptExecutionContext.h" +#include "ThreadableBlobRegistry.h" +#include + +#if ENABLE(MEDIA_STREAM) +#include "MediaStream.h" +#include "MediaStreamRegistry.h" +#endif + +namespace WebCore { + +class ScriptExecutionContext; + +class PublicURLManager { + +public: + static PassOwnPtr create() { return adoptPtr(new PublicURLManager); } + void contextDestroyed() + { + HashSet::iterator blobURLsEnd = m_blobURLs.end(); + for (HashSet::iterator iter = m_blobURLs.begin(); iter != blobURLsEnd; ++iter) + ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter)); + +#if ENABLE(MEDIA_STREAM) + HashSet::iterator streamURLsEnd = m_streamURLs.end(); + for (HashSet::iterator iter = m_streamURLs.begin(); iter != streamURLsEnd; ++iter) + MediaStreamRegistry::registry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter)); +#endif + } + + HashSet& blobURLs() { return m_blobURLs; } +#if ENABLE(MEDIA_STREAM) + HashSet& streamURLs() { return m_streamURLs; } +#endif + +private: + HashSet m_blobURLs; +#if ENABLE(MEDIA_STREAM) + HashSet m_streamURLs; +#endif +}; + +} // namespace WebCore + +#endif // BLOB +#endif // PUBLICURLMANAGER_h diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp index 739e2ae..2597f86 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -1897,15 +1897,6 @@ void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea dialogFrame->page()->chrome()->runModal(); } -#if ENABLE(BLOB) -DOMURL* DOMWindow::webkitURL() const -{ - if (!m_domURL && isCurrentlyDisplayedInFrame()) - m_domURL = DOMURL::create(this->scriptExecutionContext()); - return m_domURL.get(); -} -#endif - #if ENABLE(QUOTA) StorageInfo* DOMWindow::webkitStorageInfo() const { diff --git a/Source/WebCore/page/DOMWindow.h b/Source/WebCore/page/DOMWindow.h index 38e8c5d..96a58e5 100644 --- a/Source/WebCore/page/DOMWindow.h +++ b/Source/WebCore/page/DOMWindow.h @@ -351,10 +351,6 @@ namespace WebCore { using RefCounted::ref; using RefCounted::deref; -#if ENABLE(BLOB) - DOMURL* webkitURL() const; -#endif - #if ENABLE(DEVICE_ORIENTATION) DEFINE_ATTRIBUTE_EVENT_LISTENER(devicemotion); DEFINE_ATTRIBUTE_EVENT_LISTENER(deviceorientation); diff --git a/Source/WebCore/page/DOMWindow.idl b/Source/WebCore/page/DOMWindow.idl index 0792439..41ace04 100644 --- a/Source/WebCore/page/DOMWindow.idl +++ b/Source/WebCore/page/DOMWindow.idl @@ -782,7 +782,7 @@ module window { attribute [Conditional=BLOB] WebKitBlobBuilderConstructor WebKitBlobBuilder; - readonly attribute [Conditional=BLOB] DOMURL webkitURL; + attribute [Conditional=BLOB] DOMURLConstructor webkitURL; #if defined(ENABLE_QUOTA) && ENABLE_QUOTA readonly attribute [V8EnabledAtRuntime=Quota] StorageInfo webkitStorageInfo; diff --git a/Source/WebCore/workers/WorkerContext.cpp b/Source/WebCore/workers/WorkerContext.cpp index fbed36b..0d68c4d 100644 --- a/Source/WebCore/workers/WorkerContext.cpp +++ b/Source/WebCore/workers/WorkerContext.cpp @@ -377,15 +377,6 @@ EventTargetData* WorkerContext::ensureEventTargetData() return &m_eventTargetData; } -#if ENABLE(BLOB) -DOMURL* WorkerContext::webkitURL() const -{ - if (!m_domURL) - m_domURL = DOMURL::create(this->scriptExecutionContext()); - return m_domURL.get(); -} -#endif - #if ENABLE(FILE_SYSTEM) void WorkerContext::webkitRequestFileSystem(int type, long long size, PassRefPtr successCallback, PassRefPtr errorCallback) { diff --git a/Source/WebCore/workers/WorkerContext.h b/Source/WebCore/workers/WorkerContext.h index 43d2e2e..25ca63b 100644 --- a/Source/WebCore/workers/WorkerContext.h +++ b/Source/WebCore/workers/WorkerContext.h @@ -131,10 +131,6 @@ namespace WebCore { virtual bool isContextThread() const; virtual bool isJSExecutionForbidden() const; -#if ENABLE(BLOB) - DOMURL* webkitURL() const; -#endif - #if ENABLE(FILE_SYSTEM) enum FileSystemType { TEMPORARY, diff --git a/Source/WebCore/workers/WorkerContext.idl b/Source/WebCore/workers/WorkerContext.idl index 278c30a..a2cd239 100644 --- a/Source/WebCore/workers/WorkerContext.idl +++ b/Source/WebCore/workers/WorkerContext.idl @@ -101,7 +101,7 @@ module threads { attribute FileReaderSyncConstructor FileReaderSync; #endif - readonly attribute [Conditional=BLOB] DOMURL webkitURL; + attribute [Conditional=BLOB] DOMURLConstructor webkitURL; #if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM const unsigned short TEMPORARY = 0;