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

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

Issue 2681193003: Page load metrics observers cleanup (Closed)
Patch Set: address comment Created 3 years, 10 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
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 <string> 7 #include <string>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/optional.h" 10 #include "base/optional.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 do { \ 46 do { \
47 PAGE_LOAD_HISTOGRAM(GetConstHistogramWithSuffix(histogram_suffix), value); \ 47 PAGE_LOAD_HISTOGRAM(GetConstHistogramWithSuffix(histogram_suffix), value); \
48 if (data->lofi_requested()) { \ 48 if (data->lofi_requested()) { \
49 PAGE_LOAD_HISTOGRAM( \ 49 PAGE_LOAD_HISTOGRAM( \
50 std::string(internal::kHistogramDataReductionProxyLoFiOnPrefix) \ 50 std::string(internal::kHistogramDataReductionProxyLoFiOnPrefix) \
51 .append(histogram_suffix), \ 51 .append(histogram_suffix), \
52 value); \ 52 value); \
53 } \ 53 } \
54 } while (false) 54 } while (false)
55 55
56 // Records the kilobytes (i.e., bytes / 1024) to |histogram_name| in a histogram 56 // Like RECORD_HISTOGRAMS_FOR_SUFFIX, but only records histograms if the event
57 // with 50 buckets capped at 500 MB. 57 // occurred while the page was in the foreground.
58 #define RECORD_KILOBYTES_HISTOGRAM(histogram_name, bytes) \ 58 #define RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(info, data, timing, \
59 UMA_HISTOGRAM_CUSTOM_COUNTS( \ 59 histogram_suffix) \
60 histogram_name, static_cast<int>((bytes) / 1024), 1, 500 * 1024, 50) 60 do { \
61 if (WasStartedInForegroundOptionalEventInForeground(timing, info)) { \
62 RECORD_HISTOGRAMS_FOR_SUFFIX(data, timing.value(), histogram_suffix); \
63 } \
64 } while (false)
61 65
62 } // namespace 66 } // namespace
63 67
64 namespace internal { 68 namespace internal {
65 69
66 const char kHistogramDataReductionProxyPrefix[] = 70 const char kHistogramDataReductionProxyPrefix[] =
67 "PageLoad.Clients.DataReductionProxy."; 71 "PageLoad.Clients.DataReductionProxy.";
68 const char kHistogramDataReductionProxyLoFiOnPrefix[] = 72 const char kHistogramDataReductionProxyLoFiOnPrefix[] =
69 "PageLoad.Clients.DataReductionProxy.LoFiOn."; 73 "PageLoad.Clients.DataReductionProxy.LoFiOn.";
70 const char kHistogramDOMContentLoadedEventFiredSuffix[] = 74 const char kHistogramDOMContentLoadedEventFiredSuffix[] =
71 "DocumentTiming.NavigationToDOMContentLoadedEventFired"; 75 "DocumentTiming.NavigationToDOMContentLoadedEventFired";
72 const char kHistogramFirstLayoutSuffix[] = 76 const char kHistogramFirstLayoutSuffix[] =
73 "DocumentTiming.NavigationToFirstLayout"; 77 "DocumentTiming.NavigationToFirstLayout";
74 const char kHistogramLoadEventFiredSuffix[] = 78 const char kHistogramLoadEventFiredSuffix[] =
75 "DocumentTiming.NavigationToLoadEventFired"; 79 "DocumentTiming.NavigationToLoadEventFired";
76 const char kHistogramFirstContentfulPaintSuffix[] = 80 const char kHistogramFirstContentfulPaintSuffix[] =
77 "PaintTiming.NavigationToFirstContentfulPaint"; 81 "PaintTiming.NavigationToFirstContentfulPaint";
78 const char kHistogramFirstMeaningfulPaintSuffix[] = 82 const char kHistogramFirstMeaningfulPaintSuffix[] =
79 "Experimental.PaintTiming.NavigationToFirstMeaningfulPaint"; 83 "Experimental.PaintTiming.NavigationToFirstMeaningfulPaint";
80 const char kHistogramFirstImagePaintSuffix[] = 84 const char kHistogramFirstImagePaintSuffix[] =
81 "PaintTiming.NavigationToFirstImagePaint"; 85 "PaintTiming.NavigationToFirstImagePaint";
82 const char kHistogramFirstPaintSuffix[] = "PaintTiming.NavigationToFirstPaint"; 86 const char kHistogramFirstPaintSuffix[] = "PaintTiming.NavigationToFirstPaint";
83 const char kHistogramFirstTextPaintSuffix[] = 87 const char kHistogramFirstTextPaintSuffix[] =
84 "PaintTiming.NavigationToFirstTextPaint"; 88 "PaintTiming.NavigationToFirstTextPaint";
85 const char kHistogramParseStartSuffix[] = "ParseTiming.NavigationToParseStart"; 89 const char kHistogramParseStartSuffix[] = "ParseTiming.NavigationToParseStart";
86 const char kHistogramParseBlockedOnScriptLoadSuffix[] = 90 const char kHistogramParseBlockedOnScriptLoadSuffix[] =
87 "ParseTiming.ParseBlockedOnScriptLoad"; 91 "ParseTiming.ParseBlockedOnScriptLoad";
88 const char kHistogramParseDurationSuffix[] = "ParseTiming.ParseDuration"; 92 const char kHistogramParseDurationSuffix[] = "ParseTiming.ParseDuration";
89 93
90 const char kRequestsPercentProxied[] = 94 const char kResourcesPercentProxied[] =
91 "Experimental.Requests.Network.PercentProxied"; 95 "Experimental.CompletedResources.Network.PercentProxied";
92 const char kBytesPercentProxied[] = "Experimental.Bytes.Network.PercentProxied"; 96 const char kBytesPercentProxied[] = "Experimental.Bytes.Network.PercentProxied";
93 const char kBytesCompressionRatio[] = 97 const char kBytesCompressionRatio[] =
94 "Experimental.Bytes.Network.CompressionRatio"; 98 "Experimental.Bytes.Network.CompressionRatio";
95 const char kBytesInflationPercent[] = 99 const char kBytesInflationPercent[] =
96 "Experimental.Bytes.Network.InflationPercent"; 100 "Experimental.Bytes.Network.InflationPercent";
97 const char kNetworkRequests[] = "Experimental.Requests.Network"; 101 const char kNetworkResources[] = "Experimental.CompletedResources.Network";
98 const char kRequestsProxied[] = "Experimental.Requests.Network.Proxied"; 102 const char kResourcesProxied[] =
99 const char kRequestsNotProxied[] = "Experimental.Requests.Network.NonProxied"; 103 "Experimental.CompletedResources.Network.Proxied";
104 const char kResourcesNotProxied[] =
105 "Experimental.CompletedResources.Network.NonProxied";
100 const char kNetworkBytes[] = "Experimental.Bytes.Network"; 106 const char kNetworkBytes[] = "Experimental.Bytes.Network";
101 const char kBytesProxied[] = "Experimental.Bytes.Network.Proxied"; 107 const char kBytesProxied[] = "Experimental.Bytes.Network.Proxied";
102 const char kBytesNotProxied[] = "Experimental.Bytes.Network.NonProxied"; 108 const char kBytesNotProxied[] = "Experimental.Bytes.Network.NonProxied";
103 const char kBytesOriginal[] = "Experimental.Bytes.Network.Original"; 109 const char kBytesOriginal[] = "Experimental.Bytes.Network.Original";
104 const char kBytesSavings[] = "Experimental.Bytes.Network.Savings"; 110 const char kBytesSavings[] = "Experimental.Bytes.Network.Savings";
105 const char kBytesInflation[] = "Experimental.Bytes.Network.Inflation"; 111 const char kBytesInflation[] = "Experimental.Bytes.Network.Inflation";
106 112
107 } // namespace internal 113 } // namespace internal
108 114
109 DataReductionProxyMetricsObserver::DataReductionProxyMetricsObserver() 115 DataReductionProxyMetricsObserver::DataReductionProxyMetricsObserver()
110 : browser_context_(nullptr), 116 : browser_context_(nullptr),
111 num_data_reduction_proxy_requests_(0), 117 num_data_reduction_proxy_resources_(0),
112 num_network_requests_(0), 118 num_network_resources_(0),
113 original_network_bytes_(0), 119 original_network_bytes_(0),
114 network_bytes_proxied_(0), 120 network_bytes_proxied_(0),
115 network_bytes_(0) {} 121 network_bytes_(0) {}
116 122
117 DataReductionProxyMetricsObserver::~DataReductionProxyMetricsObserver() {} 123 DataReductionProxyMetricsObserver::~DataReductionProxyMetricsObserver() {}
118 124
119 // Check if the NavigationData indicates anything about the DataReductionProxy. 125 // Check if the NavigationData indicates anything about the DataReductionProxy.
120 page_load_metrics::PageLoadMetricsObserver::ObservePolicy 126 page_load_metrics::PageLoadMetricsObserver::ObservePolicy
121 DataReductionProxyMetricsObserver::OnCommit( 127 DataReductionProxyMetricsObserver::OnCommit(
122 content::NavigationHandle* navigation_handle) { 128 content::NavigationHandle* navigation_handle) {
(...skipping 29 matching lines...) Expand all
152 DataReductionProxyMetricsObserver::OnStart( 158 DataReductionProxyMetricsObserver::OnStart(
153 content::NavigationHandle* navigation_handle, 159 content::NavigationHandle* navigation_handle,
154 const GURL& currently_committed_url, 160 const GURL& currently_committed_url,
155 bool started_in_foreground) { 161 bool started_in_foreground) {
156 if (!started_in_foreground) 162 if (!started_in_foreground)
157 return STOP_OBSERVING; 163 return STOP_OBSERVING;
158 return CONTINUE_OBSERVING; 164 return CONTINUE_OBSERVING;
159 } 165 }
160 166
161 page_load_metrics::PageLoadMetricsObserver::ObservePolicy 167 page_load_metrics::PageLoadMetricsObserver::ObservePolicy
162 DataReductionProxyMetricsObserver::OnHidden(
163 const page_load_metrics::PageLoadTiming& timing,
164 const page_load_metrics::PageLoadExtraInfo& info) {
165 RecordPageSizeUMA();
166 SendPingback(timing, info);
167 return STOP_OBSERVING;
168 }
169
170 page_load_metrics::PageLoadMetricsObserver::ObservePolicy
171 DataReductionProxyMetricsObserver::FlushMetricsOnAppEnterBackground( 168 DataReductionProxyMetricsObserver::FlushMetricsOnAppEnterBackground(
172 const page_load_metrics::PageLoadTiming& timing, 169 const page_load_metrics::PageLoadTiming& timing,
173 const page_load_metrics::PageLoadExtraInfo& info) { 170 const page_load_metrics::PageLoadExtraInfo& info) {
174 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the 171 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the
175 // app is about to be backgrounded, as part of the Activity.onPause() 172 // app is about to be backgrounded, as part of the Activity.onPause()
176 // flow. After this method is invoked, Chrome may be killed without further 173 // flow. After this method is invoked, Chrome may be killed without further
177 // notification, so we send a pingback with data collected up to this point. 174 // notification, so we send a pingback with data collected up to this point.
178 RecordPageSizeUMA(); 175 if (!info.committed_url.is_empty()) {
179 SendPingback(timing, info); 176 RecordPageSizeUMA();
177 SendPingback(timing, info);
178 }
180 return STOP_OBSERVING; 179 return STOP_OBSERVING;
181 } 180 }
182 181
183 void DataReductionProxyMetricsObserver::OnComplete( 182 void DataReductionProxyMetricsObserver::OnComplete(
184 const page_load_metrics::PageLoadTiming& timing, 183 const page_load_metrics::PageLoadTiming& timing,
185 const page_load_metrics::PageLoadExtraInfo& info) { 184 const page_load_metrics::PageLoadExtraInfo& info) {
186 RecordPageSizeUMA(); 185 RecordPageSizeUMA();
187 SendPingback(timing, info); 186 SendPingback(timing, info);
188 } 187 }
189 188
190 void DataReductionProxyMetricsObserver::RecordPageSizeUMA() const { 189 void DataReductionProxyMetricsObserver::RecordPageSizeUMA() const {
190 if (!data_)
191 return;
192
191 // If the first request didn't complete, don't record UMA. 193 // If the first request didn't complete, don't record UMA.
192 if (num_network_requests_ == 0) 194 if (num_network_resources_ == 0)
193 return; 195 return;
194 196
195 // TODO(ryansturm): Evaluate if any of the below histograms are unncessary 197 // TODO(ryansturm): Evaluate if any of the below histograms are unncessary
196 // once data is available. crbug.com/682782 198 // once data is available. crbug.com/682782
197 199
198 // The percent of requests that went through the data reduction proxy. 200 // The percent of resources that went through the data reduction proxy.
199 UMA_HISTOGRAM_PERCENTAGE( 201 UMA_HISTOGRAM_PERCENTAGE(
200 GetConstHistogramWithSuffix(internal::kRequestsPercentProxied), 202 GetConstHistogramWithSuffix(internal::kResourcesPercentProxied),
201 (100 * num_data_reduction_proxy_requests_) / num_network_requests_); 203 (100 * num_data_reduction_proxy_resources_) / num_network_resources_);
202 204
203 // The percent of bytes that went through the data reduction proxy. 205 // The percent of bytes that went through the data reduction proxy.
204 if (network_bytes_ > 0) { 206 if (network_bytes_ > 0) {
205 UMA_HISTOGRAM_PERCENTAGE( 207 UMA_HISTOGRAM_PERCENTAGE(
206 GetConstHistogramWithSuffix(internal::kBytesPercentProxied), 208 GetConstHistogramWithSuffix(internal::kBytesPercentProxied),
207 static_cast<int>((100 * network_bytes_proxied_) / network_bytes_)); 209 static_cast<int>((100 * network_bytes_proxied_) / network_bytes_));
208 } 210 }
209 211
210 // If the data reduction proxy caused savings, record the compression ratio; 212 // If the data reduction proxy caused savings, record the compression ratio;
211 // otherwise, record the inflation ratio. 213 // otherwise, record the inflation ratio.
212 if (original_network_bytes_ > 0 && 214 if (original_network_bytes_ > 0 &&
213 original_network_bytes_ >= network_bytes_) { 215 original_network_bytes_ >= network_bytes_) {
214 UMA_HISTOGRAM_PERCENTAGE( 216 UMA_HISTOGRAM_PERCENTAGE(
215 GetConstHistogramWithSuffix(internal::kBytesCompressionRatio), 217 GetConstHistogramWithSuffix(internal::kBytesCompressionRatio),
216 static_cast<int>((100 * network_bytes_) / original_network_bytes_)); 218 static_cast<int>((100 * network_bytes_) / original_network_bytes_));
217 } else if (original_network_bytes_ > 0) { 219 } else if (original_network_bytes_ > 0) {
218 // Inflation should never be above one hundred percent. 220 // Inflation should never be above one hundred percent.
219 UMA_HISTOGRAM_PERCENTAGE( 221 UMA_HISTOGRAM_PERCENTAGE(
220 GetConstHistogramWithSuffix(internal::kBytesInflationPercent), 222 GetConstHistogramWithSuffix(internal::kBytesInflationPercent),
221 static_cast<int>((100 * network_bytes_) / original_network_bytes_ - 223 static_cast<int>((100 * network_bytes_) / original_network_bytes_ -
222 100)); 224 100));
223 } 225 }
224 226
225 // Record the number of network requests seen. 227 // Record the number of network resources seen.
226 UMA_HISTOGRAM_COUNTS_10000( 228 PAGE_RESOURCE_COUNT_HISTOGRAM(
227 GetConstHistogramWithSuffix(internal::kNetworkRequests), 229 GetConstHistogramWithSuffix(internal::kNetworkResources),
228 num_network_requests_); 230 num_network_resources_);
229 231
230 // Record the number of requests that used data reduction proxy. 232 // Record the number of resources that used data reduction proxy.
231 UMA_HISTOGRAM_COUNTS_10000( 233 PAGE_RESOURCE_COUNT_HISTOGRAM(
232 GetConstHistogramWithSuffix(internal::kRequestsProxied), 234 GetConstHistogramWithSuffix(internal::kResourcesProxied),
233 num_data_reduction_proxy_requests_); 235 num_data_reduction_proxy_resources_);
234 236
235 // Record the number of requests that did not use data reduction proxy. 237 // Record the number of resources that did not use data reduction proxy.
236 UMA_HISTOGRAM_COUNTS_10000( 238 PAGE_RESOURCE_COUNT_HISTOGRAM(
237 GetConstHistogramWithSuffix(internal::kRequestsNotProxied), 239 GetConstHistogramWithSuffix(internal::kResourcesNotProxied),
238 num_network_requests_ - num_data_reduction_proxy_requests_); 240 num_network_resources_ - num_data_reduction_proxy_resources_);
239 241
240 // Record the total KB of network bytes. 242 // Record the total KB of network bytes.
241 RECORD_KILOBYTES_HISTOGRAM( 243 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kNetworkBytes),
242 GetConstHistogramWithSuffix(internal::kNetworkBytes), network_bytes_); 244 network_bytes_);
243 245
244 // Record the total amount of bytes that went through the data reduction 246 // Record the total amount of bytes that went through the data reduction
245 // proxy. 247 // proxy.
246 RECORD_KILOBYTES_HISTOGRAM( 248 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesProxied),
247 GetConstHistogramWithSuffix(internal::kBytesProxied), 249 network_bytes_proxied_);
248 network_bytes_proxied_);
249 250
250 // Record the total amount of bytes that did not go through the data reduction 251 // Record the total amount of bytes that did not go through the data reduction
251 // proxy. 252 // proxy.
252 RECORD_KILOBYTES_HISTOGRAM( 253 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesNotProxied),
253 GetConstHistogramWithSuffix(internal::kBytesNotProxied), 254 network_bytes_ - network_bytes_proxied_);
254 network_bytes_ - network_bytes_proxied_);
255 255
256 // Record the total KB of network bytes that the user would have seen without 256 // Record the total KB of network bytes that the user would have seen without
257 // using data reduction proxy. 257 // using data reduction proxy.
258 RECORD_KILOBYTES_HISTOGRAM( 258 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesOriginal),
259 GetConstHistogramWithSuffix(internal::kBytesOriginal), 259 original_network_bytes_);
260 original_network_bytes_);
261 260
262 // Record the savings the user saw by using data reduction proxy. If there was 261 // Record the savings the user saw by using data reduction proxy. If there was
263 // inflation instead, record that. 262 // inflation instead, record that.
264 if (network_bytes_ <= original_network_bytes_) { 263 if (network_bytes_ <= original_network_bytes_) {
265 RECORD_KILOBYTES_HISTOGRAM( 264 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesSavings),
266 GetConstHistogramWithSuffix(internal::kBytesSavings), 265 original_network_bytes_ - network_bytes_);
267 original_network_bytes_ - network_bytes_);
268 } else { 266 } else {
269 RECORD_KILOBYTES_HISTOGRAM( 267 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesInflation),
270 GetConstHistogramWithSuffix(internal::kBytesInflation), 268 network_bytes_proxied_ - original_network_bytes_);
271 network_bytes_proxied_ - original_network_bytes_);
272 } 269 }
273 } 270 }
274 271
275 void DataReductionProxyMetricsObserver::SendPingback( 272 void DataReductionProxyMetricsObserver::SendPingback(
276 const page_load_metrics::PageLoadTiming& timing, 273 const page_load_metrics::PageLoadTiming& timing,
277 const page_load_metrics::PageLoadExtraInfo& info) { 274 const page_load_metrics::PageLoadExtraInfo& info) {
278 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast 275 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast
279 // shutdown cases. crbug.com/618072 276 // shutdown cases. crbug.com/618072
280 if (!browser_context_) 277 if (!browser_context_ || !data_)
281 return; 278 return;
282 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() || 279 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() ||
283 data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) { 280 data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) {
284 return; 281 return;
285 } 282 }
286 // Only consider timing events that happened before the first background 283 // Only consider timing events that happened before the first background
287 // event. 284 // event.
288 base::Optional<base::TimeDelta> response_start; 285 base::Optional<base::TimeDelta> response_start;
289 base::Optional<base::TimeDelta> load_event_start; 286 base::Optional<base::TimeDelta> load_event_start;
290 base::Optional<base::TimeDelta> first_image_paint; 287 base::Optional<base::TimeDelta> first_image_paint;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 first_image_paint, first_contentful_paint, 324 first_image_paint, first_contentful_paint,
328 experimental_first_meaningful_paint, 325 experimental_first_meaningful_paint,
329 parse_blocked_on_script_load_duration, parse_stop, network_bytes_, 326 parse_blocked_on_script_load_duration, parse_stop, network_bytes_,
330 original_network_bytes_); 327 original_network_bytes_);
331 GetPingbackClient()->SendPingback(*data_, data_reduction_proxy_timing); 328 GetPingbackClient()->SendPingback(*data_, data_reduction_proxy_timing);
332 } 329 }
333 330
334 void DataReductionProxyMetricsObserver::OnDomContentLoadedEventStart( 331 void DataReductionProxyMetricsObserver::OnDomContentLoadedEventStart(
335 const page_load_metrics::PageLoadTiming& timing, 332 const page_load_metrics::PageLoadTiming& timing,
336 const page_load_metrics::PageLoadExtraInfo& info) { 333 const page_load_metrics::PageLoadExtraInfo& info) {
337 RECORD_HISTOGRAMS_FOR_SUFFIX( 334 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(
338 data_, timing.dom_content_loaded_event_start.value(), 335 info, data_, timing.dom_content_loaded_event_start,
339 internal::kHistogramDOMContentLoadedEventFiredSuffix); 336 internal::kHistogramDOMContentLoadedEventFiredSuffix);
340 } 337 }
341 338
342 void DataReductionProxyMetricsObserver::OnLoadEventStart( 339 void DataReductionProxyMetricsObserver::OnLoadEventStart(
343 const page_load_metrics::PageLoadTiming& timing, 340 const page_load_metrics::PageLoadTiming& timing,
344 const page_load_metrics::PageLoadExtraInfo& info) { 341 const page_load_metrics::PageLoadExtraInfo& info) {
345 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.load_event_start.value(), 342 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(
346 internal::kHistogramLoadEventFiredSuffix); 343 info, data_, timing.load_event_start,
344 internal::kHistogramLoadEventFiredSuffix);
347 } 345 }
348 346
349 void DataReductionProxyMetricsObserver::OnFirstLayout( 347 void DataReductionProxyMetricsObserver::OnFirstLayout(
350 const page_load_metrics::PageLoadTiming& timing, 348 const page_load_metrics::PageLoadTiming& timing,
351 const page_load_metrics::PageLoadExtraInfo& info) { 349 const page_load_metrics::PageLoadExtraInfo& info) {
352 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.first_layout.value(), 350 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(
353 internal::kHistogramFirstLayoutSuffix); 351 info, data_, timing.first_layout, internal::kHistogramFirstLayoutSuffix);
354 } 352 }
355 353
356 void DataReductionProxyMetricsObserver::OnFirstPaint( 354 void DataReductionProxyMetricsObserver::OnFirstPaint(
357 const page_load_metrics::PageLoadTiming& timing, 355 const page_load_metrics::PageLoadTiming& timing,
358 const page_load_metrics::PageLoadExtraInfo& info) { 356 const page_load_metrics::PageLoadExtraInfo& info) {
359 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.first_paint.value(), 357 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(info, data_, timing.first_paint,
360 internal::kHistogramFirstPaintSuffix); 358 internal::kHistogramFirstPaintSuffix);
361 } 359 }
362 360
363 void DataReductionProxyMetricsObserver::OnFirstTextPaint( 361 void DataReductionProxyMetricsObserver::OnFirstTextPaint(
364 const page_load_metrics::PageLoadTiming& timing, 362 const page_load_metrics::PageLoadTiming& timing,
365 const page_load_metrics::PageLoadExtraInfo& info) { 363 const page_load_metrics::PageLoadExtraInfo& info) {
366 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.first_text_paint.value(), 364 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(
367 internal::kHistogramFirstTextPaintSuffix); 365 info, data_, timing.first_text_paint,
366 internal::kHistogramFirstTextPaintSuffix);
368 } 367 }
369 368
370 void DataReductionProxyMetricsObserver::OnFirstImagePaint( 369 void DataReductionProxyMetricsObserver::OnFirstImagePaint(
371 const page_load_metrics::PageLoadTiming& timing, 370 const page_load_metrics::PageLoadTiming& timing,
372 const page_load_metrics::PageLoadExtraInfo& info) { 371 const page_load_metrics::PageLoadExtraInfo& info) {
373 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.first_image_paint.value(), 372 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(
374 internal::kHistogramFirstImagePaintSuffix); 373 info, data_, timing.first_image_paint,
374 internal::kHistogramFirstImagePaintSuffix);
375 } 375 }
376 376
377 void DataReductionProxyMetricsObserver::OnFirstContentfulPaint( 377 void DataReductionProxyMetricsObserver::OnFirstContentfulPaint(
378 const page_load_metrics::PageLoadTiming& timing, 378 const page_load_metrics::PageLoadTiming& timing,
379 const page_load_metrics::PageLoadExtraInfo& info) { 379 const page_load_metrics::PageLoadExtraInfo& info) {
380 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.first_contentful_paint.value(), 380 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(
381 internal::kHistogramFirstContentfulPaintSuffix); 381 info, data_, timing.first_contentful_paint,
382 internal::kHistogramFirstContentfulPaintSuffix);
382 } 383 }
383 384
384 void DataReductionProxyMetricsObserver::OnFirstMeaningfulPaint( 385 void DataReductionProxyMetricsObserver::OnFirstMeaningfulPaint(
385 const page_load_metrics::PageLoadTiming& timing, 386 const page_load_metrics::PageLoadTiming& timing,
386 const page_load_metrics::PageLoadExtraInfo& info) { 387 const page_load_metrics::PageLoadExtraInfo& info) {
387 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.first_meaningful_paint.value(), 388 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(
388 internal::kHistogramFirstMeaningfulPaintSuffix); 389 info, data_, timing.first_meaningful_paint,
390 internal::kHistogramFirstMeaningfulPaintSuffix);
389 } 391 }
390 392
391 void DataReductionProxyMetricsObserver::OnParseStart( 393 void DataReductionProxyMetricsObserver::OnParseStart(
392 const page_load_metrics::PageLoadTiming& timing, 394 const page_load_metrics::PageLoadTiming& timing,
393 const page_load_metrics::PageLoadExtraInfo& info) { 395 const page_load_metrics::PageLoadExtraInfo& info) {
394 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, timing.parse_start.value(), 396 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX(info, data_, timing.parse_start,
395 internal::kHistogramParseStartSuffix); 397 internal::kHistogramParseStartSuffix);
396 } 398 }
397 399
398 void DataReductionProxyMetricsObserver::OnParseStop( 400 void DataReductionProxyMetricsObserver::OnParseStop(
399 const page_load_metrics::PageLoadTiming& timing, 401 const page_load_metrics::PageLoadTiming& timing,
400 const page_load_metrics::PageLoadExtraInfo& info) { 402 const page_load_metrics::PageLoadExtraInfo& info) {
403 if (!WasStartedInForegroundOptionalEventInForeground(timing.parse_stop, info))
404 return;
405
401 base::TimeDelta parse_duration = 406 base::TimeDelta parse_duration =
402 timing.parse_stop.value() - timing.parse_start.value(); 407 timing.parse_stop.value() - timing.parse_start.value();
403 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, parse_duration, 408 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, parse_duration,
404 internal::kHistogramParseDurationSuffix); 409 internal::kHistogramParseDurationSuffix);
405 RECORD_HISTOGRAMS_FOR_SUFFIX( 410 RECORD_HISTOGRAMS_FOR_SUFFIX(
406 data_, timing.parse_blocked_on_script_load_duration.value(), 411 data_, timing.parse_blocked_on_script_load_duration.value(),
407 internal::kHistogramParseBlockedOnScriptLoadSuffix); 412 internal::kHistogramParseBlockedOnScriptLoadSuffix);
408 } 413 }
409 414
410 void DataReductionProxyMetricsObserver::OnLoadedResource( 415 void DataReductionProxyMetricsObserver::OnLoadedResource(
411 const page_load_metrics::ExtraRequestInfo& extra_request_info) { 416 const page_load_metrics::ExtraRequestInfo& extra_request_info) {
412 if (extra_request_info.was_cached) 417 if (extra_request_info.was_cached)
413 return; 418 return;
414 original_network_bytes_ += extra_request_info.original_network_content_length; 419 original_network_bytes_ += extra_request_info.original_network_content_length;
415 network_bytes_ += extra_request_info.raw_body_bytes; 420 network_bytes_ += extra_request_info.raw_body_bytes;
416 num_network_requests_++; 421 num_network_resources_++;
417 if (!extra_request_info.data_reduction_proxy_used) 422 if (!extra_request_info.data_reduction_proxy_used)
418 return; 423 return;
419 num_data_reduction_proxy_requests_++; 424 num_data_reduction_proxy_resources_++;
420 network_bytes_proxied_ += extra_request_info.raw_body_bytes; 425 network_bytes_proxied_ += extra_request_info.raw_body_bytes;
421 } 426 }
422 427
423 DataReductionProxyPingbackClient* 428 DataReductionProxyPingbackClient*
424 DataReductionProxyMetricsObserver::GetPingbackClient() const { 429 DataReductionProxyMetricsObserver::GetPingbackClient() const {
425 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 430 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
426 browser_context_) 431 browser_context_)
427 ->data_reduction_proxy_service() 432 ->data_reduction_proxy_service()
428 ->pingback_client(); 433 ->pingback_client();
429 } 434 }
430 435
431 } // namespace data_reduction_proxy 436 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698