OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/appcache/appcache_request_handler.h" | 5 #include "content/browser/appcache/appcache_request_handler.h" |
6 | 6 |
7 #include "content/browser/appcache/appcache.h" | 7 #include "content/browser/appcache/appcache.h" |
8 #include "content/browser/appcache/appcache_backend_impl.h" | 8 #include "content/browser/appcache/appcache_backend_impl.h" |
9 #include "content/browser/appcache/appcache_policy.h" | 9 #include "content/browser/appcache/appcache_policy.h" |
10 #include "content/browser/appcache/appcache_url_request_job.h" | 10 #include "content/browser/appcache/appcache_url_request_job.h" |
11 #include "content/browser/service_worker/service_worker_request_handler.h" | |
11 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
12 #include "net/url_request/url_request_job.h" | 13 #include "net/url_request/url_request_job.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host, | 17 AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host, |
17 ResourceType resource_type) | 18 ResourceType resource_type) |
18 : host_(host), | 19 : host_(host), |
19 resource_type_(resource_type), | 20 resource_type_(resource_type), |
20 is_waiting_for_cache_selection_(false), | 21 is_waiting_for_cache_selection_(false), |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 job_->DeliverNetworkResponse(); | 232 job_->DeliverNetworkResponse(); |
232 } | 233 } |
233 | 234 |
234 // Main-resource handling ---------------------------------------------- | 235 // Main-resource handling ---------------------------------------------- |
235 | 236 |
236 void AppCacheRequestHandler::MaybeLoadMainResource( | 237 void AppCacheRequestHandler::MaybeLoadMainResource( |
237 net::URLRequest* request, net::NetworkDelegate* network_delegate) { | 238 net::URLRequest* request, net::NetworkDelegate* network_delegate) { |
238 DCHECK(!job_.get()); | 239 DCHECK(!job_.get()); |
239 DCHECK(host_); | 240 DCHECK(host_); |
240 | 241 |
242 // If a page falls into the scope of a ServiceWorker, any matching AppCaches | |
243 // should be ignored. This depends on the ServiceWorker handler being invoked | |
244 // prior to the AppCache handler. | |
michaeln
2014/10/03 01:09:46
bah... the ordering is wrong, appcache gets called
| |
245 if (ServiceWorkerRequestHandler::IsControlledByServiceWorker(request)) { | |
246 host_->enable_cache_selection(false); | |
247 return; | |
248 } | |
249 | |
250 host_->enable_cache_selection(true); | |
251 | |
241 const AppCacheHost* spawning_host = | 252 const AppCacheHost* spawning_host = |
242 (resource_type_ == RESOURCE_TYPE_SHARED_WORKER) ? | 253 (resource_type_ == RESOURCE_TYPE_SHARED_WORKER) ? |
243 host_ : host_->GetSpawningHost(); | 254 host_ : host_->GetSpawningHost(); |
244 GURL preferred_manifest_url = spawning_host ? | 255 GURL preferred_manifest_url = spawning_host ? |
245 spawning_host->preferred_manifest_url() : GURL(); | 256 spawning_host->preferred_manifest_url() : GURL(); |
246 | 257 |
247 // We may have to wait for our storage query to complete, but | 258 // We may have to wait for our storage query to complete, but |
248 // this query can also complete syncrhonously. | 259 // this query can also complete syncrhonously. |
249 job_ = new AppCacheURLRequestJob(request, network_delegate, | 260 job_ = new AppCacheURLRequestJob(request, network_delegate, |
250 storage(), host_, is_main_resource()); | 261 storage(), host_, is_main_resource()); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 if (!host_->associated_cache() || | 408 if (!host_->associated_cache() || |
398 !host_->associated_cache()->is_complete()) { | 409 !host_->associated_cache()->is_complete()) { |
399 DeliverNetworkResponse(); | 410 DeliverNetworkResponse(); |
400 return; | 411 return; |
401 } | 412 } |
402 | 413 |
403 ContinueMaybeLoadSubResource(); | 414 ContinueMaybeLoadSubResource(); |
404 } | 415 } |
405 | 416 |
406 } // namespace content | 417 } // namespace content |
OLD | NEW |