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

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

Issue 1872673002: DevTools: introduce the bypass service worker checkbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 // It's for original request (A) or redirect case (B-a or B-b). 102 // It's for original request (A) or redirect case (B-a or B-b).
103 scoped_ptr<ServiceWorkerURLRequestJob> job(new ServiceWorkerURLRequestJob( 103 scoped_ptr<ServiceWorkerURLRequestJob> job(new ServiceWorkerURLRequestJob(
104 request, network_delegate, provider_host_->client_uuid(), 104 request, network_delegate, provider_host_->client_uuid(),
105 blob_storage_context_, resource_context, request_mode_, credentials_mode_, 105 blob_storage_context_, resource_context, request_mode_, credentials_mode_,
106 redirect_mode_, resource_type_, request_context_type_, frame_type_, body_, 106 redirect_mode_, resource_type_, request_context_type_, frame_type_, body_,
107 ServiceWorkerFetchType::FETCH, this)); 107 ServiceWorkerFetchType::FETCH, this));
108 job_ = job->GetWeakPtr(); 108 job_ = job->GetWeakPtr();
109 109
110 if (context_->fallback_to_network_for_devtools())
horo 2016/04/08 05:41:15 (1) Remove line 110-112.
111 job_->FallbackToNetwork();
112
110 resource_context_ = resource_context; 113 resource_context_ = resource_context;
111 114
112 if (is_main_resource_load_) 115 if (is_main_resource_load_)
113 PrepareForMainResource(request); 116 PrepareForMainResource(request);
114 else 117 else
115 PrepareForSubResource(); 118 PrepareForSubResource();
116 119
117 if (job_->ShouldFallbackToNetwork()) { 120 if (job_->ShouldFallbackToNetwork()) {
118 // If we know we can fallback to network at this point (in case 121 // If we know we can fallback to network at this point (in case
119 // the storage lookup returned immediately), just destroy the job and return 122 // the storage lookup returned immediately), just destroy the job and return
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 178
176 void 179 void
177 ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource( 180 ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource(
178 ServiceWorkerStatusCode status, 181 ServiceWorkerStatusCode status,
179 const scoped_refptr<ServiceWorkerRegistration>& registration) { 182 const scoped_refptr<ServiceWorkerRegistration>& registration) {
180 // The job may have been canceled and then destroyed before this was invoked. 183 // The job may have been canceled and then destroyed before this was invoked.
181 if (!job_) 184 if (!job_)
182 return; 185 return;
183 186
184 const bool need_to_update = !force_update_started_ && registration && 187 const bool need_to_update = !force_update_started_ && registration &&
185 context_->force_update_on_page_load(); 188 context_->update_on_page_load_for_devtools();
186 189
187 if (provider_host_ && !need_to_update) 190 if (provider_host_ && !need_to_update)
188 provider_host_->SetAllowAssociation(true); 191 provider_host_->SetAllowAssociation(true);
189 if (status != SERVICE_WORKER_OK || !provider_host_ || !context_) { 192 if (status != SERVICE_WORKER_OK || !provider_host_ || !context_) {
190 job_->FallbackToNetwork(); 193 job_->FallbackToNetwork();
191 TRACE_EVENT_ASYNC_END1( 194 TRACE_EVENT_ASYNC_END1(
192 "ServiceWorker", 195 "ServiceWorker",
193 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 196 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
194 job_.get(), 197 job_.get(),
195 "Status", status); 198 "Status", status);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 264 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
262 job_.get(), 265 job_.get(),
263 "Status", status, 266 "Status", status,
264 "Info", 267 "Info",
265 "ServiceWorkerVersion is not available, so falling back to network"); 268 "ServiceWorkerVersion is not available, so falling back to network");
266 return; 269 return;
267 } 270 }
268 271
269 ServiceWorkerMetrics::CountControlledPageLoad(stripped_url_); 272 ServiceWorkerMetrics::CountControlledPageLoad(stripped_url_);
270 273
271 job_->ForwardToServiceWorker(); 274 job_->ForwardToServiceWorker();
horo 2016/04/08 05:41:15 (3) Change here.
272 TRACE_EVENT_ASYNC_END2( 275 TRACE_EVENT_ASYNC_END2(
273 "ServiceWorker", 276 "ServiceWorker",
274 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 277 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
275 job_.get(), 278 job_.get(),
276 "Status", status, 279 "Status", status,
277 "Info", 280 "Info",
278 "Forwarded to the ServiceWorker"); 281 "Forwarded to the ServiceWorker");
279 } 282 }
280 283
281 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( 284 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged(
282 ServiceWorkerRegistration* registration, 285 ServiceWorkerRegistration* registration,
283 ServiceWorkerVersion* version) { 286 ServiceWorkerVersion* version) {
284 // The job may have been canceled and then destroyed before this was invoked. 287 // The job may have been canceled and then destroyed before this was invoked.
285 if (!job_) 288 if (!job_)
286 return; 289 return;
287 290
288 if (provider_host_) 291 if (provider_host_)
289 provider_host_->SetAllowAssociation(true); 292 provider_host_->SetAllowAssociation(true);
290 if (version != registration->active_version() || 293 if (version != registration->active_version() ||
291 version->status() != ServiceWorkerVersion::ACTIVATED || 294 version->status() != ServiceWorkerVersion::ACTIVATED ||
292 !provider_host_) { 295 !provider_host_) {
293 job_->FallbackToNetwork(); 296 job_->FallbackToNetwork();
294 return; 297 return;
295 } 298 }
296 299
297 ServiceWorkerMetrics::CountControlledPageLoad(stripped_url_); 300 ServiceWorkerMetrics::CountControlledPageLoad(stripped_url_);
298 301
299 provider_host_->AssociateRegistration(registration, 302 provider_host_->AssociateRegistration(registration,
300 false /* notify_controllerchange */); 303 false /* notify_controllerchange */);
301 job_->ForwardToServiceWorker(); 304 job_->ForwardToServiceWorker();
horo 2016/04/08 05:41:15 (4) Change here.
302 } 305 }
303 306
304 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration( 307 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration(
305 const scoped_refptr<ServiceWorkerRegistration>& original_registration, 308 const scoped_refptr<ServiceWorkerRegistration>& original_registration,
306 ServiceWorkerStatusCode status, 309 ServiceWorkerStatusCode status,
307 const std::string& status_message, 310 const std::string& status_message,
308 int64_t registration_id) { 311 int64_t registration_id) {
309 DCHECK(force_update_started_); 312 DCHECK(force_update_started_);
310 313
311 // The job may have been canceled and then destroyed before this was invoked. 314 // The job may have been canceled and then destroyed before this was invoked.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 364 }
362 version->RegisterStatusChangeCallback( 365 version->RegisterStatusChangeCallback(
363 base::Bind(&self::OnUpdatedVersionStatusChanged, 366 base::Bind(&self::OnUpdatedVersionStatusChanged,
364 weak_factory_.GetWeakPtr(), registration, version)); 367 weak_factory_.GetWeakPtr(), registration, version));
365 } 368 }
366 369
367 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { 370 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() {
368 DCHECK(job_.get()); 371 DCHECK(job_.get());
369 DCHECK(context_); 372 DCHECK(context_);
370 DCHECK(provider_host_->active_version()); 373 DCHECK(provider_host_->active_version());
371 job_->ForwardToServiceWorker(); 374 job_->ForwardToServiceWorker();
horo 2016/04/08 05:41:15 (2) Change here.
372 } 375 }
373 376
374 void ServiceWorkerControlleeRequestHandler::OnPrepareToRestart( 377 void ServiceWorkerControlleeRequestHandler::OnPrepareToRestart(
375 base::TimeTicks service_worker_start_time, 378 base::TimeTicks service_worker_start_time,
376 base::TimeTicks service_worker_ready_time) { 379 base::TimeTicks service_worker_ready_time) {
377 use_network_ = true; 380 use_network_ = true;
378 ClearJob(); 381 ClearJob();
379 // Update times, if not already set by a previous Job. 382 // Update times, if not already set by a previous Job.
380 if (service_worker_start_time_.is_null()) { 383 if (service_worker_start_time_.is_null()) {
381 service_worker_start_time_ = service_worker_start_time; 384 service_worker_start_time_ = service_worker_start_time;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 was_fetched_via_service_worker_ = false; 445 was_fetched_via_service_worker_ = false;
443 was_fallback_required_ = false; 446 was_fallback_required_ = false;
444 original_url_via_service_worker_ = GURL(); 447 original_url_via_service_worker_ = GURL();
445 response_type_via_service_worker_ = 448 response_type_via_service_worker_ =
446 blink::WebServiceWorkerResponseTypeDefault; 449 blink::WebServiceWorkerResponseTypeDefault;
447 response_is_in_cache_storage_ = false; 450 response_is_in_cache_storage_ = false;
448 response_cache_storage_cache_name_ = std::string(); 451 response_cache_storage_cache_name_ = std::string();
449 } 452 }
450 453
451 } // namespace content 454 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698