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 <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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 167 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
168 DataReductionProxyMetricsObserver::FlushMetricsOnAppEnterBackground( | 168 DataReductionProxyMetricsObserver::FlushMetricsOnAppEnterBackground( |
169 const page_load_metrics::PageLoadTiming& timing, | 169 const page_load_metrics::PageLoadTiming& timing, |
170 const page_load_metrics::PageLoadExtraInfo& info) { | 170 const page_load_metrics::PageLoadExtraInfo& info) { |
171 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the | 171 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the |
172 // 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() |
173 // 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 |
174 // 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. |
175 if (info.did_commit) { | 175 if (info.did_commit) { |
176 RecordPageSizeUMA(); | 176 RecordPageSizeUMA(); |
177 SendPingback(timing, info); | 177 SendPingback(timing, info, true /* app_background_occured */); |
bengr
2017/04/20 23:19:36
Spelling.
RyanSturm
2017/04/21 16:25:04
Done.
| |
178 } | 178 } |
179 return STOP_OBSERVING; | 179 return STOP_OBSERVING; |
180 } | 180 } |
181 | 181 |
182 void DataReductionProxyMetricsObserver::OnComplete( | 182 void DataReductionProxyMetricsObserver::OnComplete( |
183 const page_load_metrics::PageLoadTiming& timing, | 183 const page_load_metrics::PageLoadTiming& timing, |
184 const page_load_metrics::PageLoadExtraInfo& info) { | 184 const page_load_metrics::PageLoadExtraInfo& info) { |
185 RecordPageSizeUMA(); | 185 RecordPageSizeUMA(); |
186 SendPingback(timing, info); | 186 SendPingback(timing, info, false /* app_background_occured */); |
bengr
2017/04/20 23:19:36
Spelling.
RyanSturm
2017/04/21 16:25:04
Done.
| |
187 } | 187 } |
188 | 188 |
189 void DataReductionProxyMetricsObserver::RecordPageSizeUMA() const { | 189 void DataReductionProxyMetricsObserver::RecordPageSizeUMA() const { |
190 if (!data_) | 190 if (!data_) |
191 return; | 191 return; |
192 | 192 |
193 // If the first request didn't complete, don't record UMA. | 193 // If the first request didn't complete, don't record UMA. |
194 if (num_network_resources_ == 0) | 194 if (num_network_resources_ == 0) |
195 return; | 195 return; |
196 | 196 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesSavings), | 264 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesSavings), |
265 original_network_bytes_ - network_bytes_); | 265 original_network_bytes_ - network_bytes_); |
266 } else { | 266 } else { |
267 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesInflation), | 267 PAGE_BYTES_HISTOGRAM(GetConstHistogramWithSuffix(internal::kBytesInflation), |
268 network_bytes_proxied_ - original_network_bytes_); | 268 network_bytes_proxied_ - original_network_bytes_); |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 void DataReductionProxyMetricsObserver::SendPingback( | 272 void DataReductionProxyMetricsObserver::SendPingback( |
273 const page_load_metrics::PageLoadTiming& timing, | 273 const page_load_metrics::PageLoadTiming& timing, |
274 const page_load_metrics::PageLoadExtraInfo& info) { | 274 const page_load_metrics::PageLoadExtraInfo& info, |
275 bool app_background_occurred) { | |
275 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast | 276 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast |
276 // shutdown cases. crbug.com/618072 | 277 // shutdown cases. crbug.com/618072 |
277 if (!browser_context_ || !data_) | 278 if (!browser_context_ || !data_) |
278 return; | 279 return; |
279 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() || | 280 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() || |
280 data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) { | 281 data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) { |
281 return; | 282 return; |
282 } | 283 } |
283 // Only consider timing events that happened before the first background | 284 // Only consider timing events that happened before the first background |
284 // event. | 285 // event. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 if (WasStartedInForegroundOptionalEventInForeground( | 319 if (WasStartedInForegroundOptionalEventInForeground( |
319 timing.parse_timing.parse_stop, info)) { | 320 timing.parse_timing.parse_stop, info)) { |
320 parse_stop = timing.parse_timing.parse_stop; | 321 parse_stop = timing.parse_timing.parse_stop; |
321 } | 322 } |
322 | 323 |
323 DataReductionProxyPageLoadTiming data_reduction_proxy_timing( | 324 DataReductionProxyPageLoadTiming data_reduction_proxy_timing( |
324 timing.navigation_start, response_start, load_event_start, | 325 timing.navigation_start, response_start, load_event_start, |
325 first_image_paint, first_contentful_paint, | 326 first_image_paint, first_contentful_paint, |
326 experimental_first_meaningful_paint, | 327 experimental_first_meaningful_paint, |
327 parse_blocked_on_script_load_duration, parse_stop, network_bytes_, | 328 parse_blocked_on_script_load_duration, parse_stop, network_bytes_, |
328 original_network_bytes_); | 329 original_network_bytes_, app_background_occurred); |
329 GetPingbackClient()->SendPingback(*data_, data_reduction_proxy_timing); | 330 GetPingbackClient()->SendPingback(*data_, data_reduction_proxy_timing); |
330 } | 331 } |
331 | 332 |
332 void DataReductionProxyMetricsObserver::OnDomContentLoadedEventStart( | 333 void DataReductionProxyMetricsObserver::OnDomContentLoadedEventStart( |
333 const page_load_metrics::PageLoadTiming& timing, | 334 const page_load_metrics::PageLoadTiming& timing, |
334 const page_load_metrics::PageLoadExtraInfo& info) { | 335 const page_load_metrics::PageLoadExtraInfo& info) { |
335 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX( | 336 RECORD_FOREGROUND_HISTOGRAMS_FOR_SUFFIX( |
336 info, data_, timing.document_timing.dom_content_loaded_event_start, | 337 info, data_, timing.document_timing.dom_content_loaded_event_start, |
337 internal::kHistogramDOMContentLoadedEventFiredSuffix); | 338 internal::kHistogramDOMContentLoadedEventFiredSuffix); |
338 } | 339 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 timing.parse_timing.parse_start.value(); | 413 timing.parse_timing.parse_start.value(); |
413 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, parse_duration, | 414 RECORD_HISTOGRAMS_FOR_SUFFIX(data_, parse_duration, |
414 internal::kHistogramParseDurationSuffix); | 415 internal::kHistogramParseDurationSuffix); |
415 RECORD_HISTOGRAMS_FOR_SUFFIX( | 416 RECORD_HISTOGRAMS_FOR_SUFFIX( |
416 data_, timing.parse_timing.parse_blocked_on_script_load_duration.value(), | 417 data_, timing.parse_timing.parse_blocked_on_script_load_duration.value(), |
417 internal::kHistogramParseBlockedOnScriptLoadSuffix); | 418 internal::kHistogramParseBlockedOnScriptLoadSuffix); |
418 } | 419 } |
419 | 420 |
420 void DataReductionProxyMetricsObserver::OnLoadedResource( | 421 void DataReductionProxyMetricsObserver::OnLoadedResource( |
421 const page_load_metrics::ExtraRequestInfo& extra_request_info) { | 422 const page_load_metrics::ExtraRequestInfo& extra_request_info) { |
423 if (extra_request_info.data_reduction_proxy_data && | |
424 extra_request_info.data_reduction_proxy_data->lofi_received()) { | |
425 data_->set_lofi_received(true); | |
426 } | |
422 if (extra_request_info.was_cached) | 427 if (extra_request_info.was_cached) |
423 return; | 428 return; |
424 original_network_bytes_ += extra_request_info.original_network_content_length; | 429 original_network_bytes_ += extra_request_info.original_network_content_length; |
425 network_bytes_ += extra_request_info.raw_body_bytes; | 430 network_bytes_ += extra_request_info.raw_body_bytes; |
426 num_network_resources_++; | 431 num_network_resources_++; |
427 if (!extra_request_info.data_reduction_proxy_used) | 432 if (!extra_request_info.data_reduction_proxy_data || |
433 !extra_request_info.data_reduction_proxy_data | |
434 ->used_data_reduction_proxy()) { | |
428 return; | 435 return; |
436 } | |
429 num_data_reduction_proxy_resources_++; | 437 num_data_reduction_proxy_resources_++; |
430 network_bytes_proxied_ += extra_request_info.raw_body_bytes; | 438 network_bytes_proxied_ += extra_request_info.raw_body_bytes; |
431 } | 439 } |
432 | 440 |
433 DataReductionProxyPingbackClient* | 441 DataReductionProxyPingbackClient* |
434 DataReductionProxyMetricsObserver::GetPingbackClient() const { | 442 DataReductionProxyMetricsObserver::GetPingbackClient() const { |
435 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 443 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
436 browser_context_) | 444 browser_context_) |
437 ->data_reduction_proxy_service() | 445 ->data_reduction_proxy_service() |
438 ->pingback_client(); | 446 ->pingback_client(); |
439 } | 447 } |
440 | 448 |
441 } // namespace data_reduction_proxy | 449 } // namespace data_reduction_proxy |
OLD | NEW |