| OLD | NEW |
| 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_bypa
ss_stats.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
| 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
| 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
| 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" |
| 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
| 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 original_content_length_ += original_content_length; | 231 original_content_length_ += original_content_length; |
| 232 } | 232 } |
| 233 | 233 |
| 234 void DataReductionProxyNetworkDelegate::UpdateContentLengthPrefs( | 234 void DataReductionProxyNetworkDelegate::UpdateContentLengthPrefs( |
| 235 int received_content_length, | 235 int received_content_length, |
| 236 int original_content_length, | 236 int original_content_length, |
| 237 bool data_reduction_proxy_enabled, | 237 bool data_reduction_proxy_enabled, |
| 238 DataReductionProxyRequestType request_type) { | 238 DataReductionProxyRequestType request_type) { |
| 239 if (data_reduction_proxy_io_data_ && | 239 if (data_reduction_proxy_io_data_ && |
| 240 data_reduction_proxy_io_data_->service()) { | 240 data_reduction_proxy_io_data_->service()) { |
| 241 DataReductionProxyStatisticsPrefs* data_reduction_proxy_statistics_prefs = | 241 DataReductionProxyCompressionStats* data_reduction_proxy_compression_stats = |
| 242 data_reduction_proxy_io_data_->service()->statistics_prefs(); | 242 data_reduction_proxy_io_data_->service()->compression_stats(); |
| 243 int64 total_received = data_reduction_proxy_statistics_prefs->GetInt64( | 243 int64 total_received = data_reduction_proxy_compression_stats->GetInt64( |
| 244 data_reduction_proxy::prefs::kHttpReceivedContentLength); | 244 data_reduction_proxy::prefs::kHttpReceivedContentLength); |
| 245 int64 total_original = data_reduction_proxy_statistics_prefs->GetInt64( | 245 int64 total_original = data_reduction_proxy_compression_stats->GetInt64( |
| 246 data_reduction_proxy::prefs::kHttpOriginalContentLength); | 246 data_reduction_proxy::prefs::kHttpOriginalContentLength); |
| 247 total_received += received_content_length; | 247 total_received += received_content_length; |
| 248 total_original += original_content_length; | 248 total_original += original_content_length; |
| 249 data_reduction_proxy_statistics_prefs->SetInt64( | 249 data_reduction_proxy_compression_stats->SetInt64( |
| 250 data_reduction_proxy::prefs::kHttpReceivedContentLength, | 250 data_reduction_proxy::prefs::kHttpReceivedContentLength, |
| 251 total_received); | 251 total_received); |
| 252 data_reduction_proxy_statistics_prefs->SetInt64( | 252 data_reduction_proxy_compression_stats->SetInt64( |
| 253 data_reduction_proxy::prefs::kHttpOriginalContentLength, | 253 data_reduction_proxy::prefs::kHttpOriginalContentLength, |
| 254 total_original); | 254 total_original); |
| 255 | 255 |
| 256 UpdateContentLengthPrefsForDataReductionProxy( | 256 UpdateContentLengthPrefsForDataReductionProxy( |
| 257 received_content_length, | 257 received_content_length, |
| 258 original_content_length, | 258 original_content_length, |
| 259 data_reduction_proxy_enabled, | 259 data_reduction_proxy_enabled, |
| 260 request_type, | 260 request_type, |
| 261 base::Time::Now(), | 261 base::Time::Now(), |
| 262 data_reduction_proxy_statistics_prefs); | 262 data_reduction_proxy_compression_stats); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 void OnResolveProxyHandler(const GURL& url, | 266 void OnResolveProxyHandler(const GURL& url, |
| 267 int load_flags, | 267 int load_flags, |
| 268 const net::ProxyConfig& data_reduction_proxy_config, | 268 const net::ProxyConfig& data_reduction_proxy_config, |
| 269 const net::ProxyRetryInfoMap& proxy_retry_info, | 269 const net::ProxyRetryInfoMap& proxy_retry_info, |
| 270 const DataReductionProxyConfig* config, | 270 const DataReductionProxyConfig* config, |
| 271 net::ProxyInfo* result) { | 271 net::ProxyInfo* result) { |
| 272 DCHECK(config); | 272 DCHECK(config); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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 |
| OLD | NEW |