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

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: 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
Index: Source/core/fetch/ResourceLoader.cpp
diff --git a/Source/core/fetch/ResourceLoader.cpp b/Source/core/fetch/ResourceLoader.cpp
index 6bea1e83725c21cee17c2196c799a96061c15a7b..420aa3f2c8f575c77208b0301090ca2a6fb91626 100644
--- a/Source/core/fetch/ResourceLoader.cpp
+++ b/Source/core/fetch/ResourceLoader.cpp
@@ -44,6 +44,7 @@
#include "public/platform/WebURLRequest.h"
#include "public/platform/WebURLResponse.h"
#include "wtf/Assertions.h"
+#include "wtf/CurrentTime.h"
abarth-chromium 2013/09/13 23:48:28 Is this still needed?
namespace WebCore {
@@ -63,7 +64,6 @@ PassRefPtr<ResourceLoader> ResourceLoader::create(ResourceLoaderHost* host, Reso
{
RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(host, resource, options)));
loader->init(request);
- loader->start();
Nate Chapin 2013/09/12 23:28:46 This is moved to Resource.cpp so that Resource::m_
return loader.release();
}
@@ -132,6 +132,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 +393,29 @@ 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();
+ didReceiveData(0, dataOut.data(), dataOut.size(), resourceLoadInfo ? resourceLoadInfo->encodedDataLength : -1);
abarth-chromium 2013/09/13 23:48:28 Does this introduce a memcpy? Previously, we were
Nate Chapin 2013/09/16 20:32:50 Yeah, I think it will memcpy. I guess we could exp
+ didFinishLoading(0, monotonicallyIncreasingTime());
}
}

Powered by Google App Engine
This is Rietveld 408576698