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

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

Issue 2362033002: Showing previews UI for Offline Previews (Closed)
Patch Set: megjablon comments rebase Created 4 years, 2 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/optional.h" 9 #include "base/optional.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DataReductionProxyMetricsObserver::OnCommit( 95 DataReductionProxyMetricsObserver::OnCommit(
96 content::NavigationHandle* navigation_handle) { 96 content::NavigationHandle* navigation_handle) {
97 // This BrowserContext is valid for the lifetime of 97 // This BrowserContext is valid for the lifetime of
98 // DataReductionProxyMetricsObserver. BrowserContext is always valid and 98 // DataReductionProxyMetricsObserver. BrowserContext is always valid and
99 // non-nullptr in NavigationControllerImpl, which is a member of WebContents. 99 // non-nullptr in NavigationControllerImpl, which is a member of WebContents.
100 // A raw pointer to BrowserContext taken at this point will be valid until 100 // A raw pointer to BrowserContext taken at this point will be valid until
101 // after WebContent's destructor. The latest that PageLoadTracker's destructor 101 // after WebContent's destructor. The latest that PageLoadTracker's destructor
102 // will be called is in MetricsWebContentsObserver's destrcutor, which is 102 // will be called is in MetricsWebContentsObserver's destrcutor, which is
103 // called in WebContents destructor. 103 // called in WebContents destructor.
104 browser_context_ = navigation_handle->GetWebContents()->GetBrowserContext(); 104 browser_context_ = navigation_handle->GetWebContents()->GetBrowserContext();
105 // As documented in content/public/browser/navigation_handle.h, this
106 // NavigationData is a clone of the NavigationData instance returned from
107 // ResourceDispatcherHostDelegate::GetNavigationData during commit.
108 // Because ChromeResourceDispatcherHostDelegate always returns a
109 // ChromeNavigationData, it is safe to static_cast here.
110 ChromeNavigationData* chrome_navigation_data = 105 ChromeNavigationData* chrome_navigation_data =
111 static_cast<ChromeNavigationData*>( 106 ChromeNavigationData::GetForNavigationHandle(navigation_handle);
112 navigation_handle->GetNavigationData());
113 if (!chrome_navigation_data) 107 if (!chrome_navigation_data)
114 return STOP_OBSERVING; 108 return STOP_OBSERVING;
115 data_reduction_proxy::DataReductionProxyData* data = 109 data_reduction_proxy::DataReductionProxyData* data =
116 chrome_navigation_data->GetDataReductionProxyData(); 110 chrome_navigation_data->GetDataReductionProxyData();
117 if (!data) 111 if (!data)
118 return STOP_OBSERVING; 112 return STOP_OBSERVING;
119 data_ = data->DeepCopy(); 113 data_ = data->DeepCopy();
120 // DataReductionProxy page loads should only occur on HTTP navigations. 114 // DataReductionProxy page loads should only occur on HTTP navigations.
121 DCHECK(!data_->used_data_reduction_proxy() || 115 DCHECK(!data_->used_data_reduction_proxy() ||
122 !navigation_handle->GetURL().SchemeIsCryptographic()); 116 !navigation_handle->GetURL().SchemeIsCryptographic());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 251
258 DataReductionProxyPingbackClient* 252 DataReductionProxyPingbackClient*
259 DataReductionProxyMetricsObserver::GetPingbackClient() const { 253 DataReductionProxyMetricsObserver::GetPingbackClient() const {
260 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 254 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
261 browser_context_) 255 browser_context_)
262 ->data_reduction_proxy_service() 256 ->data_reduction_proxy_service()
263 ->pingback_client(); 257 ->pingback_client();
264 } 258 }
265 259
266 } // namespace data_reduction_proxy 260 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698