| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/renderer_host/chrome_navigation_data.h" | 7 #include "chrome/browser/renderer_host/chrome_navigation_data.h" |
| 8 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" | 8 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" |
| 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 10 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" | 10 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" |
| 11 #include "components/page_load_metrics/browser/page_load_metrics_util.h" | 11 #include "components/page_load_metrics/browser/page_load_metrics_util.h" |
| 12 #include "components/page_load_metrics/common/page_load_timing.h" | 12 #include "components/page_load_metrics/common/page_load_timing.h" |
| 13 #include "content/public/browser/navigation_data.h" | 13 #include "content/public/browser/navigation_data.h" |
| 14 #include "content/public/browser/navigation_handle.h" | 14 #include "content/public/browser/navigation_handle.h" |
| 15 | 15 |
| 16 namespace data_reduction_proxy { | 16 namespace data_reduction_proxy { |
| 17 | 17 |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 const char kHistogramFirstContentfulPaintDataReductionProxy[] = | 20 const char kHistogramFirstContentfulPaintDataReductionProxy[] = |
| 21 "PageLoad.Clients.DataReductionProxy.Timing2." | 21 "PageLoad.Clients.DataReductionProxy.PaintTiming." |
| 22 "NavigationToFirstContentfulPaint"; | 22 "NavigationToFirstContentfulPaint"; |
| 23 const char kHistogramFirstContentfulPaintDataReductionProxyLoFiOn[] = | 23 const char kHistogramFirstContentfulPaintDataReductionProxyLoFiOn[] = |
| 24 "PageLoad.Clients.DataReductionProxy.LoFiOn.Timing2." | 24 "PageLoad.Clients.DataReductionProxy.LoFiOn.PaintTiming." |
| 25 "NavigationToFirstContentfulPaint"; | 25 "NavigationToFirstContentfulPaint"; |
| 26 | 26 |
| 27 } // namespace internal | 27 } // namespace internal |
| 28 | 28 |
| 29 DataReductionProxyMetricsObserver::DataReductionProxyMetricsObserver() | 29 DataReductionProxyMetricsObserver::DataReductionProxyMetricsObserver() |
| 30 : lofi_requested_(false), used_data_reduction_proxy_(false) {} | 30 : lofi_requested_(false), used_data_reduction_proxy_(false) {} |
| 31 | 31 |
| 32 DataReductionProxyMetricsObserver::~DataReductionProxyMetricsObserver() {} | 32 DataReductionProxyMetricsObserver::~DataReductionProxyMetricsObserver() {} |
| 33 | 33 |
| 34 // Check if the NavigationData indicates anything about the DataReductionProxy. | 34 // Check if the NavigationData indicates anything about the DataReductionProxy. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 if (!chrome_navigation_data) | 45 if (!chrome_navigation_data) |
| 46 return; | 46 return; |
| 47 data_reduction_proxy::DataReductionProxyData* data = | 47 data_reduction_proxy::DataReductionProxyData* data = |
| 48 chrome_navigation_data->GetDataReductionProxyData(); | 48 chrome_navigation_data->GetDataReductionProxyData(); |
| 49 if (!data) | 49 if (!data) |
| 50 return; | 50 return; |
| 51 used_data_reduction_proxy_ = data->used_data_reduction_proxy(); | 51 used_data_reduction_proxy_ = data->used_data_reduction_proxy(); |
| 52 lofi_requested_ = data->lofi_requested(); | 52 lofi_requested_ = data->lofi_requested(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void DataReductionProxyMetricsObserver::OnComplete( | 55 void DataReductionProxyMetricsObserver::OnFirstContentfulPaint( |
| 56 const page_load_metrics::PageLoadTiming& timing, | 56 const page_load_metrics::PageLoadTiming& timing, |
| 57 const page_load_metrics::PageLoadExtraInfo& info) { | 57 const page_load_metrics::PageLoadExtraInfo& info) { |
| 58 RecordTimingHistograms(timing, info); | |
| 59 } | |
| 60 | |
| 61 // Record first contentful paint UMA for various DataReductionProxy | |
| 62 // configurations. | |
| 63 void DataReductionProxyMetricsObserver::RecordTimingHistograms( | |
| 64 const page_load_metrics::PageLoadTiming& timing, | |
| 65 const page_load_metrics::PageLoadExtraInfo& info) const { | |
| 66 if (!used_data_reduction_proxy_ || | 58 if (!used_data_reduction_proxy_ || |
| 67 !WasStartedInForegroundEventInForeground(timing.first_contentful_paint, | 59 !WasStartedInForegroundEventInForeground(timing.first_contentful_paint, |
| 68 info)) | 60 info)) |
| 69 return; | 61 return; |
| 70 PAGE_LOAD_HISTOGRAM( | 62 PAGE_LOAD_HISTOGRAM( |
| 71 internal::kHistogramFirstContentfulPaintDataReductionProxy, | 63 internal::kHistogramFirstContentfulPaintDataReductionProxy, |
| 72 timing.first_contentful_paint); | 64 timing.first_contentful_paint); |
| 73 if (!lofi_requested_) | 65 if (!lofi_requested_) |
| 74 return; | 66 return; |
| 75 PAGE_LOAD_HISTOGRAM( | 67 PAGE_LOAD_HISTOGRAM( |
| 76 internal::kHistogramFirstContentfulPaintDataReductionProxyLoFiOn, | 68 internal::kHistogramFirstContentfulPaintDataReductionProxyLoFiOn, |
| 77 timing.first_contentful_paint); | 69 timing.first_contentful_paint); |
| 78 } | 70 } |
| 79 | 71 |
| 80 } // namespace data_reduction_proxy | 72 } // namespace data_reduction_proxy |
| OLD | NEW |