Migrate createObjectURL & revokeObjectURL to static (Class) methods.
https://bugs.webkit.org/show_bug.cgi?id=74386

Patch by Kaustubh Atrawalkar <kaustubh@motorola.com> 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/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 <wtf/HashSet.h>
+
+#if ENABLE(MEDIA_STREAM)
+#include "MediaStream.h"
+#include "MediaStreamRegistry.h"
+#endif
+
+namespace WebCore {
+
+class ScriptExecutionContext;
+
+class PublicURLManager {
+
+public:
+    static PassOwnPtr<PublicURLManager> create() { return adoptPtr(new PublicURLManager); }
+    void contextDestroyed()
+    {
+        HashSet<String>::iterator blobURLsEnd = m_blobURLs.end();
+        for (HashSet<String>::iterator iter = m_blobURLs.begin(); iter != blobURLsEnd; ++iter)
+            ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter));
+
+#if ENABLE(MEDIA_STREAM)
+        HashSet<String>::iterator streamURLsEnd = m_streamURLs.end();
+        for (HashSet<String>::iterator iter = m_streamURLs.begin(); iter != streamURLsEnd; ++iter)
+            MediaStreamRegistry::registry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter));
+#endif
+    }
+
+    HashSet<String>& blobURLs() { return m_blobURLs; }
+#if ENABLE(MEDIA_STREAM)
+    HashSet<String>& streamURLs() { return m_streamURLs; }
+#endif
+
+private:
+    HashSet<String> m_blobURLs;
+#if ENABLE(MEDIA_STREAM)
+    HashSet<String> m_streamURLs;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // BLOB
+#endif // PUBLICURLMANAGER_h