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

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: Changing lifetime of NavigationSupportsUserData for Draft Created 4 years, 9 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 "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"
10 #include "components/page_load_metrics/browser/page_load_metrics_observer.h"
11 #include "components/page_load_metrics/browser/page_load_metrics_util.h"
12 #include "components/page_load_metrics/common/page_load_timing.h"
13 #include "content/public/browser/navigation_handle.h"
14
15 namespace data_reduction_proxy {
16
17 namespace internal {
18
19 const char kHistogramFirstContentfulPaintDataReductionProxy[] =
20 "PageLoad.Clients.DataReductionProxy.Timing2."
21 "NavigationToFirstContentfulPaint";
22 const char kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOn[] =
23 "PageLoad.Clients.DataReductionProxy.AutoLoFiOn.Timing2."
24 "NavigationToFirstContentfulPaint";
25 const char kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOff[] =
26 "PageLoad.Clients.DataReductionProxy.AutoLoFiOff.Timing2."
27 "NavigationToFirstContentfulPaint";
28
29 } // namespace internal
30
31 DataReductionProxyMetricsObserver::DataReductionProxyMetricsObserver()
32 : is_using_lofi_(false), used_data_reduction_proxy_(false) {}
33
34 DataReductionProxyMetricsObserver::~DataReductionProxyMetricsObserver() {}
35
36 void DataReductionProxyMetricsObserver::OnCommit(
37 content::NavigationHandle* navigation_handle) {
38 DataReductionProxyData* user_data =
39 static_cast<DataReductionProxyData*>(navigation_handle->GetUserData(
40 data_reduction_proxy::kDataReductionProxyUserDataKey));
41 if (user_data) {
42 used_data_reduction_proxy_ = user_data->get_used_data_reduction_proxy();
43 }
44 }
45 void DataReductionProxyMetricsObserver::OnComplete(
46 const page_load_metrics::PageLoadTiming& timing,
47 const page_load_metrics::PageLoadExtraInfo& info) {
48 RecordTimingHistograms(timing, info);
49 }
50
51 void DataReductionProxyMetricsObserver::RecordTimingHistograms(
52 const page_load_metrics::PageLoadTiming& timing,
53 const page_load_metrics::PageLoadExtraInfo& info) const {
54 if (timing.first_contentful_paint.is_zero() || !used_data_reduction_proxy_)
55 return;
56 LOG(WARNING) << "Navigation used DRP";
57 PAGE_LOAD_HISTOGRAM(
58 internal::kHistogramFirstContentfulPaintDataReductionProxy,
59 timing.first_contentful_paint);
60 if (is_using_lofi_) {
61 if (data_reduction_proxy::params::IsIncludedInLoFiEnabledFieldTrial()) {
62 PAGE_LOAD_HISTOGRAM(
63 internal::kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOn,
64 timing.first_contentful_paint);
65 } else if (data_reduction_proxy::params::
66 IsIncludedInLoFiControlFieldTrial()) {
67 PAGE_LOAD_HISTOGRAM(
68 internal::kHistogramFirstContentfulPaintDataReductionProxyAutoLofiOff,
69 timing.first_contentful_paint);
70 }
71 }
72 }
73
74 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698