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/data_reduction_proxy_metric s_observer.h" | |
| 6 | |
| 7 #include "base/metrics/histogram.h" | |
|
Charlie Harrison
2016/05/03 01:08:32
Not sure you need this if you're only using PAGE_L
RyanSturm
2016/05/03 18:14:13
Done.
| |
| 8 #include "chrome/browser/renderer_host/chrome_navigation_data.h" | |
| 9 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" | |
| 10 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | |
| 11 #include "components/page_load_metrics/browser/page_load_metrics_observer.h" | |
| 12 #include "components/page_load_metrics/browser/page_load_metrics_util.h" | |
| 13 #include "components/page_load_metrics/common/page_load_timing.h" | |
| 14 #include "content/public/browser/navigation_data.h" | |
| 15 #include "content/public/browser/navigation_handle.h" | |
| 16 | |
| 17 namespace data_reduction_proxy { | |
| 18 | |
| 19 namespace internal { | |
| 20 | |
| 21 const char kHistogramFirstContentfulPaintDataReductionProxy[] = | |
| 22 "PageLoad.Clients.DataReductionProxy.Timing2." | |
| 23 "NavigationToFirstContentfulPaint"; | |
| 24 const char kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOn[] = | |
| 25 "PageLoad.Clients.DataReductionProxy.AutoLoFiOn.Timing2." | |
| 26 "NavigationToFirstContentfulPaint"; | |
| 27 const char kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOff[] = | |
| 28 "PageLoad.Clients.DataReductionProxy.AutoLoFiOff.Timing2." | |
| 29 "NavigationToFirstContentfulPaint"; | |
| 30 | |
| 31 } // namespace internal | |
| 32 | |
| 33 DataReductionProxyMetricsObserver::DataReductionProxyMetricsObserver() | |
| 34 : lofi_requested_(false), used_data_reduction_proxy_(false) {} | |
| 35 | |
| 36 DataReductionProxyMetricsObserver::~DataReductionProxyMetricsObserver() {} | |
| 37 | |
| 38 // Check if the NavigationData indicates anything about the DataReductionProxy. | |
| 39 void DataReductionProxyMetricsObserver::OnCommit( | |
| 40 content::NavigationHandle* navigation_handle) { | |
| 41 // As documented in content, this NavigationData is a clone of the | |
|
Charlie Harrison
2016/05/03 01:08:32
"//content" is clearer than "content". Better yet,
RyanSturm
2016/05/03 18:14:13
Done.
| |
| 42 // NavigationData instance returned from | |
| 43 // ResourceDispatcherHostDelegate::GetNavigationData during commit. | |
| 44 // Because ChromeResourceDispatcherHostDelegate always returns a | |
| 45 // ChromeNavigationData, it is safe to static_cast here. | |
| 46 ChromeNavigationData* chrome_navigation_data = | |
| 47 static_cast<ChromeNavigationData*>( | |
| 48 navigation_handle->GetNavigationData()); | |
| 49 if (!chrome_navigation_data) | |
| 50 return; | |
| 51 data_reduction_proxy::DataReductionProxyData* data = | |
| 52 chrome_navigation_data->GetDataReductionProxyData(); | |
| 53 if (!data) | |
| 54 return; | |
| 55 used_data_reduction_proxy_ = data->used_data_reduction_proxy(); | |
| 56 lofi_requested_ = data->lofi_requested(); | |
| 57 } | |
| 58 | |
| 59 void DataReductionProxyMetricsObserver::OnComplete( | |
| 60 const page_load_metrics::PageLoadTiming& timing, | |
| 61 const page_load_metrics::PageLoadExtraInfo& info) { | |
| 62 RecordTimingHistograms(timing, info); | |
| 63 } | |
| 64 | |
| 65 // Record first contentful paint UMA for various DataReductionProxy | |
| 66 // configurations. | |
| 67 void DataReductionProxyMetricsObserver::RecordTimingHistograms( | |
| 68 const page_load_metrics::PageLoadTiming& timing, | |
| 69 const page_load_metrics::PageLoadExtraInfo& info) const { | |
| 70 if (timing.first_contentful_paint.is_zero() || !used_data_reduction_proxy_) | |
| 71 return; | |
| 72 PAGE_LOAD_HISTOGRAM( | |
|
Charlie Harrison
2016/05/03 01:08:32
You might want to filter out loads that occurred i
RyanSturm
2016/05/03 18:14:13
Thanks. That sounds like a good idea.
| |
| 73 internal::kHistogramFirstContentfulPaintDataReductionProxy, | |
| 74 timing.first_contentful_paint); | |
| 75 if (!lofi_requested_) | |
| 76 return; | |
| 77 if (data_reduction_proxy::params::IsIncludedInLoFiEnabledFieldTrial()) { | |
|
Bryan McQuade
2016/05/03 13:00:40
are these standard finch field trials? if so, you
RyanSturm
2016/05/03 18:14:13
Done.
| |
| 78 PAGE_LOAD_HISTOGRAM( | |
| 79 internal::kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOn, | |
| 80 timing.first_contentful_paint); | |
| 81 } else if (data_reduction_proxy::params:: | |
| 82 IsIncludedInLoFiControlFieldTrial()) { | |
| 83 PAGE_LOAD_HISTOGRAM( | |
| 84 internal::kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOff, | |
| 85 timing.first_contentful_paint); | |
| 86 } | |
| 87 } | |
| 88 | |
| 89 } // namespace data_reduction_proxy | |
| OLD | NEW |