Commit a702da79 authored by rcs@chromium.org's avatar rcs@chromium.org

Add Finch experiment for selectively bypassing proxies.

Add option to bypass the data compression proxy if the request resource
type (as inferred by the renderer process) is not an image.

For background, see this design doc:

https://docs.google.com/a/google.com/document/d/1Kz92Fmw3lv_R-2aNvLp8jW9lkfKOZciTZtni2qQ_Adc/edit

BUG=391836

Review URL: https://codereview.chromium.org/332313003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281951 0039d316-1c4b-4281-b951-d872f2087c98
parent 30759127
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "dbus/bus.h" #include "dbus/bus.h"
#include "dbus/message.h" #include "dbus/message.h"
#include "dbus/exported_object.h" #include "dbus/exported_object.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/proxy/proxy_service.h" #include "net/proxy/proxy_service.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
...@@ -134,8 +135,8 @@ class ProxyResolverImpl : public ProxyResolverInterface { ...@@ -134,8 +135,8 @@ class ProxyResolverImpl : public ProxyResolverInterface {
VLOG(1) << "Starting network proxy resolution for " VLOG(1) << "Starting network proxy resolution for "
<< request->source_url_; << request->source_url_;
const int result = proxy_service->ResolveProxy( const int result = proxy_service->ResolveProxy(
GURL(request->source_url_), &request->proxy_info_, GURL(request->source_url_), net::LOAD_NORMAL, &request->proxy_info_,
request->callback_, NULL, net::BoundNetLog()); request->callback_, NULL, NULL, net::BoundNetLog());
if (result != net::ERR_IO_PENDING) { if (result != net::ERR_IO_PENDING) {
VLOG(1) << "Network proxy resolution completed synchronously."; VLOG(1) << "Network proxy resolution completed synchronously.";
request->OnCompletion(result); request->OnCompletion(result);
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#if defined(OS_ANDROID) || defined(OS_IOS) #if defined(OS_ANDROID) || defined(OS_IOS)
#include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h" #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.h" #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.h"
#endif #endif
...@@ -638,6 +639,9 @@ void IOThread::InitAsync() { ...@@ -638,6 +639,9 @@ void IOThread::InitAsync() {
globals_->data_reduction_proxy_params.reset(proxy_params); globals_->data_reduction_proxy_params.reset(proxy_params);
globals_->data_reduction_proxy_auth_request_handler.reset( globals_->data_reduction_proxy_auth_request_handler.reset(
new DataReductionProxyAuthRequestHandler(proxy_params)); new DataReductionProxyAuthRequestHandler(proxy_params));
globals_->on_resolve_proxy_handler =
ChromeNetworkDelegate::OnResolveProxyHandler(
base::Bind(data_reduction_proxy::OnResolveProxyHandler));
DataReductionProxyUsageStats* proxy_usage_stats = DataReductionProxyUsageStats* proxy_usage_stats =
new DataReductionProxyUsageStats(proxy_params, new DataReductionProxyUsageStats(proxy_params,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
...@@ -647,6 +651,8 @@ void IOThread::InitAsync() { ...@@ -647,6 +651,8 @@ void IOThread::InitAsync() {
network_delegate->set_data_reduction_proxy_usage_stats(proxy_usage_stats); network_delegate->set_data_reduction_proxy_usage_stats(proxy_usage_stats);
network_delegate->set_data_reduction_proxy_auth_request_handler( network_delegate->set_data_reduction_proxy_auth_request_handler(
globals_->data_reduction_proxy_auth_request_handler.get()); globals_->data_reduction_proxy_auth_request_handler.get());
network_delegate->set_on_resolve_proxy_handler(
globals_->on_resolve_proxy_handler);
#endif // defined(SPDY_PROXY_AUTH_ORIGIN) #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
#endif // defined(OS_ANDROID) || defined(OS_IOS) #endif // defined(OS_ANDROID) || defined(OS_IOS)
globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory(
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/prefs/pref_member.h" #include "base/prefs/pref_member.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/ssl_config_service_manager.h" #include "chrome/browser/net/ssl_config_service_manager.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h" #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
...@@ -196,6 +197,7 @@ class IOThread : public content::BrowserThreadDelegate { ...@@ -196,6 +197,7 @@ class IOThread : public content::BrowserThreadDelegate {
data_reduction_proxy_usage_stats; data_reduction_proxy_usage_stats;
scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler> scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler>
data_reduction_proxy_auth_request_handler; data_reduction_proxy_auth_request_handler;
ChromeNetworkDelegate::OnResolveProxyHandler on_resolve_proxy_handler;
}; };
// |net_log| must either outlive the IOThread or be NULL. // |net_log| must either outlive the IOThread or be NULL.
......
...@@ -475,6 +475,14 @@ int ChromeNetworkDelegate::OnBeforeURLRequest( ...@@ -475,6 +475,14 @@ int ChromeNetworkDelegate::OnBeforeURLRequest(
return rv; return rv;
} }
void ChromeNetworkDelegate::OnResolveProxy(
const GURL& url, int load_flags, net::ProxyInfo* result) {
if (!on_resolve_proxy_handler_.is_null()) {
on_resolve_proxy_handler_.Run(url, load_flags,
data_reduction_proxy_params_, result);
}
}
int ChromeNetworkDelegate::OnBeforeSendHeaders( int ChromeNetworkDelegate::OnBeforeSendHeaders(
net::URLRequest* request, net::URLRequest* request,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
......
...@@ -66,6 +66,15 @@ class PrerenderTracker; ...@@ -66,6 +66,15 @@ class PrerenderTracker;
// add hooks into the network stack. // add hooks into the network stack.
class ChromeNetworkDelegate : public net::NetworkDelegate { class ChromeNetworkDelegate : public net::NetworkDelegate {
public: public:
// Provides an opportunity to interpose on proxy resolution. Called before
// ProxyService.ResolveProxy() returns. |proxy_info| contains information
// about the proxy being used, and may be modified by this callback.
typedef base::Callback<void(
const GURL& url,
int load_flags,
const data_reduction_proxy::DataReductionProxyParams* params,
net::ProxyInfo* result)> OnResolveProxyHandler;
// |enable_referrers| (and all of the other optional PrefMembers) should be // |enable_referrers| (and all of the other optional PrefMembers) should be
// initialized on the UI thread (see below) beforehand. This object's owner is // initialized on the UI thread (see below) beforehand. This object's owner is
// responsible for cleaning them up at shutdown. // responsible for cleaning them up at shutdown.
...@@ -142,6 +151,10 @@ class ChromeNetworkDelegate : public net::NetworkDelegate { ...@@ -142,6 +151,10 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
data_reduction_proxy_auth_request_handler_ = handler; data_reduction_proxy_auth_request_handler_ = handler;
} }
void set_on_resolve_proxy_handler(OnResolveProxyHandler handler) {
on_resolve_proxy_handler_ = handler;
}
// Adds the Client Hints header to HTTP requests. // Adds the Client Hints header to HTTP requests.
void SetEnableClientHints(); void SetEnableClientHints();
...@@ -178,6 +191,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegate { ...@@ -178,6 +191,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
virtual int OnBeforeURLRequest(net::URLRequest* request, virtual int OnBeforeURLRequest(net::URLRequest* request,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
GURL* new_url) OVERRIDE; GURL* new_url) OVERRIDE;
virtual void OnResolveProxy(
const GURL& url, int load_flags, net::ProxyInfo* result) OVERRIDE;
virtual int OnBeforeSendHeaders(net::URLRequest* request, virtual int OnBeforeSendHeaders(net::URLRequest* request,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) OVERRIDE; net::HttpRequestHeaders* headers) OVERRIDE;
...@@ -280,6 +295,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegate { ...@@ -280,6 +295,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
data_reduction_proxy::DataReductionProxyAuthRequestHandler* data_reduction_proxy::DataReductionProxyAuthRequestHandler*
data_reduction_proxy_auth_request_handler_; data_reduction_proxy_auth_request_handler_;
OnResolveProxyHandler on_resolve_proxy_handler_;
DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate); DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate);
}; };
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/common/chrome_version_info.h" #include "chrome/common/chrome_version_info.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
#include "net/base/test_completion_callback.h" #include "net/base/test_completion_callback.h"
...@@ -820,10 +821,12 @@ void ProxyDetector::StartResolveProxy() { ...@@ -820,10 +821,12 @@ void ProxyDetector::StartResolveProxy() {
DCHECK(proxy_service_); DCHECK(proxy_service_);
int rv = proxy_service_->ResolveProxy( int rv = proxy_service_->ResolveProxy(
gurl, gurl,
net::LOAD_NORMAL,
&proxy_info_, &proxy_info_,
base::Bind(&ProxyDetector::OnResolveProxyComplete, base::Bind(&ProxyDetector::OnResolveProxyComplete,
base::Unretained(this)), base::Unretained(this)),
NULL, NULL,
NULL,
net::BoundNetLog()); net::BoundNetLog());
if (rv != net::ERR_IO_PENDING) if (rv != net::ERR_IO_PENDING)
OnResolveProxyComplete(rv); OnResolveProxyComplete(rv);
......
...@@ -995,6 +995,8 @@ void ProfileIOData::Init( ...@@ -995,6 +995,8 @@ void ProfileIOData::Init(
io_thread_globals->data_reduction_proxy_usage_stats.get()); io_thread_globals->data_reduction_proxy_usage_stats.get());
network_delegate->set_data_reduction_proxy_auth_request_handler( network_delegate->set_data_reduction_proxy_auth_request_handler(
io_thread_globals->data_reduction_proxy_auth_request_handler.get()); io_thread_globals->data_reduction_proxy_auth_request_handler.get());
network_delegate->set_on_resolve_proxy_handler(
io_thread_globals->on_resolve_proxy_handler);
if (command_line.HasSwitch(switches::kEnableClientHints)) if (command_line.HasSwitch(switches::kEnableClientHints))
network_delegate->SetEnableClientHints(); network_delegate->SetEnableClientHints();
network_delegate->set_extension_info_map( network_delegate->set_extension_info_map(
......
...@@ -45,6 +45,13 @@ bool DataReductionProxyParams::IsIncludedInPreconnectHintingFieldTrial() { ...@@ -45,6 +45,13 @@ bool DataReductionProxyParams::IsIncludedInPreconnectHintingFieldTrial() {
"DataCompressionProxyPreconnectHints") == kEnabled; "DataCompressionProxyPreconnectHints") == kEnabled;
} }
// static
bool DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() {
return IsIncludedInFieldTrial() &&
FieldTrialList::FindFullName(
"DataCompressionProxyCriticalBypass") == kEnabled;
}
DataReductionProxyParams::DataReductionProxyParams(int flags) DataReductionProxyParams::DataReductionProxyParams(int flags)
: allowed_((flags & kAllowed) == kAllowed), : allowed_((flags & kAllowed) == kAllowed),
fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed), fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
......
...@@ -47,6 +47,10 @@ class DataReductionProxyParams { ...@@ -47,6 +47,10 @@ class DataReductionProxyParams {
// hinting. // hinting.
static bool IsIncludedInPreconnectHintingFieldTrial(); static bool IsIncludedInPreconnectHintingFieldTrial();
// Returns true if this client is part of a field trial that bypasses the
// proxy if the request resource type is on the critical path (e.g. HTML).
static bool IsIncludedInCriticalPathBypassFieldTrial();
// Constructs configuration parameters. If |kAllowed|, then the standard // Constructs configuration parameters. If |kAllowed|, then the standard
// data reduction proxy configuration is allowed to be used. If // data reduction proxy configuration is allowed to be used. If
// |kfallbackAllowed| a fallback proxy can be used if the primary proxy is // |kfallbackAllowed| a fallback proxy can be used if the primary proxy is
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "url/gurl.h" #include "url/gurl.h"
namespace { namespace {
bool SetProxyServerFromGURL(const GURL& gurl, bool SetProxyServerFromGURL(const GURL& gurl,
net::ProxyServer* proxy_server) { net::ProxyServer* proxy_server) {
DCHECK(proxy_server); DCHECK(proxy_server);
...@@ -30,6 +31,7 @@ bool SetProxyServerFromGURL(const GURL& gurl, ...@@ -30,6 +31,7 @@ bool SetProxyServerFromGURL(const GURL& gurl,
net::HostPortPair::FromURL(gurl)); net::HostPortPair::FromURL(gurl));
return true; return true;
} }
} // namespace } // namespace
namespace data_reduction_proxy { namespace data_reduction_proxy {
...@@ -88,7 +90,20 @@ bool MaybeBypassProxyAndPrepareToRetry( ...@@ -88,7 +90,20 @@ bool MaybeBypassProxyAndPrepareToRetry(
return true; return true;
} }
void OnResolveProxyHandler(const GURL& url,
int load_flags,
const DataReductionProxyParams* params,
net::ProxyInfo* result) {
if ((load_flags & net::LOAD_BYPASS_DATA_REDUCTION_PROXY) &&
DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() &&
!result->is_empty() &&
!result->is_direct() &&
params &&
params->IsDataReductionProxy(
result->proxy_server().host_port_pair(), NULL)) {
result->UseDirect();
}
}
bool IsRequestIdempotent(const net::URLRequest* request) { bool IsRequestIdempotent(const net::URLRequest* request) {
DCHECK(request); DCHECK(request);
......
...@@ -14,6 +14,7 @@ class TimeDelta; ...@@ -14,6 +14,7 @@ class TimeDelta;
namespace net { namespace net {
class HttpResponseHeaders; class HttpResponseHeaders;
class ProxyInfo;
class ProxyServer; class ProxyServer;
class URLRequest; class URLRequest;
} }
...@@ -33,6 +34,17 @@ bool MaybeBypassProxyAndPrepareToRetry( ...@@ -33,6 +34,17 @@ bool MaybeBypassProxyAndPrepareToRetry(
const net::HttpResponseHeaders* original_response_headers, const net::HttpResponseHeaders* original_response_headers,
scoped_refptr<net::HttpResponseHeaders>* override_response_headers); scoped_refptr<net::HttpResponseHeaders>* override_response_headers);
// Configure |result| to proceed directly to the origin if |result|'s current
// proxy is the data reduction proxy, the
// |net::LOAD_BYPASS_DATA_REDUCTION_PROXY| |load_flag| is set, and the
// DataCompressionProxyCriticalBypass Finch trial is set.
// This handler is intended to be invoked only by
// |ChromeNetworkDelegate.NotifyResolveProxy|.
void OnResolveProxyHandler(const GURL& url,
int load_flags,
const DataReductionProxyParams* params,
net::ProxyInfo* result);
// Returns true if the request method is idempotent. Only idempotent requests // Returns true if the request method is idempotent. Only idempotent requests
// are retried on a bypass. Visible as part of the public API for testing. // are retried on a bypass. Visible as part of the public API for testing.
bool IsRequestIdempotent(const net::URLRequest* request); bool IsRequestIdempotent(const net::URLRequest* request);
......
...@@ -8,14 +8,17 @@ ...@@ -8,14 +8,17 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h" #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/host_port_pair.h" #include "net/base/host_port_pair.h"
#include "net/base/load_flags.h"
#include "net/base/network_delegate.h" #include "net/base/network_delegate.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/http/http_transaction_test_util.h" #include "net/http/http_transaction_test_util.h"
#include "net/proxy/proxy_service.h"
#include "net/socket/socket_test_util.h" #include "net/socket/socket_test_util.h"
#include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
...@@ -611,4 +614,80 @@ TEST_F(DataReductionProxyProtocolTest, ...@@ -611,4 +614,80 @@ TEST_F(DataReductionProxyProtocolTest,
TestBadProxies(0, -1, "", ""); TestBadProxies(0, -1, "", "");
} }
class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
public:
virtual ~BadEntropyProvider() {}
virtual double GetEntropyForTrial(const std::string& trial_name,
uint32 randomization_seed) const OVERRIDE {
return 0.5;
}
};
TEST_F(DataReductionProxyProtocolTest, OnResolveProxyHandler) {
int load_flags = net::LOAD_NORMAL;
GURL url("http://www.google.com/");
TestDataReductionProxyParams test_params(
DataReductionProxyParams::kAllowed |
DataReductionProxyParams::kFallbackAllowed |
DataReductionProxyParams::kPromoAllowed,
TestDataReductionProxyParams::HAS_EVERYTHING &
~TestDataReductionProxyParams::HAS_DEV_ORIGIN);
// Data reduction proxy
net::ProxyInfo info1;
std::string data_reduction_proxy;
base::TrimString(test_params.DefaultOrigin(), "/", &data_reduction_proxy);
info1.UseNamedProxy(data_reduction_proxy);
EXPECT_FALSE(info1.is_empty());
// Other proxy
net::ProxyInfo info2;
info2.UseNamedProxy("proxy.com");
EXPECT_FALSE(info2.is_empty());
// Without DataCompressionProxyCriticalBypass Finch trial set, should never
// bypass.
OnResolveProxyHandler(url, load_flags, &test_params, &info1);
EXPECT_FALSE(info1.is_direct());
OnResolveProxyHandler(url, load_flags, &test_params,&info2);
EXPECT_FALSE(info2.is_direct());
load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
OnResolveProxyHandler(url, load_flags, &test_params, &info1);
EXPECT_FALSE(info1.is_direct());
OnResolveProxyHandler(url, load_flags, &test_params, &info2);
EXPECT_FALSE(info2.is_direct());
// With Finch trial set, should only bypass if LOAD flag is set and the
// effective proxy is the data compression proxy.
base::FieldTrialList field_trial_list(new BadEntropyProvider());
base::FieldTrialList::CreateFieldTrial("DataCompressionProxyRollout",
"Enabled");
base::FieldTrialList::CreateFieldTrial("DataCompressionProxyCriticalBypass",
"Enabled");
EXPECT_TRUE(
DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial());
load_flags = net::LOAD_NORMAL;
OnResolveProxyHandler(url, load_flags, &test_params, &info1);
EXPECT_FALSE(info1.is_direct());
OnResolveProxyHandler(url, load_flags, &test_params, &info2);
EXPECT_FALSE(info2.is_direct());
load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
OnResolveProxyHandler(url, load_flags, &test_params, &info2);
EXPECT_FALSE(info2.is_direct());
OnResolveProxyHandler(url, load_flags, &test_params, &info1);
EXPECT_TRUE(info1.is_direct());
}
} // namespace data_reduction_proxy } // namespace data_reduction_proxy
...@@ -1987,6 +1987,11 @@ int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest( ...@@ -1987,6 +1987,11 @@ int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest(
load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
} }
// Add a flag to selectively bypass the data reduction proxy if the resource
// type is not an image.
if (request_data.resource_type != ResourceType::IMAGE)
load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
return load_flags; return load_flags;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/socket_permission_request.h" #include "content/public/common/socket_permission_request.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/proxy/proxy_info.h" #include "net/proxy/proxy_info.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
...@@ -145,9 +146,11 @@ void PepperNetworkProxyHost::TryToSendUnsentRequests() { ...@@ -145,9 +146,11 @@ void PepperNetworkProxyHost::TryToSendUnsentRequests() {
request.reply_context, request.reply_context,
base::Owned(proxy_info)); base::Owned(proxy_info));
int result = proxy_service_->ResolveProxy(request.url, int result = proxy_service_->ResolveProxy(request.url,
net::LOAD_NORMAL,
proxy_info, proxy_info,
callback, callback,
&pending_request, &pending_request,
NULL,
net::BoundNetLog()); net::BoundNetLog());
pending_requests_.push(pending_request); pending_requests_.push(pending_request);
// If it was handled synchronously, we must run the callback now; // If it was handled synchronously, we must run the callback now;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
...@@ -91,10 +92,10 @@ void ResolveProxyMsgHelper::StartPendingRequest() { ...@@ -91,10 +92,10 @@ void ResolveProxyMsgHelper::StartPendingRequest() {
// Start the request. // Start the request.
int result = proxy_service_->ResolveProxy( int result = proxy_service_->ResolveProxy(
req.url, &proxy_info_, req.url, net::LOAD_NORMAL, &proxy_info_,
base::Bind(&ResolveProxyMsgHelper::OnResolveProxyCompleted, base::Bind(&ResolveProxyMsgHelper::OnResolveProxyCompleted,
base::Unretained(this)), base::Unretained(this)),
&req.pac_req, net::BoundNetLog()); &req.pac_req, NULL, net::BoundNetLog());
// Completed synchronously. // Completed synchronously.
if (result != net::ERR_IO_PENDING) if (result != net::ERR_IO_PENDING)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "google_apis/gcm/engine/connection_handler_impl.h" #include "google_apis/gcm/engine/connection_handler_impl.h"
#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
#include "google_apis/gcm/protocol/mcs.pb.h" #include "google_apis/gcm/protocol/mcs.pb.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_network_session.h" #include "net/http/http_network_session.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
...@@ -280,10 +281,12 @@ void ConnectionFactoryImpl::ConnectImpl() { ...@@ -280,10 +281,12 @@ void ConnectionFactoryImpl::ConnectImpl() {
recorder_->RecordConnectionInitiated(current_endpoint.host()); recorder_->RecordConnectionInitiated(current_endpoint.host());
int status = network_session_->proxy_service()->ResolveProxy( int status = network_session_->proxy_service()->ResolveProxy(
current_endpoint, current_endpoint,
net::LOAD_NORMAL,
&proxy_info_, &proxy_info_,
base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
&pac_request_, &pac_request_,
NULL,
bound_net_log_); bound_net_log_);
if (status != net::ERR_IO_PENDING) if (status != net::ERR_IO_PENDING)
OnProxyResolveDone(status); OnProxyResolveDone(status);
...@@ -497,10 +500,11 @@ int ConnectionFactoryImpl::ReconsiderProxyAfterError(int error) { ...@@ -497,10 +500,11 @@ int ConnectionFactoryImpl::ReconsiderProxyAfterError(int error) {
} }
int status = network_session_->proxy_service()->ReconsiderProxyAfterError( int status = network_session_->proxy_service()->ReconsiderProxyAfterError(
GetCurrentEndpoint(), error, &proxy_info_, GetCurrentEndpoint(), net::LOAD_NORMAL, error, &proxy_info_,
base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
&pac_request_, &pac_request_,
NULL,
bound_net_log_); bound_net_log_);
if (status == net::OK || status == net::ERR_IO_PENDING) { if (status == net::OK || status == net::ERR_IO_PENDING) {
CloseSocket(); CloseSocket();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/logging.h" #include "base/logging.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/http/http_network_session.h" #include "net/http/http_network_session.h"
#include "net/socket/client_socket_handle.h" #include "net/socket/client_socket_handle.h"
...@@ -137,9 +138,11 @@ int ProxyResolvingClientSocket::Connect( ...@@ -137,9 +138,11 @@ int ProxyResolvingClientSocket::Connect(
// First we try and resolve the proxy. // First we try and resolve the proxy.
int status = network_session_->proxy_service()->ResolveProxy( int status = network_session_->proxy_service()->ResolveProxy(
proxy_url_, proxy_url_,
net::LOAD_NORMAL,
&proxy_info_, &proxy_info_,
proxy_resolve_callback_, proxy_resolve_callback_,
&pac_request_, &pac_request_,
NULL,
bound_net_log_); bound_net_log_);
if (status != net::ERR_IO_PENDING) { if (status != net::ERR_IO_PENDING) {
// We defer execution of ProcessProxyResolveDone instead of calling it // We defer execution of ProcessProxyResolveDone instead of calling it
...@@ -277,8 +280,8 @@ int ProxyResolvingClientSocket::ReconsiderProxyAfterError(int error) { ...@@ -277,8 +280,8 @@ int ProxyResolvingClientSocket::ReconsiderProxyAfterError(int error) {
} }
int rv = network_session_->proxy_service()->ReconsiderProxyAfterError( int rv = network_session_->proxy_service()->ReconsiderProxyAfterError(
proxy_url_, error, &proxy_info_, proxy_resolve_callback_, &pac_request_, proxy_url_, net::LOAD_NORMAL, error, &proxy_info_,
bound_net_log_); proxy_resolve_callback_, &pac_request_, NULL, bound_net_log_);
if (rv == net::OK || rv == net::ERR_IO_PENDING) { if (rv == net::OK || rv == net::ERR_IO_PENDING) {
CloseTransportSocket(); CloseTransportSocket();
} else { } else {
......
...@@ -124,3 +124,7 @@ LOAD_FLAG(MAYBE_USER_GESTURE, 1 << 27) ...@@ -124,3 +124,7 @@ LOAD_FLAG(MAYBE_USER_GESTURE, 1 << 27)
// be honored, but that other forms of authority may be used. // be honored, but that other forms of authority may be used.
LOAD_FLAG(DO_NOT_USE_EMBEDDED_IDENTITY, 1 << 28) LOAD_FLAG(DO_NOT_USE_EMBEDDED_IDENTITY, 1 << 28)
// Send request directly to the origin if the effective proxy is the data
// reduction proxy.
// TODO(rcs): Remove this flag as soon as http://crbug.com/339237 is resolved.
LOAD_FLAG(BYPASS_DATA_REDUCTION_PROXY, 1 << 29)
...@@ -21,6 +21,13 @@ int NetworkDelegate::NotifyBeforeURLRequest( ...@@ -21,6 +21,13 @@ int NetworkDelegate::NotifyBeforeURLRequest(
return OnBeforeURLRequest(request, callback, new_url); return OnBeforeURLRequest(request, callback, new_url);
} }
void NetworkDelegate::NotifyResolveProxy(const GURL& url, int load_flags,
ProxyInfo* result) {
DCHECK(CalledOnValidThread());
DCHECK(result);
OnResolveProxy(url, load_flags, result);
}
int NetworkDelegate::NotifyBeforeSendHeaders( int NetworkDelegate::NotifyBeforeSendHeaders(
URLRequest* request, const CompletionCallback& callback, URLRequest* request, const CompletionCallback& callback,
HttpRequestHeaders* headers) { HttpRequestHeaders* headers) {
...@@ -155,6 +162,10 @@ int NetworkDelegate::OnBeforeURLRequest(URLRequest* request, ...@@ -155,6 +162,10 @@ int NetworkDelegate::OnBeforeURLRequest(URLRequest* request,
return OK; return OK;
} }
void NetworkDelegate::OnResolveProxy(const GURL& url, int load_flags,
ProxyInfo* result) {
}
int NetworkDelegate::OnBeforeSendHeaders(URLRequest* request, int NetworkDelegate::OnBeforeSendHeaders(URLRequest* request,
const CompletionCallback& callback, const CompletionCallback& callback,
HttpRequestHeaders* headers) { HttpRequestHeaders* headers) {
......
...@@ -61,6 +61,8 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { ...@@ -61,6 +61,8 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
int NotifyBeforeURLRequest(URLRequest* request, int NotifyBeforeURLRequest(URLRequest* request,
const CompletionCallback& callback, const CompletionCallback& callback,
GURL* new_url); GURL* new_url);
void NotifyResolveProxy(const GURL& url, int load_flags,
ProxyInfo* result);
int NotifyBeforeSendHeaders(URLRequest* request, int NotifyBeforeSendHeaders(URLRequest* request,
const CompletionCallback& callback, const CompletionCallback& callback,
HttpRequestHeaders* headers); HttpRequestHeaders* headers);
...@@ -121,6 +123,13 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { ...@@ -121,6 +123,13 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
const CompletionCallback& callback, const CompletionCallback& callback,
GURL* new_url); GURL* new_url);
// Called as the proxy is being resolved for |url|. Allows the delegate to
// override the proxy resolution decision made by ProxyService. The delegate
// may override the decision by modifying the ProxyInfo |result|.
virtual void OnResolveProxy(const GURL& url,
int load_flags,
ProxyInfo* result);
// Called right before the HTTP headers are sent. Allows the delegate to // Called right before the HTTP headers are sent. Allows the delegate to
// read/write |headers| before they get sent out. |callback| and |headers| are // read/write |headers| before they get sent out. |callback| and |headers| are
// valid only until OnCompleted or OnURLRequestDestroyed is called for this // valid only until OnCompleted or OnURLRequestDestroyed is called for this
......
...@@ -652,6 +652,7 @@ int HttpStreamFactoryImpl::Job::DoStart() { ...@@ -652,6 +652,7 @@ int HttpStreamFactoryImpl::Job::DoStart() {
int HttpStreamFactoryImpl::Job::DoResolveProxy() { int HttpStreamFactoryImpl::Job::DoResolveProxy() {
DCHECK(!pac_request_); DCHECK(!pac_request_);
DCHECK(session_);
next_state_ = STATE_RESOLVE_PROXY_COMPLETE; next_state_ = STATE_RESOLVE_PROXY_COMPLETE;
...@@ -661,7 +662,8 @@ int HttpStreamFactoryImpl::Job::DoResolveProxy() { ...@@ -661,7 +662,8 @@ int HttpStreamFactoryImpl::Job::DoResolveProxy() {
} }
return session_->proxy_service()->ResolveProxy( return session_->proxy_service()->ResolveProxy(
request_info_.url, &proxy_info_, io_callback_, &pac_request_, net_log_); request_info_.url, request_info_.load_flags, &proxy_info_, io_callback_,
&pac_request_, session_->network_delegate(), net_log_);
} }
int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) { int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) {
...@@ -1268,6 +1270,7 @@ void HttpStreamFactoryImpl::Job::InitSSLConfig( ...@@ -1268,6 +1270,7 @@ void HttpStreamFactoryImpl::Job::InitSSLConfig(
int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) { int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) {
DCHECK(!pac_request_); DCHECK(!pac_request_);
DCHECK(session_);
// A failure to resolve the hostname or any error related to establishing a // A failure to resolve the hostname or any error related to establishing a
// TCP connection could be grounds for trying a new proxy configuration. // TCP connection could be grounds for trying a new proxy configuration.
...@@ -1321,8 +1324,8 @@ int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) { ...@@ -1321,8 +1324,8 @@ int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) {
} }
int rv = session_->proxy_service()->ReconsiderProxyAfterError( int rv = session_->proxy_service()->ReconsiderProxyAfterError(
request_info_.url, error, &proxy_info_, io_callback_, &pac_request_, request_info_.url, request_info_.load_flags, error, &proxy_info_,
net_log_); io_callback_, &pac_request_, session_->network_delegate(), net_log_);
if (rv == OK || rv == ERR_IO_PENDING) { if (rv == OK || rv == ERR_IO_PENDING) {
// If the error was during connection setup, there is no socket to // If the error was during connection setup, there is no socket to
// disconnect. // disconnect.
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/thread_task_runner_handle.h" #include "base/thread_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/base/net_log.h" #include "net/base/net_log.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
...@@ -734,6 +735,8 @@ class ProxyService::PacRequest ...@@ -734,6 +735,8 @@ class ProxyService::PacRequest
public: public:
PacRequest(ProxyService* service, PacRequest(ProxyService* service,
const GURL& url, const GURL& url,
int load_flags,
NetworkDelegate* network_delegate,
ProxyInfo* results, ProxyInfo* results,
const net::CompletionCallback& user_callback, const net::CompletionCallback& user_callback,
const BoundNetLog& net_log) const BoundNetLog& net_log)
...@@ -741,6 +744,8 @@ class ProxyService::PacRequest ...@@ -741,6 +744,8 @@ class ProxyService::PacRequest
user_callback_(user_callback), user_callback_(user_callback),
results_(results), results_(results),
url_(url), url_(url),
load_flags_(load_flags),
network_delegate_(network_delegate),
resolve_job_(NULL), resolve_job_(NULL),
config_id_(ProxyConfig::kInvalidConfigID), config_id_(ProxyConfig::kInvalidConfigID),
config_source_(PROXY_CONFIG_SOURCE_UNKNOWN), config_source_(PROXY_CONFIG_SOURCE_UNKNOWN),
...@@ -771,7 +776,8 @@ class ProxyService::PacRequest ...@@ -771,7 +776,8 @@ class ProxyService::PacRequest
} }
void StartAndCompleteCheckingForSynchronous() { void StartAndCompleteCheckingForSynchronous() {
int rv = service_->TryToCompleteSynchronously(url_, results_); int rv = service_->TryToCompleteSynchronously(url_, load_flags_,
network_delegate_, results_);
if (rv == ERR_IO_PENDING) if (rv == ERR_IO_PENDING)
rv = Start(); rv = Start();
if (rv != ERR_IO_PENDING) if (rv != ERR_IO_PENDING)
...@@ -811,7 +817,9 @@ class ProxyService::PacRequest ...@@ -811,7 +817,9 @@ class ProxyService::PacRequest
DCHECK(!was_cancelled()); DCHECK(!was_cancelled());
// Note that DidFinishResolvingProxy might modify |results_|. // Note that DidFinishResolvingProxy might modify |results_|.
int rv = service_->DidFinishResolvingProxy(results_, result_code, net_log_); int rv = service_->DidFinishResolvingProxy(url_, load_flags_,
network_delegate_, results_,
result_code, net_log_);
// Make a note in the results which configuration was in use at the // Make a note in the results which configuration was in use at the
// time of the resolve. // time of the resolve.
...@@ -864,6 +872,8 @@ class ProxyService::PacRequest ...@@ -864,6 +872,8 @@ class ProxyService::PacRequest
net::CompletionCallback user_callback_; net::CompletionCallback user_callback_;
ProxyInfo* results_; ProxyInfo* results_;
GURL url_; GURL url_;
int load_flags_;
NetworkDelegate* network_delegate_;
ProxyResolver::RequestHandle resolve_job_; ProxyResolver::RequestHandle resolve_job_;
ProxyConfig::ID config_id_; // The config id when the resolve was started. ProxyConfig::ID config_id_; // The config id when the resolve was started.
ProxyConfigSource config_source_; // The source of proxy settings. ProxyConfigSource config_source_; // The source of proxy settings.
...@@ -880,7 +890,7 @@ ProxyService::ProxyService(ProxyConfigService* config_service, ...@@ -880,7 +890,7 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
NetLog* net_log) NetLog* net_log)
: resolver_(resolver), : resolver_(resolver),
next_config_id_(1), next_config_id_(1),
current_state_(STATE_NONE) , current_state_(STATE_NONE),
net_log_(net_log), net_log_(net_log),
stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds( stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds(
kDelayAfterNetworkChangesMs)), kDelayAfterNetworkChangesMs)),
...@@ -965,9 +975,11 @@ ProxyService* ProxyService::CreateFixedFromPacResult( ...@@ -965,9 +975,11 @@ ProxyService* ProxyService::CreateFixedFromPacResult(
} }
int ProxyService::ResolveProxy(const GURL& raw_url, int ProxyService::ResolveProxy(const GURL& raw_url,
int load_flags,
ProxyInfo* result, ProxyInfo* result,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
PacRequest** pac_request, PacRequest** pac_request,
NetworkDelegate* network_delegate,
const BoundNetLog& net_log) { const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
...@@ -989,12 +1001,15 @@ int ProxyService::ResolveProxy(const GURL& raw_url, ...@@ -989,12 +1001,15 @@ int ProxyService::ResolveProxy(const GURL& raw_url,
// Check if the request can be completed right away. (This is the case when // Check if the request can be completed right away. (This is the case when
// using a direct connection for example). // using a direct connection for example).
int rv = TryToCompleteSynchronously(url, result); int rv = TryToCompleteSynchronously(url, load_flags,
network_delegate, result);
if (rv != ERR_IO_PENDING) if (rv != ERR_IO_PENDING)
return DidFinishResolvingProxy(result, rv, net_log); return DidFinishResolvingProxy(url, load_flags, network_delegate,
result, rv, net_log);
scoped_refptr<PacRequest> req( scoped_refptr<PacRequest> req(
new PacRequest(this, url, result, callback, net_log)); new PacRequest(this, url, load_flags, network_delegate,
result, callback, net_log));
if (current_state_ == STATE_READY) { if (current_state_ == STATE_READY) {
// Start the resolve request. // Start the resolve request.
...@@ -1017,6 +1032,8 @@ int ProxyService::ResolveProxy(const GURL& raw_url, ...@@ -1017,6 +1032,8 @@ int ProxyService::ResolveProxy(const GURL& raw_url,
} }
int ProxyService::TryToCompleteSynchronously(const GURL& url, int ProxyService::TryToCompleteSynchronously(const GURL& url,
int load_flags,
NetworkDelegate* network_delegate,
ProxyInfo* result) { ProxyInfo* result) {
DCHECK_NE(STATE_NONE, current_state_); DCHECK_NE(STATE_NONE, current_state_);
...@@ -1037,6 +1054,7 @@ int ProxyService::TryToCompleteSynchronously(const GURL& url, ...@@ -1037,6 +1054,7 @@ int ProxyService::TryToCompleteSynchronously(const GURL& url,
config_.proxy_rules().Apply(url, result); config_.proxy_rules().Apply(url, result);
result->config_source_ = config_.source(); result->config_source_ = config_.source();
result->config_id_ = config_.id(); result->config_id_ = config_.id();
return OK; return OK;
} }
...@@ -1166,10 +1184,12 @@ void ProxyService::OnInitProxyResolverComplete(int result) { ...@@ -1166,10 +1184,12 @@ void ProxyService::OnInitProxyResolverComplete(int result) {
} }
int ProxyService::ReconsiderProxyAfterError(const GURL& url, int ProxyService::ReconsiderProxyAfterError(const GURL& url,
int load_flags,
int net_error, int net_error,
ProxyInfo* result, ProxyInfo* result,
const CompletionCallback& callback, const CompletionCallback& callback,
PacRequest** pac_request, PacRequest** pac_request,
NetworkDelegate* network_delegate,
const BoundNetLog& net_log) { const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
...@@ -1183,7 +1203,8 @@ int ProxyService::ReconsiderProxyAfterError(const GURL& url, ...@@ -1183,7 +1203,8 @@ int ProxyService::ReconsiderProxyAfterError(const GURL& url,
// If we have a new config or the config was never tried, we delete the // If we have a new config or the config was never tried, we delete the
// list of bad proxies and we try again. // list of bad proxies and we try again.
proxy_retry_info_.clear(); proxy_retry_info_.clear();
return ResolveProxy(url, result, callback, pac_request, net_log); return ResolveProxy(url, load_flags, result, callback, pac_request,
network_delegate, net_log);
} }
#if defined(SPDY_PROXY_AUTH_ORIGIN) #if defined(SPDY_PROXY_AUTH_ORIGIN)
...@@ -1273,11 +1294,19 @@ void ProxyService::RemovePendingRequest(PacRequest* req) { ...@@ -1273,11 +1294,19 @@ void ProxyService::RemovePendingRequest(PacRequest* req) {
pending_requests_.erase(it); pending_requests_.erase(it);
} }
int ProxyService::DidFinishResolvingProxy(ProxyInfo* result, int ProxyService::DidFinishResolvingProxy(const GURL& url,
int load_flags,
NetworkDelegate* network_delegate,
ProxyInfo* result,
int result_code, int result_code,
const BoundNetLog& net_log) { const BoundNetLog& net_log) {
// Log the result of the proxy resolution. // Log the result of the proxy resolution.
if (result_code == OK) { if (result_code == OK) {
// Allow the network delegate to interpose on the resolution decision,
// possibly modifying the ProxyInfo.
if (network_delegate)
network_delegate->NotifyResolveProxy(url, load_flags, result);
// When logging all events is enabled, dump the proxy list. // When logging all events is enabled, dump the proxy list.
if (net_log.IsLogging()) { if (net_log.IsLogging()) {
net_log.AddEvent( net_log.AddEvent(
...@@ -1299,6 +1328,11 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result, ...@@ -1299,6 +1328,11 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result,
// http://www.chromium.org/developers/design-documents/proxy-settings-fallback // http://www.chromium.org/developers/design-documents/proxy-settings-fallback
result->UseDirect(); result->UseDirect();
result_code = OK; result_code = OK;
// Allow the network delegate to interpose on the resolution decision,
// possibly modifying the ProxyInfo.
if (network_delegate)
network_delegate->NotifyResolveProxy(url, load_flags, result);
} else { } else {
result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED; result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED;
} }
......
...@@ -124,9 +124,11 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, ...@@ -124,9 +124,11 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// //
// Profiling information for the request is saved to |net_log| if non-NULL. // Profiling information for the request is saved to |net_log| if non-NULL.
int ResolveProxy(const GURL& url, int ResolveProxy(const GURL& url,
int load_flags,
ProxyInfo* results, ProxyInfo* results,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
PacRequest** pac_request, PacRequest** pac_request,
NetworkDelegate* network_delegate,
const BoundNetLog& net_log); const BoundNetLog& net_log);
// This method is called after a failure to connect or resolve a host name. // This method is called after a failure to connect or resolve a host name.
...@@ -144,10 +146,12 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, ...@@ -144,10 +146,12 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// //
// Profiling information for the request is saved to |net_log| if non-NULL. // Profiling information for the request is saved to |net_log| if non-NULL.
int ReconsiderProxyAfterError(const GURL& url, int ReconsiderProxyAfterError(const GURL& url,
int load_flags,
int net_error, int net_error,
ProxyInfo* results, ProxyInfo* results,
const CompletionCallback& callback, const CompletionCallback& callback,
PacRequest** pac_request, PacRequest** pac_request,
NetworkDelegate* network_delegate,
const BoundNetLog& net_log); const BoundNetLog& net_log);
// Explicitly trigger proxy fallback for the given |results| by updating our // Explicitly trigger proxy fallback for the given |results| by updating our
...@@ -367,7 +371,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, ...@@ -367,7 +371,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// Returns ERR_IO_PENDING if the request cannot be completed synchronously. // Returns ERR_IO_PENDING if the request cannot be completed synchronously.
// Otherwise it fills |result| with the proxy information for |url|. // Otherwise it fills |result| with the proxy information for |url|.
// Completing synchronously means we don't need to query ProxyResolver. // Completing synchronously means we don't need to query ProxyResolver.
int TryToCompleteSynchronously(const GURL& url, ProxyInfo* result); int TryToCompleteSynchronously(const GURL& url,
int load_flags,
NetworkDelegate* network_delegate,
ProxyInfo* result);
// Cancels all of the requests sent to the ProxyResolver. These will be // Cancels all of the requests sent to the ProxyResolver. These will be
// restarted when calling SetReady(). // restarted when calling SetReady().
...@@ -386,7 +393,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, ...@@ -386,7 +393,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// Called when proxy resolution has completed (either synchronously or // Called when proxy resolution has completed (either synchronously or
// asynchronously). Handles logging the result, and cleaning out // asynchronously). Handles logging the result, and cleaning out
// bad entries from the results list. // bad entries from the results list.
int DidFinishResolvingProxy(ProxyInfo* result, int DidFinishResolvingProxy(const GURL& url,
int load_flags,
NetworkDelegate* network_delegate,
ProxyInfo* result,
int result_code, int result_code,
const BoundNetLog& net_log); const BoundNetLog& net_log);
......
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "net/base/auth.h" #include "net/base/auth.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "net/dns/host_resolver.h" #include "net/dns/host_resolver.h"
...@@ -630,7 +631,8 @@ int SocketStream::DoResolveProxy() { ...@@ -630,7 +631,8 @@ int SocketStream::DoResolveProxy() {
// Alternate-Protocol header here for ws:// or TLS NPN extension for wss:// . // Alternate-Protocol header here for ws:// or TLS NPN extension for wss:// .
return context_->proxy_service()->ResolveProxy( return context_->proxy_service()->ResolveProxy(
proxy_url_, &proxy_info_, io_callback_, &pac_request_, net_log_); proxy_url_, net::LOAD_NORMAL, &proxy_info_, io_callback_, &pac_request_,
NULL, net_log_);
} }
int SocketStream::DoResolveProxyComplete(int result) { int SocketStream::DoResolveProxyComplete(int result) {
......
...@@ -102,10 +102,12 @@ void URLRequestFtpJob::Start() { ...@@ -102,10 +102,12 @@ void URLRequestFtpJob::Start() {
DCHECK_EQ(request_->context()->proxy_service(), proxy_service_); DCHECK_EQ(request_->context()->proxy_service(), proxy_service_);
rv = proxy_service_->ResolveProxy( rv = proxy_service_->ResolveProxy(
request_->url(), request_->url(),
request_->load_flags(),
&proxy_info_, &proxy_info_,
base::Bind(&URLRequestFtpJob::OnResolveProxyComplete, base::Bind(&URLRequestFtpJob::OnResolveProxyComplete,
base::Unretained(this)), base::Unretained(this)),
&pac_request_, &pac_request_,
NULL,
request_->net_log()); request_->net_log());
if (rv == ERR_IO_PENDING) if (rv == ERR_IO_PENDING)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment