Chromium Code Reviews| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 // ResourceDispatcherHostDelegate::GetNavigationData during commit. | 140 // ResourceDispatcherHostDelegate::GetNavigationData during commit. |
| 141 // Because ChromeResourceDispatcherHostDelegate always returns a | 141 // Because ChromeResourceDispatcherHostDelegate always returns a |
| 142 // ChromeNavigationData, it is safe to static_cast here. | 142 // ChromeNavigationData, it is safe to static_cast here. |
| 143 ChromeNavigationData* chrome_navigation_data = | 143 ChromeNavigationData* chrome_navigation_data = |
| 144 static_cast<ChromeNavigationData*>( | 144 static_cast<ChromeNavigationData*>( |
| 145 navigation_handle->GetNavigationData()); | 145 navigation_handle->GetNavigationData()); |
| 146 if (!chrome_navigation_data) | 146 if (!chrome_navigation_data) |
| 147 return STOP_OBSERVING; | 147 return STOP_OBSERVING; |
| 148 data_reduction_proxy::DataReductionProxyData* data = | 148 data_reduction_proxy::DataReductionProxyData* data = |
| 149 chrome_navigation_data->GetDataReductionProxyData(); | 149 chrome_navigation_data->GetDataReductionProxyData(); |
| 150 if (!data || !data->used_data_reduction_proxy()) | 150 if (!data || !data->used_data_reduction_proxy()) |
|
tbansal1
2017/06/09 22:32:55
keep observing if holdback is enabled?
RyanSturm
2017/06/09 22:46:02
?
This checks if DRP would have been used for the
| |
| 151 return STOP_OBSERVING; | 151 return STOP_OBSERVING; |
| 152 data_ = data->DeepCopy(); | 152 data_ = data->DeepCopy(); |
| 153 // DataReductionProxy page loads should only occur on HTTP navigations. | 153 // DataReductionProxy page loads should only occur on HTTP navigations. |
| 154 DCHECK(!navigation_handle->GetURL().SchemeIsCryptographic()); | 154 DCHECK(!navigation_handle->GetURL().SchemeIsCryptographic()); |
| 155 DCHECK_EQ(data_->request_url(), navigation_handle->GetURL()); | |
| 155 return CONTINUE_OBSERVING; | 156 return CONTINUE_OBSERVING; |
| 156 } | 157 } |
| 157 | 158 |
| 158 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 159 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
| 159 DataReductionProxyMetricsObserver::OnStart( | 160 DataReductionProxyMetricsObserver::OnStart( |
| 160 content::NavigationHandle* navigation_handle, | 161 content::NavigationHandle* navigation_handle, |
| 161 const GURL& currently_committed_url, | 162 const GURL& currently_committed_url, |
| 162 bool started_in_foreground) { | 163 bool started_in_foreground) { |
| 163 if (!started_in_foreground) | 164 if (!started_in_foreground) |
| 164 return STOP_OBSERVING; | 165 return STOP_OBSERVING; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 } | 272 } |
| 272 | 273 |
| 273 void DataReductionProxyMetricsObserver::SendPingback( | 274 void DataReductionProxyMetricsObserver::SendPingback( |
| 274 const page_load_metrics::mojom::PageLoadTiming& timing, | 275 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 275 const page_load_metrics::PageLoadExtraInfo& info, | 276 const page_load_metrics::PageLoadExtraInfo& info, |
| 276 bool app_background_occurred) { | 277 bool app_background_occurred) { |
| 277 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast | 278 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast |
| 278 // shutdown cases. crbug.com/618072 | 279 // shutdown cases. crbug.com/618072 |
| 279 if (!browser_context_ || !data_) | 280 if (!browser_context_ || !data_) |
| 280 return; | 281 return; |
| 281 if (data_reduction_proxy::params::IsIncludedInHoldbackFieldTrial() || | |
| 282 data_reduction_proxy::params::IsIncludedInTamperDetectionExperiment()) { | |
| 283 return; | |
| 284 } | |
| 285 // Only consider timing events that happened before the first background | 282 // Only consider timing events that happened before the first background |
| 286 // event. | 283 // event. |
| 287 base::Optional<base::TimeDelta> response_start; | 284 base::Optional<base::TimeDelta> response_start; |
| 288 base::Optional<base::TimeDelta> load_event_start; | 285 base::Optional<base::TimeDelta> load_event_start; |
| 289 base::Optional<base::TimeDelta> first_image_paint; | 286 base::Optional<base::TimeDelta> first_image_paint; |
| 290 base::Optional<base::TimeDelta> first_contentful_paint; | 287 base::Optional<base::TimeDelta> first_contentful_paint; |
| 291 base::Optional<base::TimeDelta> experimental_first_meaningful_paint; | 288 base::Optional<base::TimeDelta> experimental_first_meaningful_paint; |
| 292 base::Optional<base::TimeDelta> parse_blocked_on_script_load_duration; | 289 base::Optional<base::TimeDelta> parse_blocked_on_script_load_duration; |
| 293 base::Optional<base::TimeDelta> parse_stop; | 290 base::Optional<base::TimeDelta> parse_stop; |
| 294 if (WasStartedInForegroundOptionalEventInForeground(timing.response_start, | 291 if (WasStartedInForegroundOptionalEventInForeground(timing.response_start, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 data_->set_lofi_received(true); | 425 data_->set_lofi_received(true); |
| 429 } | 426 } |
| 430 if (extra_request_complete_info.was_cached) | 427 if (extra_request_complete_info.was_cached) |
| 431 return; | 428 return; |
| 432 original_network_bytes_ += | 429 original_network_bytes_ += |
| 433 extra_request_complete_info.original_network_content_length; | 430 extra_request_complete_info.original_network_content_length; |
| 434 network_bytes_ += extra_request_complete_info.raw_body_bytes; | 431 network_bytes_ += extra_request_complete_info.raw_body_bytes; |
| 435 num_network_resources_++; | 432 num_network_resources_++; |
| 436 if (!extra_request_complete_info.data_reduction_proxy_data || | 433 if (!extra_request_complete_info.data_reduction_proxy_data || |
| 437 !extra_request_complete_info.data_reduction_proxy_data | 434 !extra_request_complete_info.data_reduction_proxy_data |
| 438 ->used_data_reduction_proxy()) { | 435 ->used_data_reduction_proxy()) { |
|
tbansal1
2017/06/09 22:32:55
check for holdback?
RyanSturm
2017/06/09 22:46:02
This will track the number of requests that would
| |
| 439 return; | 436 return; |
| 440 } | 437 } |
| 441 num_data_reduction_proxy_resources_++; | 438 num_data_reduction_proxy_resources_++; |
| 442 network_bytes_proxied_ += extra_request_complete_info.raw_body_bytes; | 439 network_bytes_proxied_ += extra_request_complete_info.raw_body_bytes; |
| 443 } | 440 } |
| 444 | 441 |
| 445 DataReductionProxyPingbackClient* | 442 DataReductionProxyPingbackClient* |
| 446 DataReductionProxyMetricsObserver::GetPingbackClient() const { | 443 DataReductionProxyMetricsObserver::GetPingbackClient() const { |
| 447 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 444 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 448 browser_context_) | 445 browser_context_) |
| 449 ->data_reduction_proxy_service() | 446 ->data_reduction_proxy_service() |
| 450 ->pingback_client(); | 447 ->pingback_client(); |
| 451 } | 448 } |
| 452 | 449 |
| 453 } // namespace data_reduction_proxy | 450 } // namespace data_reduction_proxy |
| OLD | NEW |