Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc |
| index 462571bb41c905a94683626f9ba8f5b686b90238..9a5b92476939d1bf7bca0f06f7d51124d5fa31f2 100644 |
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc |
| @@ -1,60 +1,88 @@ |
| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h" |
| #include <cmath> |
| #include "base/metrics/sparse_histogram.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" |
| +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_creator.h" |
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" |
| #include "net/base/host_port_pair.h" |
| #include "net/http/http_request_headers.h" |
| #include "net/http/http_response_headers.h" |
| #include "net/proxy/proxy_server.h" |
| +#include "net/proxy/proxy_service.h" |
| namespace data_reduction_proxy { |
| DataReductionProxyDelegate::DataReductionProxyDelegate( |
| DataReductionProxyRequestOptions* request_options, |
| - DataReductionProxyConfig* config) |
| + DataReductionProxyConfig* config, |
| + const DataReductionProxyConfigurator* configurator, |
| + DataReductionProxyEventCreator* event_creator, |
| + DataReductionProxyBypassStats* bypass_stats, |
| + net::NetLog* net_log) |
| : request_options_(request_options), |
| - config_(config) { |
| + config_(config), |
| + configurator_(configurator), |
| + event_creator_(event_creator), |
| + bypass_stats_(bypass_stats), |
| + net_log_(net_log) { |
| DCHECK(request_options); |
| DCHECK(config); |
| + DCHECK(configurator); |
| + DCHECK(event_creator); |
| + DCHECK(bypass_stats); |
| + DCHECK(net_log); |
| } |
| DataReductionProxyDelegate::~DataReductionProxyDelegate() { |
| } |
| void DataReductionProxyDelegate::OnResolveProxy( |
| const GURL& url, |
| int load_flags, |
| const net::ProxyService& proxy_service, |
| net::ProxyInfo* result) { |
| + DCHECK(result); |
| + OnResolveProxyHandler(url, load_flags, configurator_->GetProxyConfig(), |
| + proxy_service.proxy_retry_info(), config_, result); |
| } |
| void DataReductionProxyDelegate::OnTunnelConnectCompleted( |
| const net::HostPortPair& endpoint, |
| const net::HostPortPair& proxy_server, |
| int net_error) { |
| if (config_->IsDataReductionProxy(proxy_server, NULL)) { |
| UMA_HISTOGRAM_SPARSE_SLOWLY("DataReductionProxy.HTTPConnectCompleted", |
| std::abs(net_error)); |
| } |
| } |
| void DataReductionProxyDelegate::OnFallback(const net::ProxyServer& bad_proxy, |
| int net_error) { |
| + if (bad_proxy.is_valid() && |
| + config_->IsDataReductionProxy(bad_proxy.host_port_pair(), nullptr)) { |
| + event_creator_->AddProxyFallbackEvent(net_log_, bad_proxy.ToURI(), |
| + net_error); |
| + } |
| + |
| + if (bypass_stats_) { |
|
bengr
2016/02/08 23:23:29
Remove curly braces.
RyanSturm
2016/02/09 00:46:02
Done.
|
| + bypass_stats_->OnProxyFallback(bad_proxy, net_error); |
| + } |
| } |
| void DataReductionProxyDelegate::OnBeforeSendHeaders( |
| net::URLRequest* request, |
| const net::ProxyInfo& proxy_info, |
| net::HttpRequestHeaders* headers) { |
| } |
| void DataReductionProxyDelegate::OnBeforeTunnelRequest( |
| const net::HostPortPair& proxy_server, |
| @@ -73,11 +101,33 @@ bool DataReductionProxyDelegate::IsTrustedSpdyProxy( |
| return config_ && |
| config_->IsDataReductionProxy(proxy_server.host_port_pair(), nullptr); |
| } |
| void DataReductionProxyDelegate::OnTunnelHeadersReceived( |
| const net::HostPortPair& origin, |
| const net::HostPortPair& proxy_server, |
| const net::HttpResponseHeaders& response_headers) { |
| } |
| +void OnResolveProxyHandler(const GURL& url, |
| + int load_flags, |
| + const net::ProxyConfig& data_reduction_proxy_config, |
| + const net::ProxyRetryInfoMap& proxy_retry_info, |
| + const DataReductionProxyConfig* config, |
| + net::ProxyInfo* result) { |
| + DCHECK(config); |
| + DCHECK(result->is_empty() || result->is_direct() || |
| + !config->IsDataReductionProxy(result->proxy_server().host_port_pair(), |
| + NULL)); |
| + if (data_reduction_proxy_config.is_valid() && |
|
bengr
2016/02/08 23:23:29
Suggestion: I know you copied and pasted, but I fi
RyanSturm
2016/02/09 00:46:02
Done.
|
| + result->proxy_server().is_direct() && result->proxy_list().size() == 1 && |
| + !url.SchemeIsWSOrWSS()) { |
| + net::ProxyInfo data_reduction_proxy_info; |
| + data_reduction_proxy_config.proxy_rules().Apply(url, |
| + &data_reduction_proxy_info); |
| + data_reduction_proxy_info.DeprioritizeBadProxies(proxy_retry_info); |
| + if (!data_reduction_proxy_info.proxy_server().is_direct()) |
| + result->OverrideProxyList(data_reduction_proxy_info.proxy_list()); |
| + } |
| +} |
| + |
| } // namespace data_reduction_proxy |