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

Unified Diff: third_party/WebKit/Source/web/AssociatedURLLoader.cpp

Issue 1937743002: Tidy up releasing of AssociatedURLLoader's client references. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/web/AssociatedURLLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/AssociatedURLLoader.cpp
diff --git a/third_party/WebKit/Source/web/AssociatedURLLoader.cpp b/third_party/WebKit/Source/web/AssociatedURLLoader.cpp
index b8e12ec2ff37b37f18b61b2e52a1ad4436f29172..8a4ae45120b2298c51227efec1f5310413ed63bd 100644
--- a/third_party/WebKit/Source/web/AssociatedURLLoader.cpp
+++ b/third_party/WebKit/Source/web/AssociatedURLLoader.cpp
@@ -142,7 +142,12 @@ public:
void enableErrorNotifications();
// Stops loading and releases the DocumentThreadableLoader as early as possible.
- void clearClient() { m_client = 0; }
+ WebURLLoaderClient* releaseClient()
+ {
+ WebURLLoaderClient* client = m_client;
+ m_client = nullptr;
+ return client;
+ }
private:
ClientAdapter(AssociatedURLLoader*, WebURLLoaderClient*, const WebURLLoaderOptions&);
@@ -250,9 +255,7 @@ void AssociatedURLLoader::ClientAdapter::didFinishLoading(unsigned long identifi
m_loader->clientAdapterDone();
- auto client = m_client;
- m_client = nullptr;
- client->didFinishLoading(m_loader, finishTime, WebURLLoaderClient::kUnknownEncodedDataLength);
+ releaseClient()->didFinishLoading(m_loader, finishTime, WebURLLoaderClient::kUnknownEncodedDataLength);
// |this| may be dead here.
}
@@ -290,9 +293,7 @@ void AssociatedURLLoader::ClientAdapter::notifyError(Timer<ClientAdapter>* timer
if (!m_client)
return;
- auto client = m_client;
- m_client = nullptr;
- client->didFail(m_loader, m_error);
+ releaseClient()->didFail(m_loader, m_error);
// |this| may be dead here.
}
@@ -412,13 +413,13 @@ void AssociatedURLLoader::cancel()
{
disposeObserver();
cancelLoader();
- m_client = nullptr;
+ releaseClient();
}
void AssociatedURLLoader::clientAdapterDone()
{
disposeObserver();
- m_client = nullptr;
+ releaseClient();
}
void AssociatedURLLoader::cancelLoader()
@@ -427,7 +428,7 @@ void AssociatedURLLoader::cancelLoader()
return;
// Prevent invocation of the WebURLLoaderClient methods.
- m_clientAdapter->clearClient();
+ m_clientAdapter->releaseClient();
if (m_loader) {
m_loader->cancel();
@@ -455,9 +456,7 @@ void AssociatedURLLoader::documentDestroyed()
if (!m_client)
return;
- WebURLLoaderClient* client = m_client;
- m_client = nullptr;
- client->didFail(this, ResourceError());
+ releaseClient()->didFail(this, ResourceError());
// |this| may be dead here.
}
« no previous file with comments | « third_party/WebKit/Source/web/AssociatedURLLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698