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

Side by Side Diff: content/browser/service_worker/service_worker_controllee_request_handler.cc

Issue 588153002: [ServiceWorker] Plumbing the request mode from the renderer to the ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service_worker/service_worker_controllee_request_handl er.h" 5 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "content/browser/service_worker/service_worker_context_core.h" 8 #include "content/browser/service_worker/service_worker_context_core.h"
9 #include "content/browser/service_worker/service_worker_metrics.h" 9 #include "content/browser/service_worker/service_worker_metrics.h"
10 #include "content/browser/service_worker/service_worker_provider_host.h" 10 #include "content/browser/service_worker/service_worker_provider_host.h"
11 #include "content/browser/service_worker/service_worker_registration.h" 11 #include "content/browser/service_worker/service_worker_registration.h"
12 #include "content/browser/service_worker/service_worker_url_request_job.h" 12 #include "content/browser/service_worker/service_worker_url_request_job.h"
13 #include "content/browser/service_worker/service_worker_utils.h" 13 #include "content/browser/service_worker/service_worker_utils.h"
14 #include "content/common/resource_request_body.h" 14 #include "content/common/resource_request_body.h"
15 #include "content/common/service_worker/service_worker_types.h" 15 #include "content/common/service_worker/service_worker_types.h"
16 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
17 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
18 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler( 22 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler(
23 base::WeakPtr<ServiceWorkerContextCore> context, 23 base::WeakPtr<ServiceWorkerContextCore> context,
24 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 24 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
25 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 25 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
26 FetchRequestMode request_mode,
26 ResourceType resource_type, 27 ResourceType resource_type,
27 scoped_refptr<ResourceRequestBody> body) 28 scoped_refptr<ResourceRequestBody> body)
28 : ServiceWorkerRequestHandler(context, 29 : ServiceWorkerRequestHandler(context,
29 provider_host, 30 provider_host,
30 blob_storage_context, 31 blob_storage_context,
31 resource_type), 32 resource_type),
32 is_main_resource_load_( 33 is_main_resource_load_(
33 ServiceWorkerUtils::IsMainResourceType(resource_type)), 34 ServiceWorkerUtils::IsMainResourceType(resource_type)),
35 request_mode_(request_mode),
34 body_(body), 36 body_(body),
35 weak_factory_(this) { 37 weak_factory_(this) {
36 } 38 }
37 39
38 ServiceWorkerControlleeRequestHandler:: 40 ServiceWorkerControlleeRequestHandler::
39 ~ServiceWorkerControlleeRequestHandler() { 41 ~ServiceWorkerControlleeRequestHandler() {
40 // Navigation triggers an update to occur shortly after the page and 42 // Navigation triggers an update to occur shortly after the page and
41 // its initial subresources load. 43 // its initial subresources load.
42 if (provider_host_ && provider_host_->active_version()) { 44 if (provider_host_ && provider_host_->active_version()) {
43 if (is_main_resource_load_) 45 if (is_main_resource_load_)
(...skipping 25 matching lines...) Expand all
69 // We've come here by restart, we already have original request and it 71 // We've come here by restart, we already have original request and it
70 // tells we should fallback to network. (Case B-c) 72 // tells we should fallback to network. (Case B-c)
71 if (job_.get() && job_->ShouldFallbackToNetwork()) { 73 if (job_.get() && job_->ShouldFallbackToNetwork()) {
72 job_ = NULL; 74 job_ = NULL;
73 return NULL; 75 return NULL;
74 } 76 }
75 77
76 // It's for original request (A) or redirect case (B-a or B-b). 78 // It's for original request (A) or redirect case (B-a or B-b).
77 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker()); 79 DCHECK(!job_.get() || job_->ShouldForwardToServiceWorker());
78 80
79 job_ = new ServiceWorkerURLRequestJob( 81 job_ = new ServiceWorkerURLRequestJob(request,
80 request, network_delegate, provider_host_, blob_storage_context_, body_); 82 network_delegate,
83 provider_host_,
84 blob_storage_context_,
85 request_mode_,
86 body_);
81 if (is_main_resource_load_) 87 if (is_main_resource_load_)
82 PrepareForMainResource(request->url()); 88 PrepareForMainResource(request->url());
83 else 89 else
84 PrepareForSubResource(); 90 PrepareForSubResource();
85 91
86 if (job_->ShouldFallbackToNetwork()) { 92 if (job_->ShouldFallbackToNetwork()) {
87 // If we know we can fallback to network at this point (in case 93 // If we know we can fallback to network at this point (in case
88 // the storage lookup returned immediately), just return NULL here to 94 // the storage lookup returned immediately), just return NULL here to
89 // fallback to network. 95 // fallback to network.
90 job_ = NULL; 96 job_ = NULL;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 235 }
230 236
231 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { 237 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() {
232 DCHECK(job_.get()); 238 DCHECK(job_.get());
233 DCHECK(context_); 239 DCHECK(context_);
234 DCHECK(provider_host_->active_version()); 240 DCHECK(provider_host_->active_version());
235 job_->ForwardToServiceWorker(); 241 job_->ForwardToServiceWorker();
236 } 242 }
237 243
238 } // namespace content 244 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698