Title: [98787] trunk/Source/WebCore
Revision
98787
Author
[email protected]
Date
2011-10-28 17:30:00 -0700 (Fri, 28 Oct 2011)

Log Message

Make DOMURL a ContextDestructionObserver
https://bugs.webkit.org/show_bug.cgi?id=71162

Reviewed by Eric Seidel.

This removes a bunch of hand-rolled ifdefed code.

* dom/ActiveDOMObject.h:
    - One-argument constructors should be explicit.
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* html/DOMURL.cpp:
(WebCore::DOMURL::DOMURL):
(WebCore::DOMURL::~DOMURL):
* html/DOMURL.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98786 => 98787)


--- trunk/Source/WebCore/ChangeLog	2011-10-29 00:10:11 UTC (rev 98786)
+++ trunk/Source/WebCore/ChangeLog	2011-10-29 00:30:00 UTC (rev 98787)
@@ -1,5 +1,24 @@
 2011-10-28  Adam Barth  <[email protected]>
 
+        Make DOMURL a ContextDestructionObserver
+        https://bugs.webkit.org/show_bug.cgi?id=71162
+
+        Reviewed by Eric Seidel.
+
+        This removes a bunch of hand-rolled ifdefed code.
+
+        * dom/ActiveDOMObject.h:
+            - One-argument constructors should be explicit.
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
+        * dom/ScriptExecutionContext.h:
+        * html/DOMURL.cpp:
+        (WebCore::DOMURL::DOMURL):
+        (WebCore::DOMURL::~DOMURL):
+        * html/DOMURL.h:
+
+2011-10-28  Adam Barth  <[email protected]>
+
         Factor ContextDestructionObserver out of ActiveDOMObject
         https://bugs.webkit.org/show_bug.cgi?id=71153
 

Modified: trunk/Source/WebCore/dom/ActiveDOMObject.h (98786 => 98787)


--- trunk/Source/WebCore/dom/ActiveDOMObject.h	2011-10-29 00:10:11 UTC (rev 98786)
+++ trunk/Source/WebCore/dom/ActiveDOMObject.h	2011-10-29 00:30:00 UTC (rev 98787)
@@ -36,7 +36,7 @@
     // FIXME: Move this class to it's own file.
     class ContextDestructionObserver {
     public:
-        ContextDestructionObserver(ScriptExecutionContext*);
+        explicit ContextDestructionObserver(ScriptExecutionContext*);
         virtual void contextDestroyed();
 
         ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (98786 => 98787)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2011-10-29 00:10:11 UTC (rev 98786)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2011-10-29 00:30:00 UTC (rev 98787)
@@ -134,12 +134,6 @@
     HashSet<String>::iterator publicBlobURLsEnd = m_publicBlobURLs.end();
     for (HashSet<String>::iterator iter = m_publicBlobURLs.begin(); iter != publicBlobURLsEnd; ++iter)
         ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter));
-
-    HashSet<DOMURL*>::iterator domUrlsEnd = m_domUrls.end();
-    for (HashSet<DOMURL*>::iterator iter = m_domUrls.begin(); iter != domUrlsEnd; ++iter) {
-        ASSERT((*iter)->scriptExecutionContext() == this);
-        (*iter)->contextDestroyed();
-    }
 #endif
 
 #if ENABLE(MEDIA_STREAM)
@@ -220,20 +214,6 @@
     m_messagePorts.remove(port);
 }
 
-#if ENABLE(BLOB)
-void ScriptExecutionContext::createdDomUrl(DOMURL* url)
-{
-    ASSERT(url);
-    m_domUrls.add(url);
-}
-
-void ScriptExecutionContext::destroyedDomUrl(DOMURL* url)
-{
-    ASSERT(url);
-    m_domUrls.remove(url);
-}
-#endif
-
 bool ScriptExecutionContext::canSuspendActiveDOMObjects()
 {
     // No protection against m_activeDOMObjects changing during iteration: canSuspend() shouldn't execute arbitrary JS.

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (98786 => 98787)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.h	2011-10-29 00:10:11 UTC (rev 98786)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h	2011-10-29 00:30:00 UTC (rev 98787)
@@ -133,11 +133,6 @@
     void destroyedMessagePort(MessagePort*);
     const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; }
 
-#if ENABLE(BLOB)
-    void createdDomUrl(DOMURL*);
-    void destroyedDomUrl(DOMURL*);
-    const HashSet<DOMURL*>& domUrls() const { return m_domUrls; }
-#endif
     void ref() { refScriptExecutionContext(); }
     void deref() { derefScriptExecutionContext(); }
 
@@ -214,7 +209,6 @@
 #if ENABLE(BLOB)
     HashSet<String> m_publicBlobURLs;
     HashSet<String> m_publicStreamURLs;
-    HashSet<DOMURL*> m_domUrls;
 #endif
 
     virtual void refScriptExecutionContext() = 0;

Modified: trunk/Source/WebCore/html/DOMURL.cpp (98786 => 98787)


--- trunk/Source/WebCore/html/DOMURL.cpp	2011-10-29 00:10:11 UTC (rev 98786)
+++ trunk/Source/WebCore/html/DOMURL.cpp	2011-10-29 00:30:00 UTC (rev 98787)
@@ -35,24 +35,14 @@
 namespace WebCore {
 
 DOMURL::DOMURL(ScriptExecutionContext* scriptExecutionContext)
-    : m_scriptExecutionContext(scriptExecutionContext)
+    : ContextDestructionObserver(scriptExecutionContext)
 {
-    if (m_scriptExecutionContext)
-        m_scriptExecutionContext->createdDomUrl(this);
 }
 
 DOMURL::~DOMURL()
 {
-    if (m_scriptExecutionContext)
-        m_scriptExecutionContext->destroyedDomUrl(this);
 }
 
-void DOMURL::contextDestroyed()
-{
-    ASSERT(m_scriptExecutionContext);
-    m_scriptExecutionContext = 0;
-}
-
 #if ENABLE(MEDIA_STREAM)
 String DOMURL::createObjectURL(MediaStream* stream)
 {

Modified: trunk/Source/WebCore/html/DOMURL.h (98786 => 98787)


--- trunk/Source/WebCore/html/DOMURL.h	2011-10-29 00:10:11 UTC (rev 98786)
+++ trunk/Source/WebCore/html/DOMURL.h	2011-10-29 00:30:00 UTC (rev 98787)
@@ -28,6 +28,7 @@
 
 #if ENABLE(BLOB)
 
+#include "ActiveDOMObject.h"
 #include "PlatformString.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -38,7 +39,7 @@
 class MediaStream;
 class ScriptExecutionContext;
 
-class DOMURL : public RefCounted<DOMURL> {
+class DOMURL : public RefCounted<DOMURL>, public ContextDestructionObserver {
 public:
     static PassRefPtr<DOMURL> create(ScriptExecutionContext* scriptExecutionContext) { return adoptRef(new DOMURL(scriptExecutionContext)); }
     ~DOMURL();
@@ -49,13 +50,8 @@
     String createObjectURL(Blob*);
     void revokeObjectURL(const String&);
 
-    void contextDestroyed();
-    ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }
-
 private:
     explicit DOMURL(ScriptExecutionContext*);
-
-    ScriptExecutionContext* m_scriptExecutionContext;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to