| 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/optional.h" | 9 #include "base/optional.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 DataReductionProxyMetricsObserver::OnCommit( | 97 DataReductionProxyMetricsObserver::OnCommit( |
| 98 content::NavigationHandle* navigation_handle) { | 98 content::NavigationHandle* navigation_handle) { |
| 99 // This BrowserContext is valid for the lifetime of | 99 // This BrowserContext is valid for the lifetime of |
| 100 // DataReductionProxyMetricsObserver. BrowserContext is always valid and | 100 // DataReductionProxyMetricsObserver. BrowserContext is always valid and |
| 101 // non-nullptr in NavigationControllerImpl, which is a member of WebContents. | 101 // non-nullptr in NavigationControllerImpl, which is a member of WebContents. |
| 102 // A raw pointer to BrowserContext taken at this point will be valid until | 102 // A raw pointer to BrowserContext taken at this point will be valid until |
| 103 // after WebContent's destructor. The latest that PageLoadTracker's destructor | 103 // after WebContent's destructor. The latest that PageLoadTracker's destructor |
| 104 // will be called is in MetricsWebContentsObserver's destrcutor, which is | 104 // will be called is in MetricsWebContentsObserver's destrcutor, which is |
| 105 // called in WebContents destructor. | 105 // called in WebContents destructor. |
| 106 browser_context_ = navigation_handle->GetWebContents()->GetBrowserContext(); | 106 browser_context_ = navigation_handle->GetWebContents()->GetBrowserContext(); |
| 107 // As documented in content/public/browser/navigation_handle.h, this | |
| 108 // NavigationData is a clone of the NavigationData instance returned from | |
| 109 // ResourceDispatcherHostDelegate::GetNavigationData during commit. | |
| 110 // Because ChromeResourceDispatcherHostDelegate always returns a | |
| 111 // ChromeNavigationData, it is safe to static_cast here. | |
| 112 ChromeNavigationData* chrome_navigation_data = | 107 ChromeNavigationData* chrome_navigation_data = |
| 113 static_cast<ChromeNavigationData*>( | 108 ChromeNavigationData::GetForNavigationHandle(navigation_handle); |
| 114 navigation_handle->GetNavigationData()); | |
| 115 if (!chrome_navigation_data) | 109 if (!chrome_navigation_data) |
| 116 return STOP_OBSERVING; | 110 return STOP_OBSERVING; |
| 117 data_reduction_proxy::DataReductionProxyData* data = | 111 data_reduction_proxy::DataReductionProxyData* data = |
| 118 chrome_navigation_data->GetDataReductionProxyData(); | 112 chrome_navigation_data->GetDataReductionProxyData(); |
| 119 if (!data) | 113 if (!data) |
| 120 return STOP_OBSERVING; | 114 return STOP_OBSERVING; |
| 121 data_ = data->DeepCopy(); | 115 data_ = data->DeepCopy(); |
| 122 // DataReductionProxy page loads should only occur on HTTP navigations. | 116 // DataReductionProxy page loads should only occur on HTTP navigations. |
| 123 DCHECK(!data_->used_data_reduction_proxy() || | 117 DCHECK(!data_->used_data_reduction_proxy() || |
| 124 !navigation_handle->GetURL().SchemeIsCryptographic()); | 118 !navigation_handle->GetURL().SchemeIsCryptographic()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 267 |
| 274 DataReductionProxyPingbackClient* | 268 DataReductionProxyPingbackClient* |
| 275 DataReductionProxyMetricsObserver::GetPingbackClient() const { | 269 DataReductionProxyMetricsObserver::GetPingbackClient() const { |
| 276 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 270 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 277 browser_context_) | 271 browser_context_) |
| 278 ->data_reduction_proxy_service() | 272 ->data_reduction_proxy_service() |
| 279 ->pingback_client(); | 273 ->pingback_client(); |
| 280 } | 274 } |
| 281 | 275 |
| 282 } // namespace data_reduction_proxy | 276 } // namespace data_reduction_proxy |
| OLD | NEW |