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

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

Issue 2326443004: Fixing redirect through DataReductionProxy logic. (Closed)
Patch Set: tbansal comments Created 4 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
13 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" 13 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
14 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" 14 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
15 #include "chrome/browser/renderer_host/chrome_navigation_data.h" 15 #include "chrome/browser/renderer_host/chrome_navigation_data.h"
16 #include "chrome/common/page_load_metrics/page_load_timing.h" 16 #include "chrome/common/page_load_metrics/page_load_timing.h"
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h"
18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_ping back_client.h" 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_ping back_client.h"
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h" 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h"
20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_ load_timing.h" 20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_ load_timing.h"
21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
22 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
23 #include "content/public/browser/navigation_data.h" 23 #include "content/public/browser/navigation_data.h"
24 #include "content/public/browser/navigation_handle.h" 24 #include "content/public/browser/navigation_handle.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "url/gurl.h"
26 27
27 namespace data_reduction_proxy { 28 namespace data_reduction_proxy {
28 29
29 namespace { 30 namespace {
30 31
31 bool ShouldRecordHistogram(const DataReductionProxyData* data, 32 bool ShouldRecordHistogram(const DataReductionProxyData* data,
32 const base::Optional<base::TimeDelta>& event, 33 const base::Optional<base::TimeDelta>& event,
33 const page_load_metrics::PageLoadExtraInfo& info) { 34 const page_load_metrics::PageLoadExtraInfo& info) {
34 return data && data->used_data_reduction_proxy() && 35 return data && data->used_data_reduction_proxy() &&
35 WasStartedInForegroundOptionalEventInForeground(event, info); 36 WasStartedInForegroundOptionalEventInForeground(event, info);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ChromeNavigationData* chrome_navigation_data = 104 ChromeNavigationData* chrome_navigation_data =
104 static_cast<ChromeNavigationData*>( 105 static_cast<ChromeNavigationData*>(
105 navigation_handle->GetNavigationData()); 106 navigation_handle->GetNavigationData());
106 if (!chrome_navigation_data) 107 if (!chrome_navigation_data)
107 return; 108 return;
108 data_reduction_proxy::DataReductionProxyData* data = 109 data_reduction_proxy::DataReductionProxyData* data =
109 chrome_navigation_data->GetDataReductionProxyData(); 110 chrome_navigation_data->GetDataReductionProxyData();
110 if (!data) 111 if (!data)
111 return; 112 return;
112 data_ = data->DeepCopy(); 113 data_ = data->DeepCopy();
114 // DataReductionProxy page loads should only occur on HTTP navigations.
115 DCHECK(!data_->used_data_reduction_proxy() ||
116 !navigation_handle->GetURL().SchemeIsCryptographic());
113 } 117 }
114 118
115 void DataReductionProxyMetricsObserver::OnComplete( 119 void DataReductionProxyMetricsObserver::OnComplete(
116 const page_load_metrics::PageLoadTiming& timing, 120 const page_load_metrics::PageLoadTiming& timing,
117 const page_load_metrics::PageLoadExtraInfo& info) { 121 const page_load_metrics::PageLoadExtraInfo& info) {
118 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast 122 // TODO(ryansturm): Move to OnFirstBackgroundEvent to handle some fast
119 // shutdown cases. crbug.com/618072 123 // shutdown cases. crbug.com/618072
120 if (!browser_context_) 124 if (!browser_context_)
121 return; 125 return;
122 if (!data_ || !data_->used_data_reduction_proxy()) 126 if (!data_ || !data_->used_data_reduction_proxy())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 216
213 DataReductionProxyPingbackClient* 217 DataReductionProxyPingbackClient*
214 DataReductionProxyMetricsObserver::GetPingbackClient() const { 218 DataReductionProxyMetricsObserver::GetPingbackClient() const {
215 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 219 return DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
216 browser_context_) 220 browser_context_)
217 ->data_reduction_proxy_service() 221 ->data_reduction_proxy_service()
218 ->pingback_client(); 222 ->pingback_client();
219 } 223 }
220 224
221 } // namespace data_reduction_proxy 225 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698