diff options
author | eustas <eustas@chromium.org> | 2014-11-27 02:48:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-27 10:48:16 +0000 |
commit | 2787684d5e8f07481cf42c95fb3986bd73daad57 (patch) | |
tree | fde1ec9d9157d796011031e3d5ddc618654b9f65 | |
parent | ada8f5dae0fd99ef5a74fecdff1b91dacd7183b3 (diff) | |
download | chromium_src-2787684d5e8f07481cf42c95fb3986bd73daad57.zip chromium_src-2787684d5e8f07481cf42c95fb3986bd73daad57.tar.gz chromium_src-2787684d5e8f07481cf42c95fb3986bd73daad57.tar.bz2 |
Support "shouldResetAppCache" request parameter.
This patch pulls parameter value to AppCacheRequestHandler.
When parameter value is true - cache corresponding to manifest_url is resetted.
shouldResetAppCache parameter is set by DevTools when "Disable Cache" mode is on, to ensure that pages are reloaded from network.
Blink patch: https://codereview.chromium.org/723113002
BUG=256672
Review URL: https://codereview.chromium.org/669133002
Cr-Commit-Position: refs/heads/master@{#305973}
-rw-r--r-- | content/browser/appcache/appcache_host.cc | 12 | ||||
-rw-r--r-- | content/browser/appcache/appcache_host.h | 3 | ||||
-rw-r--r-- | content/browser/appcache/appcache_interceptor.cc | 5 | ||||
-rw-r--r-- | content/browser/appcache/appcache_interceptor.h | 3 | ||||
-rw-r--r-- | content/browser/appcache/appcache_request_handler.cc | 11 | ||||
-rw-r--r-- | content/browser/appcache/appcache_request_handler.h | 6 | ||||
-rw-r--r-- | content/browser/appcache/appcache_request_handler_unittest.cc | 52 | ||||
-rw-r--r-- | content/browser/appcache/appcache_storage_impl_unittest.cc | 3 | ||||
-rw-r--r-- | content/browser/loader/resource_dispatcher_host_impl.cc | 3 | ||||
-rw-r--r-- | content/browser/loader/resource_dispatcher_host_unittest.cc | 1 | ||||
-rw-r--r-- | content/child/request_info.h | 3 | ||||
-rw-r--r-- | content/child/resource_dispatcher.cc | 1 | ||||
-rw-r--r-- | content/child/resource_dispatcher_unittest.cc | 1 | ||||
-rw-r--r-- | content/child/web_url_loader_impl.cc | 2 | ||||
-rw-r--r-- | content/common/resource_messages.h | 3 |
15 files changed, 79 insertions, 30 deletions
diff --git a/content/browser/appcache/appcache_host.cc b/content/browser/appcache/appcache_host.cc index 52213a3..4ec19ff 100644 --- a/content/browser/appcache/appcache_host.cc +++ b/content/browser/appcache/appcache_host.cc @@ -291,11 +291,13 @@ AppCacheHost* AppCacheHost::GetParentAppCacheHost() const { AppCacheRequestHandler* AppCacheHost::CreateRequestHandler( net::URLRequest* request, - ResourceType resource_type) { + ResourceType resource_type, + bool should_reset_appcache) { if (is_for_dedicated_worker()) { AppCacheHost* parent_host = GetParentAppCacheHost(); if (parent_host) - return parent_host->CreateRequestHandler(request, resource_type); + return parent_host->CreateRequestHandler( + request, resource_type, should_reset_appcache); return NULL; } @@ -303,12 +305,14 @@ AppCacheRequestHandler* AppCacheHost::CreateRequestHandler( // Store the first party origin so that it can be used later in SelectCache // for checking whether the creation of the appcache is allowed. first_party_url_ = request->first_party_for_cookies(); - return new AppCacheRequestHandler(this, resource_type); + return new AppCacheRequestHandler( + this, resource_type, should_reset_appcache); } if ((associated_cache() && associated_cache()->is_complete()) || is_selection_pending()) { - return new AppCacheRequestHandler(this, resource_type); + return new AppCacheRequestHandler( + this, resource_type, should_reset_appcache); } return NULL; } diff --git a/content/browser/appcache/appcache_host.h b/content/browser/appcache/appcache_host.h index 9f014fb..7525ea2 100644 --- a/content/browser/appcache/appcache_host.h +++ b/content/browser/appcache/appcache_host.h @@ -111,7 +111,8 @@ class CONTENT_EXPORT AppCacheHost // May return NULL if the request isn't subject to retrieval from an appache. AppCacheRequestHandler* CreateRequestHandler( net::URLRequest* request, - ResourceType resource_type); + ResourceType resource_type, + bool should_reset_appcache); // Support for devtools inspecting appcache resources. void GetResourceList(std::vector<AppCacheResourceInfo>* resource_infos); diff --git a/content/browser/appcache/appcache_interceptor.cc b/content/browser/appcache/appcache_interceptor.cc index e0b5513..6cb66df 100644 --- a/content/browser/appcache/appcache_interceptor.cc +++ b/content/browser/appcache/appcache_interceptor.cc @@ -32,7 +32,8 @@ void AppCacheInterceptor::SetExtraRequestInfo( AppCacheServiceImpl* service, int process_id, int host_id, - ResourceType resource_type) { + ResourceType resource_type, + bool should_reset_appcache) { if (!service || (host_id == kAppCacheNoHostId)) return; @@ -48,7 +49,7 @@ void AppCacheInterceptor::SetExtraRequestInfo( // Create a handler for this request and associate it with the request. AppCacheRequestHandler* handler = - host->CreateRequestHandler(request, resource_type); + host->CreateRequestHandler(request, resource_type, should_reset_appcache); if (handler) SetHandler(request, handler); } diff --git a/content/browser/appcache/appcache_interceptor.h b/content/browser/appcache/appcache_interceptor.h index 09fa576..50ba944 100644 --- a/content/browser/appcache/appcache_interceptor.h +++ b/content/browser/appcache/appcache_interceptor.h @@ -29,7 +29,8 @@ class CONTENT_EXPORT AppCacheInterceptor : public net::URLRequestInterceptor { AppCacheServiceImpl* service, int process_id, int host_id, - ResourceType resource_type); + ResourceType resource_type, + bool should_reset_appcache); // May be called after response headers are complete to retrieve extra // info about the response. diff --git a/content/browser/appcache/appcache_request_handler.cc b/content/browser/appcache/appcache_request_handler.cc index a21337c..46344ae 100644 --- a/content/browser/appcache/appcache_request_handler.cc +++ b/content/browser/appcache/appcache_request_handler.cc @@ -15,9 +15,11 @@ namespace content { AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host, - ResourceType resource_type) + ResourceType resource_type, + bool should_reset_appcache) : host_(host), resource_type_(resource_type), + should_reset_appcache_(should_reset_appcache), is_waiting_for_cache_selection_(false), found_group_id_(0), found_cache_id_(0), @@ -292,6 +294,13 @@ void AppCacheRequestHandler::OnMainResponseFound( return; } + if (should_reset_appcache_ && !manifest_url.is_empty()) { + host_->service()->DeleteAppCacheGroup( + manifest_url, net::CompletionCallback()); + DeliverNetworkResponse(); + return; + } + if (IsResourceTypeFrame(resource_type_) && cache_id != kAppCacheNoCacheId) { // AppCacheHost loads and holds a reference to the main resource cache // for two reasons, firstly to preload the cache into the working set diff --git a/content/browser/appcache/appcache_request_handler.h b/content/browser/appcache/appcache_request_handler.h index cf0297b..9c90b29 100644 --- a/content/browser/appcache/appcache_request_handler.h +++ b/content/browser/appcache/appcache_request_handler.h @@ -59,7 +59,8 @@ class CONTENT_EXPORT AppCacheRequestHandler friend class AppCacheHost; // Callers should use AppCacheHost::CreateRequestHandler. - AppCacheRequestHandler(AppCacheHost* host, ResourceType resource_type); + AppCacheRequestHandler(AppCacheHost* host, ResourceType resource_type, + bool should_reset_appcache); // AppCacheHost::Observer override void OnDestructionImminent(AppCacheHost* host) override; @@ -113,6 +114,9 @@ class CONTENT_EXPORT AppCacheRequestHandler // Frame vs subresource vs sharedworker loads are somewhat different. ResourceType resource_type_; + // True if corresponding AppCache group should be resetted before load. + bool should_reset_appcache_; + // Subresource requests wait until after cache selection completes. bool is_waiting_for_cache_selection_; diff --git a/content/browser/appcache/appcache_request_handler_unittest.cc b/content/browser/appcache/appcache_request_handler_unittest.cc index 9543f7e..ef02bcd 100644 --- a/content/browser/appcache/appcache_request_handler_unittest.cc +++ b/content/browser/appcache/appcache_request_handler_unittest.cc @@ -256,7 +256,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_MAIN_FRAME)); + RESOURCE_TYPE_MAIN_FRAME, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), @@ -304,7 +305,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_MAIN_FRAME)); + RESOURCE_TYPE_MAIN_FRAME, + false)); EXPECT_TRUE(handler_.get()); mock_storage()->SimulateFindMainResource( @@ -353,7 +355,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_MAIN_FRAME)); + RESOURCE_TYPE_MAIN_FRAME, + false)); EXPECT_TRUE(handler_.get()); mock_storage()->SimulateFindMainResource( @@ -435,7 +438,8 @@ class AppCacheRequestHandlerTest : public testing::Test { GURL("http://blah/fallback-override"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_MAIN_FRAME)); + RESOURCE_TYPE_MAIN_FRAME, + false)); EXPECT_TRUE(handler_.get()); mock_storage()->SimulateFindMainResource( @@ -488,7 +492,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); // We avoid creating handler when possible, sub-resource requests are not // subject to retrieval from an appcache when there's no associated cache. @@ -507,7 +512,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), @@ -539,7 +545,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), request_->context()->network_delegate()); @@ -574,7 +581,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), request_->context()->network_delegate()); @@ -607,7 +615,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), request_->context()->network_delegate()); @@ -641,7 +650,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), request_->context()->network_delegate()); @@ -676,7 +686,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), request_->context()->network_delegate()); @@ -706,7 +717,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); backend_impl_->UnregisterHost(1); @@ -733,7 +745,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), @@ -766,7 +779,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("ftp://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_SUB_RESOURCE)); + RESOURCE_TYPE_SUB_RESOURCE, + false)); EXPECT_TRUE(handler_.get()); // we could redirect to http (conceivably) EXPECT_FALSE(handler_->MaybeLoadResource( @@ -787,7 +801,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_MAIN_FRAME)); + RESOURCE_TYPE_MAIN_FRAME, + false)); EXPECT_TRUE(handler_.get()); job_ = handler_->MaybeLoadResource(request_.get(), @@ -833,7 +848,7 @@ class AppCacheRequestHandlerTest : public testing::Test { AppCacheHost* worker_host = backend_impl_->GetHost(kWorkerHostId); worker_host->SelectCacheForWorker(kParentHostId, kMockProcessId); handler_.reset(worker_host->CreateRequestHandler( - request_.get(), RESOURCE_TYPE_SHARED_WORKER)); + request_.get(), RESOURCE_TYPE_SHARED_WORKER, false)); EXPECT_TRUE(handler_.get()); // Verify that the handler is associated with the parent host. EXPECT_EQ(host_, handler_->host_); @@ -846,7 +861,7 @@ class AppCacheRequestHandlerTest : public testing::Test { EXPECT_EQ(NULL, backend_impl_->GetHost(kNonExsitingHostId)); worker_host->SelectCacheForWorker(kNonExsitingHostId, kMockProcessId); handler_.reset(worker_host->CreateRequestHandler( - request_.get(), RESOURCE_TYPE_SHARED_WORKER)); + request_.get(), RESOURCE_TYPE_SHARED_WORKER, false)); EXPECT_FALSE(handler_.get()); TestFinished(); @@ -862,7 +877,8 @@ class AppCacheRequestHandlerTest : public testing::Test { request_ = empty_context_.CreateRequest( GURL("http://blah/"), net::DEFAULT_PRIORITY, &delegate_, NULL); handler_.reset(host_->CreateRequestHandler(request_.get(), - RESOURCE_TYPE_MAIN_FRAME)); + RESOURCE_TYPE_MAIN_FRAME, + false)); EXPECT_TRUE(handler_.get()); mock_policy_->can_load_return_value_ = false; diff --git a/content/browser/appcache/appcache_storage_impl_unittest.cc b/content/browser/appcache/appcache_storage_impl_unittest.cc index a531bae..cf779bb 100644 --- a/content/browser/appcache/appcache_storage_impl_unittest.cc +++ b/content/browser/appcache/appcache_storage_impl_unittest.cc @@ -1775,7 +1775,8 @@ class AppCacheStorageImplTest : public testing::Test { AppCacheInterceptor::SetExtraRequestInfo( request_.get(), service_.get(), backend_->process_id(), host2->host_id(), - RESOURCE_TYPE_MAIN_FRAME); + RESOURCE_TYPE_MAIN_FRAME, + false); request_->Start(); } diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc index a44d153..38b28ac 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/content/browser/loader/resource_dispatcher_host_impl.cc @@ -1269,7 +1269,8 @@ void ResourceDispatcherHostImpl::BeginRequest( // Have the appcache associate its extra info with the request. AppCacheInterceptor::SetExtraRequestInfo( new_request.get(), filter_->appcache_service(), child_id, - request_data.appcache_host_id, request_data.resource_type); + request_data.appcache_host_id, request_data.resource_type, + request_data.should_reset_appcache); scoped_ptr<ResourceHandler> handler( CreateResourceHandler( diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc index 3017086..0e1c63d 100644 --- a/content/browser/loader/resource_dispatcher_host_unittest.cc +++ b/content/browser/loader/resource_dispatcher_host_unittest.cc @@ -139,6 +139,7 @@ static ResourceHostMsg_Request CreateResourceRequest(const char* method, request.request_context = 0; request.appcache_host_id = kAppCacheNoHostId; request.download_to_file = false; + request.should_reset_appcache = false; request.is_main_frame = true; request.parent_is_main_frame = false; request.parent_render_frame_id = -1; diff --git a/content/child/request_info.h b/content/child/request_info.h index e66a26b..b26e874 100644 --- a/content/child/request_info.h +++ b/content/child/request_info.h @@ -80,6 +80,9 @@ struct CONTENT_EXPORT RequestInfo { // True if the request should not be handled by the ServiceWorker. bool skip_service_worker; + // True if corresponding AppCache group should be resetted. + bool should_reset_appcache; + // The request mode passed to the ServiceWorker. FetchRequestMode fetch_request_mode; diff --git a/content/child/resource_dispatcher.cc b/content/child/resource_dispatcher.cc index 7590b23..316c609 100644 --- a/content/child/resource_dispatcher.cc +++ b/content/child/resource_dispatcher.cc @@ -128,6 +128,7 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge( request_.download_to_file = request_info.download_to_file; request_.has_user_gesture = request_info.has_user_gesture; request_.skip_service_worker = request_info.skip_service_worker; + request_.should_reset_appcache = request_info.should_reset_appcache; request_.fetch_request_mode = request_info.fetch_request_mode; request_.fetch_credentials_mode = request_info.fetch_credentials_mode; request_.fetch_request_context_type = request_info.fetch_request_context_type; diff --git a/content/child/resource_dispatcher_unittest.cc b/content/child/resource_dispatcher_unittest.cc index f0201c8..16756ec 100644 --- a/content/child/resource_dispatcher_unittest.cc +++ b/content/child/resource_dispatcher_unittest.cc @@ -328,6 +328,7 @@ class ResourceDispatcherTest : public testing::Test, public IPC::Sender { request_info.requestor_pid = 0; request_info.request_type = RESOURCE_TYPE_SUB_RESOURCE; request_info.appcache_host_id = kAppCacheNoHostId; + request_info.should_reset_appcache = false; request_info.routing_id = 0; request_info.download_to_file = download_to_file; RequestExtraData extra_data; diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc index 00fc99a..0ed7d5b 100644 --- a/content/child/web_url_loader_impl.cc +++ b/content/child/web_url_loader_impl.cc @@ -485,6 +485,7 @@ void WebURLLoaderImpl::Context::Start(const WebURLRequest& request, request_info.download_to_file = request.downloadToFile(); request_info.has_user_gesture = request.hasUserGesture(); request_info.skip_service_worker = request.skipServiceWorker(); + request_info.should_reset_appcache = request.shouldResetAppCache(); request_info.fetch_request_mode = GetFetchRequestMode(request); request_info.fetch_credentials_mode = GetFetchCredentialsMode(request); request_info.fetch_request_context_type = GetRequestContextType(request); @@ -579,6 +580,7 @@ bool WebURLLoaderImpl::Context::OnReceivedRedirect( new_request.setRequestContext(request_.requestContext()); new_request.setFrameType(request_.frameType()); new_request.setSkipServiceWorker(request_.skipServiceWorker()); + new_request.setShouldResetAppCache(request_.shouldResetAppCache()); new_request.setFetchRequestMode(request_.fetchRequestMode()); new_request.setFetchCredentialsMode(request_.fetchCredentialsMode()); diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index e35a88e..3abea07 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h @@ -194,6 +194,9 @@ IPC_STRUCT_BEGIN(ResourceHostMsg_Request) // or kAppCacheNoHostId. IPC_STRUCT_MEMBER(int, appcache_host_id) + // True if corresponding AppCache group should be resetted. + IPC_STRUCT_MEMBER(bool, should_reset_appcache) + // Indicates which frame (or worker context) the request is being loaded into, // or kInvalidServiceWorkerProviderId. IPC_STRUCT_MEMBER(int, service_worker_provider_id) |