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

Unified Diff: Source/core/fetch/ResourceLoader.cpp

Issue 695943002: Reland "Prepare blink to unify definitions of load completion" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/fetch/ResourceLoaderHost.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ResourceLoader.cpp
diff --git a/Source/core/fetch/ResourceLoader.cpp b/Source/core/fetch/ResourceLoader.cpp
index 9cf69a6f9982d80cc68c56cb436d03214298dee6..36af6b1591b2afdb1af4d90ab842155475cd476a 100644
--- a/Source/core/fetch/ResourceLoader.cpp
+++ b/Source/core/fetch/ResourceLoader.cpp
@@ -102,8 +102,8 @@ void ResourceLoader::releaseResources()
{
ASSERT(m_state != Terminated);
ASSERT(m_notifiedLoadComplete);
- m_requestCountTracker.clear();
- m_host->didLoadResource(m_resource);
+ ASSERT(!m_requestCountTracker);
+ m_host->didLoadResource();
if (m_state == Terminated)
return;
m_resource->clearLoader();
@@ -233,7 +233,7 @@ void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64_t encodedD
if (m_notifiedLoadComplete)
return;
- m_notifiedLoadComplete = true;
+ didComplete();
m_host->didFinishLoading(m_resource, finishTime, encodedDataLength);
}
@@ -286,7 +286,7 @@ void ResourceLoader::cancel(const ResourceError& error)
}
if (!m_notifiedLoadComplete) {
- m_notifiedLoadComplete = true;
+ didComplete();
m_host->didFailLoading(m_resource, nonNullError);
}
@@ -423,7 +423,7 @@ void ResourceLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebUR
m_state = Finishing;
if (!m_notifiedLoadComplete) {
- m_notifiedLoadComplete = true;
+ didComplete();
m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_request.url()));
}
@@ -470,10 +470,11 @@ void ResourceLoader::didFinishLoading(blink::WebURLLoader*, double finishTime, i
RefPtrWillBeRawPtr<ResourceLoader> protect(this);
ResourcePtr<Resource> protectResource(m_resource);
m_state = Finishing;
+ m_resource->setLoadFinishTime(finishTime);
didFinishLoadingOnePart(finishTime, encodedDataLength);
if (m_state == Terminated)
return;
- m_resource->finish(finishTime);
+ m_resource->finish();
// If the load has been cancelled by a delegate in response to didFinishLoad(), do not release
// the resources a second time, they have been released by cancel.
@@ -495,7 +496,7 @@ void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err
m_resource->setResourceError(error);
if (!m_notifiedLoadComplete) {
- m_notifiedLoadComplete = true;
+ didComplete();
m_host->didFailLoading(m_resource, error);
}
if (m_state == Terminated)
@@ -549,6 +550,12 @@ void ResourceLoader::requestSynchronously()
didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
}
+void ResourceLoader::didComplete()
+{
+ m_notifiedLoadComplete = true;
+ m_requestCountTracker.clear();
+}
+
ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const
{
request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredCredentials);
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/fetch/ResourceLoaderHost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698