Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/page_load_metrics/observers/service_worker_page_load_me trics_observer.h" | |
| 6 #include "components/page_load_metrics/browser/page_load_metrics_util.h" | |
| 7 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" | |
| 8 | |
| 9 namespace internal { | |
| 10 | |
| 11 const char kHistogramServiceWorkerFirstContentfulPaint[] = | |
| 12 "PageLoad.Clients.ServiceWorker.Timing2.NavigationToFirstContentfulPaint"; | |
| 13 const char kBackgroundHistogramServiceWorkerFirstContentfulPaint[] = | |
| 14 "PageLoad.Clients.ServiceWorker.Timing2.NavigationToFirstContentfulPaint." | |
| 15 "Background"; | |
| 16 | |
| 17 } // namespace internal | |
| 18 | |
| 19 ServiceWorkerPageLoadMetricsObserver::ServiceWorkerPageLoadMetricsObserver() {} | |
| 20 | |
| 21 void ServiceWorkerPageLoadMetricsObserver::OnComplete( | |
| 22 const page_load_metrics::PageLoadTiming& timing, | |
| 23 const page_load_metrics::PageLoadExtraInfo& info) { | |
| 24 if (timing.first_contentful_paint.is_zero()) | |
| 25 return; | |
| 26 if (info.metadata.behavior_flags & | |
| 27 blink::WebLoadingBehaviorFlag:: | |
| 28 WebLoadingBehaviorServiceWorkerControlled) { | |
| 29 LogDocumentWriteEvaluatorData(timing, info); | |
|
Bryan McQuade
2016/04/14 15:10:26
rename to LogServiceWorkerHistograms
horo
2016/04/14 15:46:31
Done.
| |
| 30 } | |
| 31 } | |
| 32 | |
| 33 void ServiceWorkerPageLoadMetricsObserver::LogDocumentWriteEvaluatorData( | |
| 34 const page_load_metrics::PageLoadTiming& timing, | |
| 35 const page_load_metrics::PageLoadExtraInfo& info) { | |
| 36 bool foreground_paint = WasStartedInForegroundEventInForeground( | |
| 37 timing.first_contentful_paint, info); | |
| 38 if (foreground_paint) { | |
| 39 PAGE_LOAD_HISTOGRAM(internal::kHistogramServiceWorkerFirstContentfulPaint, | |
| 40 timing.first_contentful_paint); | |
| 41 } else { | |
| 42 PAGE_LOAD_HISTOGRAM( | |
| 43 internal::kBackgroundHistogramServiceWorkerFirstContentfulPaint, | |
| 44 timing.first_contentful_paint); | |
| 45 } | |
| 46 } | |
| OLD | NEW |