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

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

Issue 2250623003: Keep ServiceWorkerMetrics::Site in ServiceWorkerVersion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: diff from https://codereview.chromium.org/2251633002/#ps40001 Created 4 years, 4 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 <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 "ServiceWorker", 274 "ServiceWorker",
275 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 275 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
276 job_.get(), 276 job_.get(),
277 "Status", status, 277 "Status", status,
278 "Info", 278 "Info",
279 "ServiceWorkerVersion is not available, so falling back to network"); 279 "ServiceWorkerVersion is not available, so falling back to network");
280 return; 280 return;
281 } 281 }
282 282
283 ServiceWorkerMetrics::CountControlledPageLoad( 283 ServiceWorkerMetrics::CountControlledPageLoad(
284 stripped_url_, active_version->has_fetch_handler().value(), 284 active_version->site_for_uma(), stripped_url_, is_main_frame_load_);
285 is_main_frame_load_);
286 285
287 bool is_forwarded = 286 bool is_forwarded =
288 MaybeForwardToServiceWorker(job_.get(), active_version.get()); 287 MaybeForwardToServiceWorker(job_.get(), active_version.get());
289 288
290 TRACE_EVENT_ASYNC_END2( 289 TRACE_EVENT_ASYNC_END2(
291 "ServiceWorker", 290 "ServiceWorker",
292 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 291 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
293 job_.get(), "Status", status, "Info", 292 job_.get(), "Status", status, "Info",
294 (is_forwarded) ? "Forwarded to the ServiceWorker" 293 (is_forwarded) ? "Forwarded to the ServiceWorker"
295 : "Skipped the ServiceWorker which has no fetch handler"); 294 : "Skipped the ServiceWorker which has no fetch handler");
296 } 295 }
297 296
298 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( 297 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged(
299 ServiceWorkerRegistration* registration, 298 ServiceWorkerRegistration* registration,
300 ServiceWorkerVersion* version) { 299 ServiceWorkerVersion* version) {
301 // The job may have been canceled and then destroyed before this was invoked. 300 // The job may have been canceled and then destroyed before this was invoked.
302 if (!job_) 301 if (!job_)
303 return; 302 return;
304 303
305 if (provider_host_) 304 if (provider_host_)
306 provider_host_->SetAllowAssociation(true); 305 provider_host_->SetAllowAssociation(true);
307 if (version != registration->active_version() || 306 if (version != registration->active_version() ||
308 version->status() != ServiceWorkerVersion::ACTIVATED || 307 version->status() != ServiceWorkerVersion::ACTIVATED ||
309 !provider_host_) { 308 !provider_host_) {
310 job_->FallbackToNetwork(); 309 job_->FallbackToNetwork();
311 return; 310 return;
312 } 311 }
313 312
314 ServiceWorkerMetrics::CountControlledPageLoad( 313 ServiceWorkerMetrics::CountControlledPageLoad(
315 stripped_url_, version->has_fetch_handler().value(), is_main_frame_load_); 314 version->site_for_uma(), stripped_url_, is_main_frame_load_);
316 315
317 provider_host_->AssociateRegistration(registration, 316 provider_host_->AssociateRegistration(registration,
318 false /* notify_controllerchange */); 317 false /* notify_controllerchange */);
319 318
320 MaybeForwardToServiceWorker(job_.get(), version); 319 MaybeForwardToServiceWorker(job_.get(), version);
321 } 320 }
322 321
323 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration( 322 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration(
324 const scoped_refptr<ServiceWorkerRegistration>& original_registration, 323 const scoped_refptr<ServiceWorkerRegistration>& original_registration,
325 ServiceWorkerStatusCode status, 324 ServiceWorkerStatusCode status,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 DCHECK(provider_host_); 423 DCHECK(provider_host_);
425 // Detach the controller so subresource requests also skip the worker. 424 // Detach the controller so subresource requests also skip the worker.
426 provider_host_->NotifyControllerLost(); 425 provider_host_->NotifyControllerLost();
427 } 426 }
428 427
429 void ServiceWorkerControlleeRequestHandler::ClearJob() { 428 void ServiceWorkerControlleeRequestHandler::ClearJob() {
430 job_.reset(); 429 job_.reset();
431 } 430 }
432 431
433 } // namespace content 432 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698