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

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

Issue 2551013003: Introduce ServiceWorker.MainFramePageLoad.CoreTransition and RedirectChainLength UMAs. (Closed)
Patch Set: Add comment about where the 20 is defined Created 4 years 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_metrics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "content/browser/service_worker/service_worker_context_core.h" 12 #include "content/browser/service_worker/service_worker_context_core.h"
13 #include "content/browser/service_worker/service_worker_metrics.h" 13 #include "content/browser/service_worker/service_worker_metrics.h"
14 #include "content/browser/service_worker/service_worker_provider_host.h" 14 #include "content/browser/service_worker/service_worker_provider_host.h"
15 #include "content/browser/service_worker/service_worker_registration.h" 15 #include "content/browser/service_worker/service_worker_registration.h"
16 #include "content/browser/service_worker/service_worker_response_info.h" 16 #include "content/browser/service_worker/service_worker_response_info.h"
17 #include "content/browser/service_worker/service_worker_url_request_job.h" 17 #include "content/browser/service_worker/service_worker_url_request_job.h"
18 #include "content/common/resource_request_body_impl.h" 18 #include "content/common/resource_request_body_impl.h"
19 #include "content/common/service_worker/service_worker_types.h" 19 #include "content/common/service_worker/service_worker_types.h"
20 #include "content/common/service_worker/service_worker_utils.h" 20 #include "content/common/service_worker/service_worker_utils.h"
21 #include "content/public/browser/content_browser_client.h" 21 #include "content/public/browser/content_browser_client.h"
22 #include "content/public/browser/resource_request_info.h"
22 #include "content/public/common/content_client.h" 23 #include "content/public/common/content_client.h"
23 #include "content/public/common/resource_response_info.h" 24 #include "content/public/common/resource_response_info.h"
24 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
25 #include "net/base/url_util.h" 26 #include "net/base/url_util.h"
26 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
28 #include "ui/base/page_transition_types.h"
27 29
28 namespace content { 30 namespace content {
29 31
30 namespace { 32 namespace {
31 33
32 bool MaybeForwardToServiceWorker(ServiceWorkerURLRequestJob* job, 34 bool MaybeForwardToServiceWorker(ServiceWorkerURLRequestJob* job,
33 const ServiceWorkerVersion* version) { 35 const ServiceWorkerVersion* version) {
34 DCHECK(job); 36 DCHECK(job);
35 DCHECK(version); 37 DCHECK(version);
36 DCHECK_NE(version->fetch_handler_existence(), 38 DCHECK_NE(version->fetch_handler_existence(),
37 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN); 39 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN);
38 if (version->fetch_handler_existence() == 40 if (version->fetch_handler_existence() ==
39 ServiceWorkerVersion::FetchHandlerExistence::EXISTS) { 41 ServiceWorkerVersion::FetchHandlerExistence::EXISTS) {
40 job->ForwardToServiceWorker(); 42 job->ForwardToServiceWorker();
41 return true; 43 return true;
42 } 44 }
43 45
44 job->FallbackToNetworkOrRenderer(); 46 job->FallbackToNetworkOrRenderer();
45 return false; 47 return false;
46 } 48 }
47 49
50 ui::PageTransition GetPageTransition(net::URLRequest* request) {
51 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
52 // ResourceRequestInfo may not be set in some tests.
53 if (!info)
54 return ui::PAGE_TRANSITION_LINK;
55 return info->GetPageTransition();
56 }
57
48 } // namespace 58 } // namespace
49 59
50 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler( 60 ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler(
51 base::WeakPtr<ServiceWorkerContextCore> context, 61 base::WeakPtr<ServiceWorkerContextCore> context,
52 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 62 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
53 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 63 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
54 FetchRequestMode request_mode, 64 FetchRequestMode request_mode,
55 FetchCredentialsMode credentials_mode, 65 FetchCredentialsMode credentials_mode,
56 FetchRedirectMode redirect_mode, 66 FetchRedirectMode redirect_mode,
57 ResourceType resource_type, 67 ResourceType resource_type,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 288 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
279 job_.get(), 289 job_.get(),
280 "Status", status, 290 "Status", status,
281 "Info", 291 "Info",
282 "ServiceWorkerVersion is not available, so falling back to network"); 292 "ServiceWorkerVersion is not available, so falling back to network");
283 return; 293 return;
284 } 294 }
285 295
286 DCHECK_NE(active_version->fetch_handler_existence(), 296 DCHECK_NE(active_version->fetch_handler_existence(),
287 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN); 297 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN);
288
289 ServiceWorkerMetrics::CountControlledPageLoad( 298 ServiceWorkerMetrics::CountControlledPageLoad(
290 active_version->site_for_uma(), stripped_url_, is_main_frame_load_); 299 active_version->site_for_uma(), stripped_url_, is_main_frame_load_,
300 GetPageTransition(job_->request()), job_->request()->url_chain().size());
291 301
292 bool is_forwarded = 302 bool is_forwarded =
293 MaybeForwardToServiceWorker(job_.get(), active_version.get()); 303 MaybeForwardToServiceWorker(job_.get(), active_version.get());
294 304
295 TRACE_EVENT_ASYNC_END2( 305 TRACE_EVENT_ASYNC_END2(
296 "ServiceWorker", 306 "ServiceWorker",
297 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 307 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
298 job_.get(), "Status", status, "Info", 308 job_.get(), "Status", status, "Info",
299 (is_forwarded) ? "Forwarded to the ServiceWorker" 309 (is_forwarded) ? "Forwarded to the ServiceWorker"
300 : "Skipped the ServiceWorker which has no fetch handler"); 310 : "Skipped the ServiceWorker which has no fetch handler");
(...skipping 11 matching lines...) Expand all
312 if (version != registration->active_version() || 322 if (version != registration->active_version() ||
313 version->status() != ServiceWorkerVersion::ACTIVATED || 323 version->status() != ServiceWorkerVersion::ACTIVATED ||
314 !provider_host_) { 324 !provider_host_) {
315 job_->FallbackToNetwork(); 325 job_->FallbackToNetwork();
316 return; 326 return;
317 } 327 }
318 328
319 DCHECK_NE(version->fetch_handler_existence(), 329 DCHECK_NE(version->fetch_handler_existence(),
320 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN); 330 ServiceWorkerVersion::FetchHandlerExistence::UNKNOWN);
321 ServiceWorkerMetrics::CountControlledPageLoad( 331 ServiceWorkerMetrics::CountControlledPageLoad(
322 version->site_for_uma(), stripped_url_, is_main_frame_load_); 332 version->site_for_uma(), stripped_url_, is_main_frame_load_,
333 GetPageTransition(job_->request()), job_->request()->url_chain().size());
323 334
324 provider_host_->AssociateRegistration(registration, 335 provider_host_->AssociateRegistration(registration,
325 false /* notify_controllerchange */); 336 false /* notify_controllerchange */);
326 337
327 MaybeForwardToServiceWorker(job_.get(), version); 338 MaybeForwardToServiceWorker(job_.get(), version);
328 } 339 }
329 340
330 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration( 341 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration(
331 const scoped_refptr<ServiceWorkerRegistration>& original_registration, 342 const scoped_refptr<ServiceWorkerRegistration>& original_registration,
332 ServiceWorkerStatusCode status, 343 ServiceWorkerStatusCode status,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 DCHECK(provider_host_); 442 DCHECK(provider_host_);
432 // Detach the controller so subresource requests also skip the worker. 443 // Detach the controller so subresource requests also skip the worker.
433 provider_host_->NotifyControllerLost(); 444 provider_host_->NotifyControllerLost();
434 } 445 }
435 446
436 void ServiceWorkerControlleeRequestHandler::ClearJob() { 447 void ServiceWorkerControlleeRequestHandler::ClearJob() {
437 job_.reset(); 448 job_.reset();
438 } 449 }
439 450
440 } // namespace content 451 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698