From e82298dad5b93e668a6dae26da91a7d2f942d0bb Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Mon, 24 Oct 2011 12:42:19 +0100 Subject: Report a load error when network loads blocked. When network loads are blocked, we should fail those loads rather than leaving them dangling. In particular, this fixes an issue where WebCore will wait to do the first layout while CSS loads are pending. If network loads are blocked, we need to tell WebCore they are never going to complete. To implement this, we make use of the Chromium stack's load flags and move the code to a more suitable location. Bug: 5416543 Change-Id: I0bd41e430c7ab3cefa302ed0e0576c7e74e7274a --- .../android/WebCoreSupport/WebResourceRequest.cpp | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'Source/WebKit/android/WebCoreSupport/WebResourceRequest.cpp') diff --git a/Source/WebKit/android/WebCoreSupport/WebResourceRequest.cpp b/Source/WebKit/android/WebCoreSupport/WebResourceRequest.cpp index 2ede1ca..663ded8 100644 --- a/Source/WebKit/android/WebCoreSupport/WebResourceRequest.cpp +++ b/Source/WebKit/android/WebCoreSupport/WebResourceRequest.cpp @@ -34,22 +34,33 @@ using namespace WebCore; namespace android { -WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceRequest) +WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceRequest, bool shouldBlockNetworkLoads) { // Set the load flags based on the WebCore request. m_loadFlags = net::LOAD_NORMAL; - switch (resourceRequest.cachePolicy()) { - case ReloadIgnoringCacheData: - m_loadFlags |= net::LOAD_VALIDATE_CACHE; - break; - case ReturnCacheDataElseLoad: - m_loadFlags |= net::LOAD_PREFERRING_CACHE; - break; - case ReturnCacheDataDontLoad: + + if (shouldBlockNetworkLoads) { + // In the case that the embedder has blocked network loads, we only + // ever try to serve content out of the cache. If WebCore has set + // ReloadIgnoringCacheData, we would normally attempt to validate + // the cached data before serving it. In the absence of network + // we can't do that, so we will just return whatever we have in the + // cache (which may well be nothing). m_loadFlags |= net::LOAD_ONLY_FROM_CACHE; - break; - case UseProtocolCachePolicy: - break; + } else { + switch (resourceRequest.cachePolicy()) { + case ReloadIgnoringCacheData: + m_loadFlags |= net::LOAD_VALIDATE_CACHE; + break; + case ReturnCacheDataElseLoad: + m_loadFlags |= net::LOAD_PREFERRING_CACHE; + break; + case ReturnCacheDataDontLoad: + m_loadFlags |= net::LOAD_ONLY_FROM_CACHE; + break; + case UseProtocolCachePolicy: + break; + } } // TODO: We should consider setting these flags and net::LOAD_DO_NOT_SEND_AUTH_DATA -- cgit v1.1