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

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

Issue 23702040: Send synchronous loads through the cache. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments Created 7 years, 3 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 | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/fetch/ResourceLoaderOptions.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 6bea1e83725c21cee17c2196c799a96061c15a7b..b385bc72ab7bec4dfdd6087ac545886f1fc50cc9 100644
--- a/Source/core/fetch/ResourceLoader.cpp
+++ b/Source/core/fetch/ResourceLoader.cpp
@@ -63,7 +63,6 @@ PassRefPtr<ResourceLoader> ResourceLoader::create(ResourceLoaderHost* host, Reso
{
RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(host, resource, options)));
loader->init(request);
- loader->start();
return loader.release();
}
@@ -132,6 +131,11 @@ void ResourceLoader::start()
m_host->willStartLoadingResource(m_request);
+ if (m_options.synchronousPolicy == RequestSynchronously) {
+ requestSynchronously();
+ return;
+ }
+
if (m_defersLoading) {
m_deferredRequest = m_request;
return;
@@ -388,24 +392,30 @@ bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const
return m_host->isLoadedBy(loader);
}
-void ResourceLoader::loadResourceSynchronously(const ResourceRequest& request, StoredCredentials storedCredentials, ResourceError& error, ResourceResponse& response, Vector<char>& data)
+void ResourceLoader::requestSynchronously()
{
OwnPtr<WebKit::WebURLLoader> loader = adoptPtr(WebKit::Platform::current()->createURLLoader());
ASSERT(loader);
- WebKit::WrappedResourceRequest requestIn(request);
- requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredentials);
- WebKit::WrappedResourceResponse responseOut(response);
+ RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
+ m_connectionState = ConnectionStateStarted;
+
+ WebKit::WrappedResourceRequest requestIn(m_request);
+ requestIn.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredCredentials);
+ WebKit::WebURLResponse responseOut;
+ responseOut.initialize();
WebKit::WebURLError errorOut;
WebKit::WebData dataOut;
-
loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
-
- error = errorOut;
- data.clear();
- RefPtr<SharedBuffer> buffer = dataOut;
- if (buffer)
- buffer->moveTo(data);
+ if (errorOut.reason) {
+ didFail(0, errorOut);
+ return;
+ }
+ didReceiveResponse(0, responseOut);
+ RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse().resourceLoadInfo();
+ m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), resourceLoadInfo ? resourceLoadInfo->encodedDataLength : -1, m_options);
+ m_resource->setResourceBuffer(dataOut);
+ didFinishLoading(0, responseOut.responseTime());
}
}
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/fetch/ResourceLoaderOptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698