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

Side by Side Diff: chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer.cc

Issue 1721813002: Adding DRP specfic UMA for FirstContentfulPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing Header Include Created 4 years, 7 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
(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"
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 {
bengr 2016/04/29 21:14:20 Why does this namespace need to be named? Can it b
RyanSturm 2016/05/02 19:52:18 So it has external linkage. I don't think the exte
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 : is_using_lofi_(false), used_data_reduction_proxy_(false) {}
bengr 2016/04/29 21:14:20 Should these be an enum? I ask because used_data_r
RyanSturm 2016/05/02 19:52:18 I think it should be an enum later if we find a go
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
42 // NavigationData instance returned from
43 // ResourceDispatcherHostDelegate::GetNavigationData during commit, which is
bengr 2016/04/29 21:14:20 My parser stopped working here. When does cloning
RyanSturm 2016/05/02 19:52:18 Done.
44 // always a ChromeNavigationData.
45 ChromeNavigationData* chrome_navigation_data =
46 static_cast<ChromeNavigationData*>(
47 navigation_handle->GetNavigationData());
48 if (!chrome_navigation_data) {
bengr 2016/04/29 21:14:20 Remove curly braces.
RyanSturm 2016/05/02 19:52:18 Done.
49 return;
50 }
51 data_reduction_proxy::DataReductionProxyData* data =
52 chrome_navigation_data->GetDataReductionProxyData();
53 if (data) {
bengr 2016/04/29 21:14:20 I would follow the patter in line 48: if (!data)
RyanSturm 2016/05/02 19:52:18 Done.
54 used_data_reduction_proxy_ = data->get_used_data_reduction_proxy();
55 is_using_lofi_ = data->get_is_using_lofi();
56 }
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 // Recording UMA for FirstContentfulPaint for various DataReductionProxy
bengr 2016/04/29 21:14:20 nit: Recording UMA for FirstContentfulPaint -> Rec
RyanSturm 2016/05/02 19:52:18 Done.
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(
73 internal::kHistogramFirstContentfulPaintDataReductionProxy,
74 timing.first_contentful_paint);
75 if (is_using_lofi_) {
bengr 2016/04/29 21:14:20 if (!is_using_lofi_) return; ...
RyanSturm 2016/05/02 19:52:19 Done.
76 if (data_reduction_proxy::params::IsIncludedInLoFiEnabledFieldTrial()) {
77 PAGE_LOAD_HISTOGRAM(
78 internal::kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOn,
79 timing.first_contentful_paint);
80 } else if (data_reduction_proxy::params::
81 IsIncludedInLoFiControlFieldTrial()) {
82 PAGE_LOAD_HISTOGRAM(
83 internal::kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOff,
84 timing.first_contentful_paint);
85 }
86 }
87 }
88
89 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698