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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc

Issue 956223002: Rename DataReductionProxyUsageStats to DataReductionProxyBypassStats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa ss_stats.h"
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h" 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h"
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h" 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h" 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h"
18 #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"
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h" 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h"
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usag e_stats.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 "net/base/load_flags.h" 22 #include "net/base/load_flags.h"
23 #include "net/http/http_response_headers.h" 23 #include "net/http/http_response_headers.h"
24 #include "net/proxy/proxy_info.h" 24 #include "net/proxy/proxy_info.h"
25 #include "net/proxy/proxy_server.h" 25 #include "net/proxy/proxy_server.h"
26 #include "net/proxy/proxy_service.h" 26 #include "net/proxy/proxy_service.h"
27 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
28 #include "net/url_request/url_request_status.h" 28 #include "net/url_request/url_request_status.h"
29 29
30 namespace { 30 namespace {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 scoped_ptr<net::NetworkDelegate> network_delegate, 80 scoped_ptr<net::NetworkDelegate> network_delegate,
81 DataReductionProxyConfig* config, 81 DataReductionProxyConfig* config,
82 DataReductionProxyRequestOptions* request_options, 82 DataReductionProxyRequestOptions* request_options,
83 const DataReductionProxyConfigurator* configurator) 83 const DataReductionProxyConfigurator* configurator)
84 : LayeredNetworkDelegate(network_delegate.Pass()), 84 : LayeredNetworkDelegate(network_delegate.Pass()),
85 ui_task_runner_(NULL), 85 ui_task_runner_(NULL),
86 received_content_length_(0), 86 received_content_length_(0),
87 original_content_length_(0), 87 original_content_length_(0),
88 data_reduction_proxy_enabled_(NULL), 88 data_reduction_proxy_enabled_(NULL),
89 data_reduction_proxy_config_(config), 89 data_reduction_proxy_config_(config),
90 data_reduction_proxy_usage_stats_(NULL), 90 data_reduction_proxy_bypass_stats_(NULL),
91 data_reduction_proxy_request_options_(request_options), 91 data_reduction_proxy_request_options_(request_options),
92 configurator_(configurator) { 92 configurator_(configurator) {
93 DCHECK(data_reduction_proxy_config_); 93 DCHECK(data_reduction_proxy_config_);
94 DCHECK(data_reduction_proxy_request_options_); 94 DCHECK(data_reduction_proxy_request_options_);
95 } 95 }
96 96
97 DataReductionProxyNetworkDelegate::~DataReductionProxyNetworkDelegate() { 97 DataReductionProxyNetworkDelegate::~DataReductionProxyNetworkDelegate() {
98 } 98 }
99 99
100 void DataReductionProxyNetworkDelegate::InitIODataAndUMA( 100 void DataReductionProxyNetworkDelegate::InitIODataAndUMA(
101 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 101 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
102 DataReductionProxyIOData* io_data, 102 DataReductionProxyIOData* io_data,
103 BooleanPrefMember* data_reduction_proxy_enabled, 103 BooleanPrefMember* data_reduction_proxy_enabled,
104 DataReductionProxyUsageStats* usage_stats) { 104 DataReductionProxyBypassStats* bypass_stats) {
105 DCHECK(data_reduction_proxy_enabled); 105 DCHECK(data_reduction_proxy_enabled);
106 DCHECK(usage_stats); 106 DCHECK(bypass_stats);
107 ui_task_runner_ = ui_task_runner; 107 ui_task_runner_ = ui_task_runner;
108 data_reduction_proxy_io_data_ = io_data; 108 data_reduction_proxy_io_data_ = io_data;
109 data_reduction_proxy_enabled_ = data_reduction_proxy_enabled; 109 data_reduction_proxy_enabled_ = data_reduction_proxy_enabled;
110 data_reduction_proxy_usage_stats_ = usage_stats; 110 data_reduction_proxy_bypass_stats_ = bypass_stats;
111 } 111 }
112 112
113 base::Value* 113 base::Value*
114 DataReductionProxyNetworkDelegate::SessionNetworkStatsInfoToValue() const { 114 DataReductionProxyNetworkDelegate::SessionNetworkStatsInfoToValue() const {
115 base::DictionaryValue* dict = new base::DictionaryValue(); 115 base::DictionaryValue* dict = new base::DictionaryValue();
116 // Use strings to avoid overflow. base::Value only supports 32-bit integers. 116 // Use strings to avoid overflow. base::Value only supports 32-bit integers.
117 dict->SetString("session_received_content_length", 117 dict->SetString("session_received_content_length",
118 base::Int64ToString(received_content_length_)); 118 base::Int64ToString(received_content_length_));
119 dict->SetString("session_original_content_length", 119 dict->SetString("session_original_content_length",
120 base::Int64ToString(original_content_length_)); 120 base::Int64ToString(original_content_length_));
121 return dict; 121 return dict;
122 } 122 }
123 123
124 void DataReductionProxyNetworkDelegate::OnResolveProxyInternal( 124 void DataReductionProxyNetworkDelegate::OnResolveProxyInternal(
125 const GURL& url, 125 const GURL& url,
126 int load_flags, 126 int load_flags,
127 const net::ProxyService& proxy_service, 127 const net::ProxyService& proxy_service,
128 net::ProxyInfo* result) { 128 net::ProxyInfo* result) {
129 if (configurator_) { 129 if (configurator_) {
130 OnResolveProxyHandler( 130 OnResolveProxyHandler(
131 url, load_flags, configurator_->GetProxyConfigOnIOThread(), 131 url, load_flags, configurator_->GetProxyConfigOnIOThread(),
132 proxy_service.proxy_retry_info(), data_reduction_proxy_config_, result); 132 proxy_service.proxy_retry_info(), data_reduction_proxy_config_, result);
133 } 133 }
134 } 134 }
135 135
136 void DataReductionProxyNetworkDelegate::OnProxyFallbackInternal( 136 void DataReductionProxyNetworkDelegate::OnProxyFallbackInternal(
137 const net::ProxyServer& bad_proxy, 137 const net::ProxyServer& bad_proxy,
138 int net_error) { 138 int net_error) {
139 if (data_reduction_proxy_usage_stats_) { 139 if (data_reduction_proxy_bypass_stats_) {
140 data_reduction_proxy_usage_stats_->OnProxyFallback( 140 data_reduction_proxy_bypass_stats_->OnProxyFallback(
141 bad_proxy, net_error); 141 bad_proxy, net_error);
142 } 142 }
143 } 143 }
144 144
145 void DataReductionProxyNetworkDelegate::OnBeforeSendProxyHeadersInternal( 145 void DataReductionProxyNetworkDelegate::OnBeforeSendProxyHeadersInternal(
146 net::URLRequest* request, 146 net::URLRequest* request,
147 const net::ProxyInfo& proxy_info, 147 const net::ProxyInfo& proxy_info,
148 net::HttpRequestHeaders* headers) { 148 net::HttpRequestHeaders* headers) {
149 if (data_reduction_proxy_request_options_) { 149 if (data_reduction_proxy_request_options_) {
150 data_reduction_proxy_request_options_->MaybeAddRequestHeader( 150 data_reduction_proxy_request_options_->MaybeAddRequestHeader(
151 request, proxy_info.proxy_server(), headers); 151 request, proxy_info.proxy_server(), headers);
152 } 152 }
153 } 153 }
154 154
155 void DataReductionProxyNetworkDelegate::OnCompletedInternal( 155 void DataReductionProxyNetworkDelegate::OnCompletedInternal(
156 net::URLRequest* request, 156 net::URLRequest* request,
157 bool started) { 157 bool started) {
158 DCHECK(request); 158 DCHECK(request);
159 if (data_reduction_proxy_usage_stats_) 159 if (data_reduction_proxy_bypass_stats_)
160 data_reduction_proxy_usage_stats_->OnUrlRequestCompleted(request, started); 160 data_reduction_proxy_bypass_stats_->OnUrlRequestCompleted(request, started);
161 161
162 // Only record for http or https urls. 162 // Only record for http or https urls.
163 bool is_http = request->url().SchemeIs("http"); 163 bool is_http = request->url().SchemeIs("http");
164 bool is_https = request->url().SchemeIs("https"); 164 bool is_https = request->url().SchemeIs("https");
165 165
166 if (request->status().status() != net::URLRequestStatus::SUCCESS) 166 if (request->status().status() != net::URLRequestStatus::SUCCESS)
167 return; 167 return;
168 168
169 // For better accuracy, we use the actual bytes read instead of the length 169 // For better accuracy, we use the actual bytes read instead of the length
170 // specified with the Content-Length header, which may be inaccurate, 170 // specified with the Content-Length header, which may be inaccurate,
(...skipping 20 matching lines...) Expand all
191 original_content_length, 191 original_content_length,
192 received_content_length); 192 received_content_length);
193 AccumulateContentLength(received_content_length, 193 AccumulateContentLength(received_content_length,
194 adjusted_original_content_length, 194 adjusted_original_content_length,
195 request_type); 195 request_type);
196 RecordContentLengthHistograms(received_content_length, 196 RecordContentLengthHistograms(received_content_length,
197 original_content_length, 197 original_content_length,
198 freshness_lifetime); 198 freshness_lifetime);
199 199
200 if (data_reduction_proxy_enabled_ && 200 if (data_reduction_proxy_enabled_ &&
201 data_reduction_proxy_usage_stats_) { 201 data_reduction_proxy_bypass_stats_) {
202 data_reduction_proxy_usage_stats_->RecordBytesHistograms( 202 data_reduction_proxy_bypass_stats_->RecordBytesHistograms(
203 *request, 203 *request,
204 *data_reduction_proxy_enabled_, 204 *data_reduction_proxy_enabled_,
205 configurator_->GetProxyConfigOnIOThread()); 205 configurator_->GetProxyConfigOnIOThread());
206 } 206 }
207 DVLOG(2) << __FUNCTION__ 207 DVLOG(2) << __FUNCTION__
208 << " received content length: " << received_content_length 208 << " received content length: " << received_content_length
209 << " original content length: " << original_content_length 209 << " original content length: " << original_content_length
210 << " url: " << request->url(); 210 << " url: " << request->url();
211 } 211 }
212 } 212 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial()) { 289 DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial()) {
290 if (!result->is_empty() && !result->is_direct() && 290 if (!result->is_empty() && !result->is_direct() &&
291 config->IsDataReductionProxy(result->proxy_server().host_port_pair(), 291 config->IsDataReductionProxy(result->proxy_server().host_port_pair(),
292 NULL)) { 292 NULL)) {
293 result->RemoveProxiesWithoutScheme(net::ProxyServer::SCHEME_DIRECT); 293 result->RemoveProxiesWithoutScheme(net::ProxyServer::SCHEME_DIRECT);
294 } 294 }
295 } 295 }
296 } 296 }
297 297
298 } // namespace data_reduction_proxy 298 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698