Title: [164091] trunk/Source/WebCore
- Revision
- 164091
- Author
- [email protected]
- Date
- 2014-02-13 20:03:59 -0800 (Thu, 13 Feb 2014)
Log Message
[MSE] Move PublicURLManager shutdown logic so ActiveDOMObjects associated with public URLs won't leak.
https://bugs.webkit.org/show_bug.cgi?id=128532
Patch by Byungseon Shin <[email protected]> on 2014-02-13
Reviewed by Jer Noble.
This fixes a leak of DOM objects by breaking the circular reference
between Document, PublicURLManager, and MediaSource.
Instead of clearing PublicURLManager at destruction-time,
which is delayed indefinitely because of the circular reference,
clear the PublicURLManager during ActiveDOMObject::stop().
Frome Blink r151890 by <[email protected]>
<https://src.chromium.org/viewvc/blink?view=rev&revision=151890>
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
(WebCore::ScriptExecutionContext::publicURLManager):
* html/DOMURL.h:
* html/PublicURLManager.cpp:
(WebCore::PublicURLManager::create):
(WebCore::PublicURLManager::PublicURLManager):
(WebCore::PublicURLManager::registerURL):
(WebCore::PublicURLManager::stop):
* html/PublicURLManager.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (164090 => 164091)
--- trunk/Source/WebCore/ChangeLog 2014-02-14 03:35:13 UTC (rev 164090)
+++ trunk/Source/WebCore/ChangeLog 2014-02-14 04:03:59 UTC (rev 164091)
@@ -1,3 +1,30 @@
+2014-02-13 Byungseon Shin <[email protected]>
+
+ [MSE] Move PublicURLManager shutdown logic so ActiveDOMObjects associated with public URLs won't leak.
+ https://bugs.webkit.org/show_bug.cgi?id=128532
+
+ Reviewed by Jer Noble.
+
+ This fixes a leak of DOM objects by breaking the circular reference
+ between Document, PublicURLManager, and MediaSource.
+ Instead of clearing PublicURLManager at destruction-time,
+ which is delayed indefinitely because of the circular reference,
+ clear the PublicURLManager during ActiveDOMObject::stop().
+
+ Frome Blink r151890 by <[email protected]>
+ <https://src.chromium.org/viewvc/blink?view=rev&revision=151890>
+
+ * dom/ScriptExecutionContext.cpp:
+ (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
+ (WebCore::ScriptExecutionContext::publicURLManager):
+ * html/DOMURL.h:
+ * html/PublicURLManager.cpp:
+ (WebCore::PublicURLManager::create):
+ (WebCore::PublicURLManager::PublicURLManager):
+ (WebCore::PublicURLManager::registerURL):
+ (WebCore::PublicURLManager::stop):
+ * html/PublicURLManager.h:
+
2014-02-13 Myles C. Maxfield <[email protected]>
Remove position:sticky runtime flag
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (164090 => 164091)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2014-02-14 03:35:13 UTC (rev 164090)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2014-02-14 04:03:59 UTC (rev 164091)
@@ -117,10 +117,6 @@
ASSERT((*iter)->scriptExecutionContext() == this);
(*iter)->contextDestroyed();
}
-#if ENABLE(BLOB)
- if (m_publicURLManager)
- m_publicURLManager->contextDestroyed();
-#endif
}
void ScriptExecutionContext::processMessagePortMessagesSoon()
@@ -367,7 +363,7 @@
PublicURLManager& ScriptExecutionContext::publicURLManager()
{
if (!m_publicURLManager)
- m_publicURLManager = PublicURLManager::create();
+ m_publicURLManager = PublicURLManager::create(this);
return *m_publicURLManager;
}
#endif
Modified: trunk/Source/WebCore/html/DOMURL.h (164090 => 164091)
--- trunk/Source/WebCore/html/DOMURL.h 2014-02-14 03:35:13 UTC (rev 164090)
+++ trunk/Source/WebCore/html/DOMURL.h 2014-02-14 04:03:59 UTC (rev 164091)
@@ -53,8 +53,6 @@
void setHref(const String&, ExceptionCode&);
#if ENABLE(BLOB)
- static void contextDestroyed(ScriptExecutionContext*);
-
static String createObjectURL(ScriptExecutionContext*, Blob*);
static void revokeObjectURL(ScriptExecutionContext*, const String&);
Modified: trunk/Source/WebCore/html/PublicURLManager.cpp (164090 => 164091)
--- trunk/Source/WebCore/html/PublicURLManager.cpp 2014-02-14 03:35:13 UTC (rev 164090)
+++ trunk/Source/WebCore/html/PublicURLManager.cpp 2014-02-14 04:03:59 UTC (rev 164091)
@@ -35,8 +35,24 @@
namespace WebCore {
+PassOwnPtr<PublicURLManager> PublicURLManager::create(ScriptExecutionContext* context)
+{
+ OwnPtr<PublicURLManager> publicURLManager(adoptPtr(new PublicURLManager(context)));
+ publicURLManager->suspendIfNeeded();
+ return publicURLManager.release();
+}
+
+PublicURLManager::PublicURLManager(ScriptExecutionContext* context)
+ : ActiveDOMObject(context)
+ , m_isStopped(false)
+{
+}
+
void PublicURLManager::registerURL(SecurityOrigin* origin, const URL& url, URLRegistrable* registrable)
{
+ if (m_isStopped)
+ return;
+
RegistryURLMap::iterator found = m_registryToURL.add(®istrable->registry(), URLSet()).iterator;
found->key->registerURL(origin, url, registrable);
found->value.add(url.string());
@@ -53,8 +69,12 @@
}
}
-void PublicURLManager::contextDestroyed()
+void PublicURLManager::stop()
{
+ if (m_isStopped)
+ return;
+
+ m_isStopped = true;
for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryToURL.end(); ++i) {
for (URLSet::iterator j = i->value.begin(); j != i->value.end(); ++j)
i->key->unregisterURL(URL(ParsedURLString, *j));
Modified: trunk/Source/WebCore/html/PublicURLManager.h (164090 => 164091)
--- trunk/Source/WebCore/html/PublicURLManager.h 2014-02-14 03:35:13 UTC (rev 164090)
+++ trunk/Source/WebCore/html/PublicURLManager.h 2014-02-14 04:03:59 UTC (rev 164091)
@@ -27,6 +27,7 @@
#define PublicURLManager_h
#if ENABLE(BLOB)
+#include "ActiveDOMObject.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/PassOwnPtr.h>
@@ -41,19 +42,23 @@
class URLRegistry;
class URLRegistrable;
-class PublicURLManager {
+class PublicURLManager : public ActiveDOMObject {
WTF_MAKE_FAST_ALLOCATED;
public:
- static OwnPtr<PublicURLManager> create() { return adoptPtr(new PublicURLManager); }
+ static PassOwnPtr<PublicURLManager> create(ScriptExecutionContext*);
void registerURL(SecurityOrigin*, const URL&, URLRegistrable*);
void revoke(const URL&);
- void contextDestroyed();
+ // ActiveDOMObject interface.
+ virtual void stop() override;
private:
+ PublicURLManager(ScriptExecutionContext*);
+
typedef HashSet<String> URLSet;
typedef HashMap<URLRegistry*, URLSet > RegistryURLMap;
RegistryURLMap m_registryToURL;
+ bool m_isStopped;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes