Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Unified Diff: third_party/WebKit/Source/core/dom/PendingScript.cpp

Issue 1667843003: Make Resource RefCountedWillBeGarbageCollectedFinalized, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + address review comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/PendingScript.cpp
diff --git a/third_party/WebKit/Source/core/dom/PendingScript.cpp b/third_party/WebKit/Source/core/dom/PendingScript.cpp
index 8b3ca3a15d83bc71a05b987ed471057cc4e28f1c..0c0fdc93b80588359404a5fc22d03f79ac5a1217 100644
--- a/third_party/WebKit/Source/core/dom/PendingScript.cpp
+++ b/third_party/WebKit/Source/core/dom/PendingScript.cpp
@@ -42,14 +42,26 @@ PendingScript::PendingScript(Element* element, ScriptResource* resource)
: m_watchingForLoad(false)
, m_element(element)
, m_integrityFailure(false)
+ , m_client(nullptr)
{
setScriptResource(resource);
+#if ENABLE(OILPAN)
+ ThreadState::current()->registerPreFinalizer(this);
+#endif
}
PendingScript::~PendingScript()
{
}
+void PendingScript::dispose()
+{
+ if (!m_client)
+ return;
+ stopWatchingForLoad();
+ releaseElementAndClear();
+}
+
PendingScript& PendingScript::operator=(const PendingScript& other)
{
if (this == &other)
@@ -67,32 +79,35 @@ PendingScript& PendingScript::operator=(const PendingScript& other)
void PendingScript::watchForLoad(ScriptResourceClient* client)
{
ASSERT(!m_watchingForLoad);
- // addClient() will call notifyFinished() if the load is complete. Callers
+ // addClient() will call streamingFinished() if the load is complete. Callers
// who do not expect to be re-entered from this call should not call
// watchForLoad for a PendingScript which isReady. We also need to set
// m_watchingForLoad early, since addClient() can result in calling
// notifyFinished and further stopWatchingForLoad().
m_watchingForLoad = true;
- if (m_streamer) {
- m_streamer->addClient(client);
- } else {
+ m_client = client;
+ if (!m_streamer)
resource()->addClient(client);
- }
}
-void PendingScript::stopWatchingForLoad(ScriptResourceClient* client)
+void PendingScript::stopWatchingForLoad()
{
if (!m_watchingForLoad)
return;
ASSERT(resource());
- if (m_streamer) {
- m_streamer->removeClient(client);
- } else {
- resource()->removeClient(client);
- }
+ if (!m_streamer)
+ resource()->removeClient(m_client);
+ m_client = nullptr;
m_watchingForLoad = false;
}
+void PendingScript::streamingFinished()
+{
+ ASSERT(resource());
+ if (m_client)
+ m_client->notifyFinished(resource());
+}
+
void PendingScript::setElement(Element* element)
{
m_element = element;
« no previous file with comments | « third_party/WebKit/Source/core/dom/PendingScript.h ('k') | third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698