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

Unified Diff: net/proxy/proxy_service_unittest.cc

Issue 2110973002: Removing load_flags from ProxyService and ProxyDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_service_mojo_unittest.cc ('k') | net/url_request/url_request_ftp_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_service_unittest.cc
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index 97f9a15232052bab5fc2bbb2c75acdf738216468..e525ead750c72ea3616f0fbc825e6ba2d794d4c5 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -8,21 +8,20 @@
#include <string>
#include <vector>
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/proxy_delegate.h"
#include "net/base/test_completion_callback.h"
#include "net/log/net_log.h"
#include "net/log/test_net_log.h"
#include "net/log/test_net_log_entry.h"
#include "net/log/test_net_log_util.h"
#include "net/proxy/dhcp_proxy_script_fetcher.h"
#include "net/proxy/mock_proxy_resolver.h"
#include "net/proxy/mock_proxy_script_fetcher.h"
@@ -173,21 +172,20 @@ class MockProxyConfigService: public ProxyConfigService {
class TestResolveProxyDelegate : public ProxyDelegate {
public:
TestResolveProxyDelegate()
: on_resolve_proxy_called_(false),
add_proxy_(false),
remove_proxy_(false),
proxy_service_(nullptr) {}
void OnResolveProxy(const GURL& url,
const std::string& method,
- int load_flags,
const ProxyService& proxy_service,
ProxyInfo* result) override {
method_ = method;
on_resolve_proxy_called_ = true;
proxy_service_ = &proxy_service;
DCHECK(!add_proxy_ || !remove_proxy_);
if (add_proxy_) {
result->UseNamedProxy("delegate_proxy.com");
} else if (remove_proxy_) {
result->UseDirect();
@@ -236,21 +234,20 @@ class TestResolveProxyDelegate : public ProxyDelegate {
// A test network delegate that exercises the OnProxyFallback callback.
class TestProxyFallbackProxyDelegate : public ProxyDelegate {
public:
TestProxyFallbackProxyDelegate()
: on_proxy_fallback_called_(false), proxy_fallback_net_error_(OK) {}
// ProxyDelegate implementation:
void OnResolveProxy(const GURL& url,
const std::string& method,
- int load_flags,
const ProxyService& proxy_service,
ProxyInfo* result) override {}
void OnTunnelConnectCompleted(const HostPortPair& endpoint,
const HostPortPair& proxy_server,
int net_error) override {}
void OnFallback(const ProxyServer& bad_proxy, int net_error) override {
proxy_server_ = bad_proxy;
proxy_fallback_net_error_ = net_error;
on_proxy_fallback_called_ = true;
}
@@ -355,23 +352,22 @@ TEST_F(ProxyServiceTest, Direct) {
new MockAsyncProxyResolverFactory(false);
ProxyService service(
base::WrapUnique(new MockProxyConfigService(ProxyConfig::CreateDirect())),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback;
BoundTestNetLog log;
- int rv =
- service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr, log.bound());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, log.bound());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(factory->pending_requests().empty());
EXPECT_TRUE(info.is_direct());
EXPECT_TRUE(info.proxy_resolve_start_time().is_null());
EXPECT_TRUE(info.proxy_resolve_end_time().is_null());
// Check the NetLog was filled correctly.
TestNetLogEntry::List entries;
log.GetEntries(&entries);
@@ -396,55 +392,53 @@ TEST_F(ProxyServiceTest, OnResolveProxyCallbackAddProxy) {
nullptr, nullptr);
GURL url("http://www.google.com/");
GURL bypass_url("http://internet.org");
ProxyInfo info;
TestCompletionCallback callback;
BoundTestNetLog log;
// First, warm up the ProxyService.
- int rv =
- service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr, log.bound());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, log.bound());
EXPECT_THAT(rv, IsOk());
// Verify that network delegate is invoked.
TestResolveProxyDelegate delegate;
- rv = service.ResolveProxy(url, "GET", LOAD_NORMAL, &info, callback.callback(),
- nullptr, &delegate, log.bound());
+ rv = service.ResolveProxy(url, "GET", &info, callback.callback(), nullptr,
+ &delegate, log.bound());
EXPECT_TRUE(delegate.on_resolve_proxy_called());
EXPECT_EQ(&service, delegate.proxy_service());
EXPECT_EQ(delegate.method(), "GET");
// Verify that the ProxyDelegate's behavior is stateless across
// invocations of ResolveProxy. Start by having the callback add a proxy
// and checking that subsequent requests are not affected.
delegate.set_add_proxy(true);
// Callback should interpose:
- rv = service.ResolveProxy(url, "GET", LOAD_NORMAL, &info, callback.callback(),
- nullptr, &delegate, log.bound());
+ rv = service.ResolveProxy(url, "GET", &info, callback.callback(), nullptr,
+ &delegate, log.bound());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com");
delegate.set_add_proxy(false);
// Check non-bypassed URL:
- rv = service.ResolveProxy(url, "GET", LOAD_NORMAL, &info, callback.callback(),
- nullptr, &delegate, log.bound());
+ rv = service.ResolveProxy(url, "GET", &info, callback.callback(), nullptr,
+ &delegate, log.bound());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1");
// Check bypassed URL:
- rv = service.ResolveProxy(bypass_url, "GET", LOAD_NORMAL, &info,
- callback.callback(), nullptr, &delegate,
- log.bound());
+ rv = service.ResolveProxy(bypass_url, "GET", &info, callback.callback(),
+ nullptr, &delegate, log.bound());
EXPECT_TRUE(info.is_direct());
}
TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) {
// Same as OnResolveProxyCallbackAddProxy, but verify that the
// ProxyDelegate's behavior is stateless across invocations after it
// *removes* a proxy.
ProxyConfig config;
config.proxy_rules().ParseFromString("foopy1:8080");
config.set_auto_detect(false);
@@ -454,44 +448,42 @@ TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) {
nullptr, nullptr);
GURL url("http://www.google.com/");
GURL bypass_url("http://internet.org");
ProxyInfo info;
TestCompletionCallback callback;
BoundTestNetLog log;
// First, warm up the ProxyService.
- int rv =
- service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr, log.bound());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, log.bound());
EXPECT_THAT(rv, IsOk());
TestResolveProxyDelegate delegate;
delegate.set_remove_proxy(true);
// Callback should interpose:
- rv = service.ResolveProxy(url, "GET", LOAD_NORMAL, &info, callback.callback(),
- nullptr, &delegate, log.bound());
+ rv = service.ResolveProxy(url, "GET", &info, callback.callback(), nullptr,
+ &delegate, log.bound());
EXPECT_TRUE(info.is_direct());
delegate.set_remove_proxy(false);
// Check non-bypassed URL:
- rv = service.ResolveProxy(url, "GET", LOAD_NORMAL, &info, callback.callback(),
- nullptr, &delegate, log.bound());
+ rv = service.ResolveProxy(url, "GET", &info, callback.callback(), nullptr,
+ &delegate, log.bound());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1");
// Check bypassed URL:
- rv = service.ResolveProxy(bypass_url, "GET", LOAD_NORMAL, &info,
- callback.callback(), nullptr, &delegate,
- log.bound());
+ rv = service.ResolveProxy(bypass_url, "GET", &info, callback.callback(),
+ nullptr, &delegate, log.bound());
EXPECT_TRUE(info.is_direct());
}
TEST_F(ProxyServiceTest, PAC) {
MockProxyConfigService* config_service =
new MockProxyConfigService("http://foopy/proxy.pac");
MockAsyncProxyResolver resolver;
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
@@ -499,23 +491,22 @@ TEST_F(ProxyServiceTest, PAC) {
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback;
ProxyService::PacRequest* request;
BoundTestNetLog log;
- int rv =
- service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), &request, nullptr, log.bound());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ &request, nullptr, log.bound());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL, service.GetLoadState(request));
ASSERT_EQ(1u, factory->pending_requests().size());
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
@@ -559,23 +550,22 @@ TEST_F(ProxyServiceTest, PAC_NoIdentityOrHash) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://username:password@www.google.com/?ref#hash#hash");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
// The URL should have been simplified, stripping the username/password/hash.
EXPECT_EQ(GURL("http://www.google.com/?ref"),
resolver.pending_requests()[0]->url());
@@ -591,23 +581,22 @@ TEST_F(ProxyServiceTest, PAC_FailoverWithoutDirect) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Set the result in proxy resolver.
@@ -623,22 +612,22 @@ TEST_F(ProxyServiceTest, PAC_FailoverWithoutDirect) {
EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time());
// Now, imagine that connecting to foopy:8080 fails: there is nothing
// left to fallback to, since our proxy list was NOT terminated by
// DIRECT.
TestResolveProxyDelegate proxy_delegate;
TestCompletionCallback callback2;
ProxyServer expected_proxy_server = info.proxy_server();
rv = service.ReconsiderProxyAfterError(
- url, "GET", LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
- callback2.callback(), nullptr, &proxy_delegate, BoundNetLog());
+ url, "GET", ERR_PROXY_CONNECTION_FAILED, &info, callback2.callback(),
+ nullptr, &proxy_delegate, BoundNetLog());
// ReconsiderProxyAfterError returns error indicating nothing left.
EXPECT_THAT(rv, IsError(ERR_FAILED));
EXPECT_TRUE(info.is_empty());
}
// Test that if the execution of the PAC script fails (i.e. javascript runtime
// error), and the PAC settings are non-mandatory, that we fall-back to direct.
TEST_F(ProxyServiceTest, PAC_RuntimeError) {
MockProxyConfigService* config_service =
new MockProxyConfigService("http://foopy/proxy.pac");
@@ -646,23 +635,22 @@ TEST_F(ProxyServiceTest, PAC_RuntimeError) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://this-causes-js-error/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Simulate a failure in the PAC executor.
@@ -705,75 +693,74 @@ TEST_F(ProxyServiceTest, PAC_FailoverAfterDirect) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Set the result in proxy resolver.
resolver.pending_requests()[0]->results()->UsePacString(
"DIRECT ; PROXY foobar:10 ; DIRECT ; PROXY foobar:20");
resolver.pending_requests()[0]->CompleteNow(OK);
EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_TRUE(info.is_direct());
// Fallback 1.
TestCompletionCallback callback2;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback2.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foobar:10", info.proxy_server().ToURI());
// Fallback 2.
TestResolveProxyDelegate proxy_delegate;
ProxyServer expected_proxy_server3 = info.proxy_server();
TestCompletionCallback callback3;
rv = service.ReconsiderProxyAfterError(
- url, "GET", LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
- callback3.callback(), nullptr, &proxy_delegate, BoundNetLog());
+ url, "GET", ERR_PROXY_CONNECTION_FAILED, &info, callback3.callback(),
+ nullptr, &proxy_delegate, BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(info.is_direct());
// Fallback 3.
ProxyServer expected_proxy_server4 = info.proxy_server();
TestCompletionCallback callback4;
rv = service.ReconsiderProxyAfterError(
- url, "GET", LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
- callback4.callback(), nullptr, &proxy_delegate, BoundNetLog());
+ url, "GET", ERR_PROXY_CONNECTION_FAILED, &info, callback4.callback(),
+ nullptr, &proxy_delegate, BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foobar:20", info.proxy_server().ToURI());
// Fallback 4 -- Nothing to fall back to!
ProxyServer expected_proxy_server5 = info.proxy_server();
TestCompletionCallback callback5;
rv = service.ReconsiderProxyAfterError(
- url, "GET", LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
- callback5.callback(), nullptr, &proxy_delegate, BoundNetLog());
+ url, "GET", ERR_PROXY_CONNECTION_FAILED, &info, callback5.callback(),
+ nullptr, &proxy_delegate, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_FAILED));
EXPECT_TRUE(info.is_empty());
}
TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) {
// Test whether the ProxyConfigSource set by the ProxyConfigService is applied
// to ProxyInfo after the proxy is resolved via a PAC script.
ProxyConfig config =
ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac"));
config.set_source(PROXY_CONFIG_SOURCE_TEST);
@@ -782,23 +769,22 @@ TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) {
MockAsyncProxyResolver resolver;
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Resolve something.
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, BoundNetLog());
ASSERT_THAT(rv, IsError(ERR_IO_PENDING));
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
// Set the result in proxy resolver.
resolver.pending_requests()[0]->results()->UseNamedProxy("foopy");
resolver.pending_requests()[0]->CompleteNow(OK);
EXPECT_THAT(callback.WaitForResult(), IsOk());
EXPECT_EQ(PROXY_CONFIG_SOURCE_TEST, info.config_source());
@@ -821,23 +807,22 @@ TEST_F(ProxyServiceTest, ProxyResolverFails) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Start first resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Fail the first resolve request in MockAsyncProxyResolver.
@@ -849,23 +834,22 @@ TEST_F(ProxyServiceTest, ProxyResolverFails) {
EXPECT_TRUE(info.is_direct());
// Failed PAC executions still have proxy resolution times.
EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time());
// The second resolve request will try to run through the proxy resolver,
// regardless of whether the first request failed in it.
TestCompletionCallback callback2;
- rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback2.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info, callback2.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// This time we will have the resolver succeed (perhaps the PAC script has
// a dependency on the current time).
resolver.pending_requests()[0]->results()->UseNamedProxy("foopy_valid:8080");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -885,23 +869,22 @@ TEST_F(ProxyServiceTest, ProxyResolverTerminatedDuringRequest) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Start first resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), net::LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, factory->pending_requests().size());
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
@@ -916,23 +899,22 @@ TEST_F(ProxyServiceTest, ProxyResolverTerminatedDuringRequest) {
// Failed PAC executions still have proxy resolution times.
EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time());
// With no other requests, the ProxyService waits for a new request before
// initializing a new ProxyResolver.
EXPECT_TRUE(factory->pending_requests().empty());
TestCompletionCallback callback2;
- rv = service.ResolveProxy(url, std::string(), net::LOAD_NORMAL, &info,
- callback2.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info, callback2.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, factory->pending_requests().size());
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
@@ -958,28 +940,27 @@ TEST_F(ProxyServiceTest,
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Start two resolve requests.
GURL url1("http://www.google.com/");
GURL url2("https://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url1, std::string(), net::LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv =
+ service.ResolveProxy(url1, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
TestCompletionCallback callback2;
- rv = service.ResolveProxy(url2, std::string(), net::LOAD_NORMAL, &info,
- callback2.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url2, std::string(), &info, callback2.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, factory->pending_requests().size());
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
RequestMap requests = GetPendingRequestsForURLs(resolver, url1, url2);
// Fail the first resolve request in MockAsyncProxyResolver.
@@ -1029,42 +1010,40 @@ TEST_F(ProxyServiceTest, ProxyScriptFetcherFailsDownloadingMandatoryPac) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Start first resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNow(ERR_FAILED, nullptr);
ASSERT_EQ(0u, factory->pending_requests().size());
// As the proxy resolver factory failed the request and is configured for a
// mandatory PAC script, ProxyService must not implicitly fall-back to DIRECT.
EXPECT_EQ(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED,
callback1.WaitForResult());
EXPECT_FALSE(info.is_direct());
// As the proxy resolver factory failed the request and is configured for a
// mandatory PAC script, ProxyService must not implicitly fall-back to DIRECT.
TestCompletionCallback callback2;
- rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback2.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info, callback2.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED));
EXPECT_FALSE(info.is_direct());
}
TEST_F(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) {
// Test what happens when the ProxyResolver fails that is configured to use a
// mandatory PAC script. The download of the PAC script has already
// succeeded but the PAC script contains no valid javascript.
ProxyConfig config(
@@ -1080,23 +1059,22 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that nothing has been sent to the proxy resolver factory yet.
ASSERT_EQ(0u, factory->pending_requests().size());
// Downloading the PAC script succeeds.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
fetcher->NotifyFetchCompletion(OK, "invalid-script-contents");
@@ -1127,23 +1105,22 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsInJavaScriptMandatoryPac) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Start first resolve request.
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Fail the first resolve request in MockAsyncProxyResolver.
@@ -1151,23 +1128,22 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsInJavaScriptMandatoryPac) {
// As the proxy resolver failed the request and is configured for a mandatory
// PAC script, ProxyService must not implicitly fall-back to DIRECT.
EXPECT_EQ(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED,
callback1.WaitForResult());
EXPECT_FALSE(info.is_direct());
// The second resolve request will try to run through the proxy resolver,
// regardless of whether the first request failed in it.
TestCompletionCallback callback2;
- rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback2.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info, callback2.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// This time we will have the resolver succeed (perhaps the PAC script has
// a dependency on the current time).
resolver.pending_requests()[0]->results()->UseNamedProxy("foopy_valid:8080");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -1188,23 +1164,22 @@ TEST_F(ProxyServiceTest, ProxyFallback) {
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
// Get the proxy information.
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Set the result in proxy resolver.
@@ -1219,42 +1194,41 @@ TEST_F(ProxyServiceTest, ProxyFallback) {
EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time());
base::TimeTicks proxy_resolve_start_time = info.proxy_resolve_start_time();
base::TimeTicks proxy_resolve_end_time = info.proxy_resolve_end_time();
// Fake an error on the proxy.
TestCompletionCallback callback2;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback2.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
// Proxy times should not have been modified by fallback.
EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time());
EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time());
// The second proxy should be specified.
EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI());
// Report back that the second proxy worked. This will globally mark the
// first proxy as bad.
TestProxyFallbackProxyDelegate test_delegate;
service.ReportSuccess(info, &test_delegate);
EXPECT_EQ("foopy1:8080", test_delegate.proxy_server().ToURI());
EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED,
test_delegate.proxy_fallback_net_error());
TestCompletionCallback callback3;
- rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback3.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info, callback3.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Set the result in proxy resolver -- the second result is already known
// to be bad, so we will not try to use it initially.
resolver.pending_requests()[0]->results()->UseNamedProxy(
"foopy3:7070;foopy1:8080;foopy2:9090");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -1267,54 +1241,53 @@ TEST_F(ProxyServiceTest, ProxyFallback) {
EXPECT_LE(proxy_resolve_end_time, info.proxy_resolve_start_time());
EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time());
proxy_resolve_start_time = info.proxy_resolve_start_time();
proxy_resolve_end_time = info.proxy_resolve_end_time();
// We fake another error. It should now try the third one.
TestCompletionCallback callback4;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback4.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI());
// We fake another error. At this point we have tried all of the
// proxy servers we thought were valid; next we try the proxy server
// that was in our bad proxies map (foopy1:8080).
TestCompletionCallback callback5;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback5.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
// Fake another error, the last proxy is gone, the list should now be empty,
// so there is nothing left to try.
TestCompletionCallback callback6;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback6.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_FAILED));
EXPECT_FALSE(info.is_direct());
EXPECT_TRUE(info.is_empty());
// Proxy times should not have been modified by fallback.
EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time());
EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time());
// Look up proxies again
TestCompletionCallback callback7;
- rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback7.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info, callback7.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// This time, the first 3 results have been found to be bad, but only the
// first proxy has been confirmed ...
resolver.pending_requests()[0]->results()->UseNamedProxy(
"foopy1:8080;foopy3:7070;foopy2:9090;foopy4:9091");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -1341,23 +1314,22 @@ TEST_F(ProxyServiceTest, ProxyFallbackToDirect) {
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
// Get the proxy information.
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Set the result in proxy resolver.
@@ -1366,45 +1338,45 @@ TEST_F(ProxyServiceTest, ProxyFallbackToDirect) {
resolver.pending_requests()[0]->CompleteNow(OK);
// Get the first result.
EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
// Fake an error on the proxy.
TestCompletionCallback callback2;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback2.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
// Now we get back the second proxy.
EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI());
// Fake an error on this proxy as well.
TestCompletionCallback callback3;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback3.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
// Finally, we get back DIRECT.
EXPECT_TRUE(info.is_direct());
EXPECT_FALSE(info.proxy_resolve_start_time().is_null());
EXPECT_FALSE(info.proxy_resolve_end_time().is_null());
EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time());
// Now we tell the proxy service that even DIRECT failed.
TestCompletionCallback callback4;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback4.callback(), nullptr, nullptr, BoundNetLog());
// There was nothing left to try after DIRECT, so we are out of
// choices.
EXPECT_THAT(rv, IsError(ERR_FAILED));
}
TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) {
// Test proxy failover when new settings are available.
MockProxyConfigService* config_service =
@@ -1415,23 +1387,22 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) {
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
// Get the proxy information.
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// Set the result in proxy resolver.
@@ -1443,21 +1414,21 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) {
EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
// Fake an error on the proxy, and also a new configuration on the proxy.
config_service->SetConfig(
ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy-new/proxy.pac")));
TestCompletionCallback callback2;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback2.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy-new/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
@@ -1465,34 +1436,34 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) {
"foopy1:8080;foopy2:9090");
resolver.pending_requests()[0]->CompleteNow(OK);
// The first proxy is still there since the configuration changed.
EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
// We fake another error. It should now ignore the first one.
TestCompletionCallback callback3;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback3.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI());
// We simulate a new configuration.
config_service->SetConfig(
ProxyConfig::CreateFromCustomPacURL(
GURL("http://foopy-new2/proxy.pac")));
// We fake another error. It should go back to the first proxy.
TestCompletionCallback callback4;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback4.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy-new2/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
@@ -1519,78 +1490,76 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfig) {
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
// Get the proxy information.
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
resolver.pending_requests()[0]->results()->UseNamedProxy(
"foopy1:8080;foopy2:9090");
resolver.pending_requests()[0]->CompleteNow(OK);
// The first item is valid.
EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
// Fake a proxy error.
TestCompletionCallback callback2;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback2.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
// The first proxy is ignored, and the second one is selected.
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI());
// Fake a PAC failure.
ProxyInfo info2;
TestCompletionCallback callback3;
- rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info2,
- callback3.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info2, callback3.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// This simulates a javascript runtime error in the PAC script.
resolver.pending_requests()[0]->CompleteNow(ERR_FAILED);
// Although the resolver failed, the ProxyService will implicitly fall-back
// to a DIRECT connection.
EXPECT_THAT(callback3.WaitForResult(), IsOk());
EXPECT_TRUE(info2.is_direct());
EXPECT_FALSE(info2.is_empty());
// The PAC script will work properly next time and successfully return a
// proxy list. Since we have not marked the configuration as bad, it should
// "just work" the next time we call it.
ProxyInfo info3;
TestCompletionCallback callback4;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info3,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info3,
callback4.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
resolver.pending_requests()[0]->results()->UseNamedProxy(
"foopy1:8080;foopy2:9090");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -1619,57 +1588,55 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfigMandatory) {
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
// Get the proxy information.
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
resolver.pending_requests()[0]->results()->UseNamedProxy(
"foopy1:8080;foopy2:9090");
resolver.pending_requests()[0]->CompleteNow(OK);
// The first item is valid.
EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
// Fake a proxy error.
TestCompletionCallback callback2;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info,
callback2.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsOk());
// The first proxy is ignored, and the second one is selected.
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI());
// Fake a PAC failure.
ProxyInfo info2;
TestCompletionCallback callback3;
- rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info2,
- callback3.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url, std::string(), &info2, callback3.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
// This simulates a javascript runtime error in the PAC script.
resolver.pending_requests()[0]->CompleteNow(ERR_FAILED);
// Although the resolver failed, the ProxyService will NOT fall-back
// to a DIRECT connection as it is configured as mandatory.
@@ -1677,21 +1644,21 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfigMandatory) {
callback3.WaitForResult());
EXPECT_FALSE(info2.is_direct());
EXPECT_TRUE(info2.is_empty());
// The PAC script will work properly next time and successfully return a
// proxy list. Since we have not marked the configuration as bad, it should
// "just work" the next time we call it.
ProxyInfo info3;
TestCompletionCallback callback4;
rv = service.ReconsiderProxyAfterError(
- url, std::string(), LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info3,
+ url, std::string(), ERR_PROXY_CONNECTION_FAILED, &info3,
callback4.callback(), nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
resolver.pending_requests()[0]->results()->UseNamedProxy(
"foopy1:8080;foopy2:9090");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -1713,28 +1680,28 @@ TEST_F(ProxyServiceTest, ProxyBypassList) {
config.proxy_rules().bypass_rules.ParseFromString("*.org");
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
int rv;
GURL url1("http://www.webkit.org");
GURL url2("http://www.webkit.com");
// Request for a .org domain should bypass proxy.
- rv = service.ResolveProxy(url1, std::string(), LOAD_NORMAL, &info[0],
+ rv = service.ResolveProxy(url1, std::string(), &info[0],
callback[0].callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(info[0].is_direct());
// Request for a .com domain hits the proxy.
- rv = service.ResolveProxy(url2, std::string(), LOAD_NORMAL, &info[1],
+ rv = service.ResolveProxy(url2, std::string(), &info[1],
callback[1].callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy1:8080", info[1].proxy_server().ToURI());
}
TEST_F(ProxyServiceTest, MarkProxiesAsBadTests) {
ProxyConfig config;
config.proxy_rules().ParseFromString(
"http=foopy1:8080;http=foopy2:8080;http=foopy3.8080;http=foopy4:8080");
@@ -1772,61 +1739,61 @@ TEST_F(ProxyServiceTest, MarkProxiesAsBadTests) {
TEST_F(ProxyServiceTest, PerProtocolProxyTests) {
ProxyConfig config;
config.proxy_rules().ParseFromString("http=foopy1:8080;https=foopy2:8080");
config.set_auto_detect(false);
{
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("http://www.msn.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
}
{
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("ftp://ftp.google.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(info.is_direct());
EXPECT_EQ("direct://", info.proxy_server().ToURI());
}
{
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("https://webbranch.techcu.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy2:8080", info.proxy_server().ToURI());
}
{
config.proxy_rules().ParseFromString("foopy1:8080");
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("http://www.microsoft.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
}
}
TEST_F(ProxyServiceTest, ProxyConfigSourcePropagates) {
// Test that the proxy config source is set correctly when resolving proxies
@@ -1834,52 +1801,52 @@ TEST_F(ProxyServiceTest, ProxyConfigSourcePropagates) {
// any of the rules were applied.
{
ProxyConfig config;
config.set_source(PROXY_CONFIG_SOURCE_TEST);
config.proxy_rules().ParseFromString("https=foopy2:8080");
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("http://www.google.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
ASSERT_THAT(rv, IsOk());
// Should be SOURCE_TEST, even if there are no HTTP proxies configured.
EXPECT_EQ(PROXY_CONFIG_SOURCE_TEST, info.config_source());
}
{
ProxyConfig config;
config.set_source(PROXY_CONFIG_SOURCE_TEST);
config.proxy_rules().ParseFromString("https=foopy2:8080");
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("https://www.google.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
ASSERT_THAT(rv, IsOk());
// Used the HTTPS proxy. So source should be TEST.
EXPECT_EQ(PROXY_CONFIG_SOURCE_TEST, info.config_source());
}
{
ProxyConfig config;
config.set_source(PROXY_CONFIG_SOURCE_TEST);
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("http://www.google.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
ASSERT_THAT(rv, IsOk());
// ProxyConfig is empty. Source should still be TEST.
EXPECT_EQ(PROXY_CONFIG_SOURCE_TEST, info.config_source());
}
}
// If only HTTP and a SOCKS proxy are specified, check if ftp/https queries
// fall back to the SOCKS proxy.
@@ -1889,60 +1856,60 @@ TEST_F(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
config.set_auto_detect(false);
EXPECT_EQ(ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
config.proxy_rules().type);
{
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("http://www.msn.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
}
{
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("ftp://ftp.google.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("socks4://foopy2:1080", info.proxy_server().ToURI());
}
{
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("https://webbranch.techcu.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("socks4://foopy2:1080", info.proxy_server().ToURI());
}
{
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
nullptr, nullptr);
GURL test_url("unknown://www.microsoft.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(test_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service.ResolveProxy(test_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("socks4://foopy2:1080", info.proxy_server().ToURI());
}
}
// Test cancellation of an in-progress request.
TEST_F(ProxyServiceTest, CancelInProgressRequest) {
@@ -1956,47 +1923,45 @@ TEST_F(ProxyServiceTest, CancelInProgressRequest) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Start 3 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url1, std::string(), LOAD_NORMAL, &info1,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv =
+ service.ResolveProxy(url1, std::string(), &info1, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Successfully initialize the PAC script.
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
GetPendingRequestsForURLs(resolver, url1);
ProxyInfo info2;
TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(url2, std::string(), LOAD_NORMAL, &info2,
- callback2.callback(), &request2, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
+ &request2, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
GetPendingRequestsForURLs(resolver, url1, url2);
ProxyInfo info3;
TestCompletionCallback callback3;
- rv = service.ResolveProxy(url3, std::string(), LOAD_NORMAL, &info3,
- callback3.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url3, std::string(), &info3, callback3.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
GetPendingRequestsForURLs(resolver, url1, url2, url3);
// Cancel the second request
service.CancelPacRequest(request2);
RequestMap requests = GetPendingRequestsForURLs(resolver, url1, url3);
// Complete the two un-cancelled requests.
// We complete the last one first, just to mix it up a bit.
@@ -2034,43 +1999,41 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) {
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 3 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
ProxyService::PacRequest* request1;
- int rv = service.ResolveProxy(url1, std::string(), LOAD_NORMAL, &info1,
- callback1.callback(), &request1, nullptr,
- BoundNetLog());
+ int rv =
+ service.ResolveProxy(url1, std::string(), &info1, callback1.callback(),
+ &request1, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
ProxyInfo info2;
TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(url2, std::string(), LOAD_NORMAL, &info2,
- callback2.callback(), &request2, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
+ &request2, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ProxyInfo info3;
TestCompletionCallback callback3;
ProxyService::PacRequest* request3;
- rv = service.ResolveProxy(url3, std::string(), LOAD_NORMAL, &info3,
- callback3.callback(), &request3, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url3, std::string(), &info3, callback3.callback(),
+ &request3, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
EXPECT_EQ(LOAD_STATE_DOWNLOADING_PROXY_SCRIPT,
service.GetLoadState(request1));
EXPECT_EQ(LOAD_STATE_DOWNLOADING_PROXY_SCRIPT,
service.GetLoadState(request2));
EXPECT_EQ(LOAD_STATE_DOWNLOADING_PROXY_SCRIPT,
@@ -2139,34 +2102,33 @@ TEST_F(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url1, std::string(), LOAD_NORMAL, &info1,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv =
+ service.ResolveProxy(url1, std::string(), &info1, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
ProxyInfo info2;
TestCompletionCallback callback2;
- rv = service.ResolveProxy(url2, std::string(), LOAD_NORMAL, &info2,
- callback2.callback(), nullptr, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// At this point the ProxyService should be waiting for the
// ProxyScriptFetcher to invoke its completion callback, notifying it of
// PAC script download completion.
// We now change out the ProxyService's script fetcher. We should restart
// the initialization with the new fetcher.
fetcher = new MockProxyScriptFetcher;
@@ -2201,41 +2163,41 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) {
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 3 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
ProxyService::PacRequest* request1;
BoundTestNetLog log1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- &request1, nullptr, log1.bound());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), &request1, nullptr,
+ log1.bound());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
ProxyInfo info2;
TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), &request2, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), &request2, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ProxyInfo info3;
TestCompletionCallback callback3;
- rv = service.ResolveProxy(GURL("http://request3"), std::string(), LOAD_NORMAL,
- &info3, callback3.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request3"), std::string(), &info3,
+ callback3.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
// Cancel the first 2 requests.
service.CancelPacRequest(request1);
service.CancelPacRequest(request2);
@@ -2299,31 +2261,30 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url1, std::string(), LOAD_NORMAL, &info1,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv =
+ service.ResolveProxy(url1, std::string(), &info1, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ProxyInfo info2;
TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(url2, std::string(), LOAD_NORMAL, &info2,
- callback2.callback(), &request2, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
+ &request2, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that nothing has been sent to the proxy resolver factory yet.
ASSERT_EQ(0u, factory->pending_requests().size());
// It should be trying to auto-detect first -- FAIL the autodetect during
// the script download.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url());
fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
@@ -2380,31 +2341,30 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(url1, std::string(), LOAD_NORMAL, &info1,
- callback1.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv =
+ service.ResolveProxy(url1, std::string(), &info1, callback1.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ProxyInfo info2;
TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(url2, std::string(), LOAD_NORMAL, &info2,
- callback2.callback(), &request2, nullptr,
- BoundNetLog());
+ rv = service.ResolveProxy(url2, std::string(), &info2, callback2.callback(),
+ &request2, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that nothing has been sent to the proxy resolver factory yet.
ASSERT_EQ(0u, factory->pending_requests().size());
// It should be trying to auto-detect first -- succeed the download.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url());
fetcher->NotifyFetchCompletion(OK, "invalid-script-contents");
@@ -2454,30 +2414,30 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ProxyInfo info2;
TestCompletionCallback callback2;
ProxyService::PacRequest* request2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), &request2, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), &request2, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that nothing has been sent to the proxy resolver factory yet.
ASSERT_EQ(0u, factory->pending_requests().size());
// It should be trying to auto-detect first -- fail the download.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url());
fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
@@ -2517,22 +2477,22 @@ TEST_F(ProxyServiceTest, BypassDoesntApplyToPac) {
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 requests.
ProxyInfo info1;
TestCompletionCallback callback1;
int rv = service.ResolveProxy(GURL("http://www.google.com"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ &info1, callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that nothing has been sent to the proxy resolver factory yet.
ASSERT_EQ(0u, factory->pending_requests().size());
// It should be trying to auto-detect first -- succeed the download.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url());
fetcher->NotifyFetchCompletion(OK, kValidPacScript1);
@@ -2549,22 +2509,22 @@ TEST_F(ProxyServiceTest, BypassDoesntApplyToPac) {
resolver.pending_requests()[0]->CompleteNow(OK);
// Verify that request ran as expected.
EXPECT_THAT(callback1.WaitForResult(), IsOk());
EXPECT_EQ("request1:80", info1.proxy_server().ToURI());
// Start another request, it should pickup the bypass item.
ProxyInfo info2;
TestCompletionCallback callback2;
rv = service.ResolveProxy(GURL("http://www.google.com"), std::string(),
- LOAD_NORMAL, &info2, callback2.callback(), nullptr,
- nullptr, BoundNetLog());
+ &info2, callback2.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(GURL("http://www.google.com"),
resolver.pending_requests()[0]->url());
// Complete the pending request.
resolver.pending_requests()[0]->results()->UseNamedProxy("request2:80");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -2588,22 +2548,22 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) {
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
int rv = service.ResolveProxy(GURL("http://www.google.com"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ &info1, callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that nothing has been sent to the proxy resolver factory yet.
ASSERT_EQ(0u, factory->pending_requests().size());
// InitProxyResolver should have issued a request to the ProxyScriptFetcher
// and be waiting on that to complete.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
}
@@ -2619,52 +2579,51 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingSet) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service.ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv = service.ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
}
TEST_F(ProxyServiceTest, ResetProxyConfigService) {
ProxyConfig config1;
config1.proxy_rules().ParseFromString("foopy1:8080");
config1.set_auto_detect(false);
ProxyService service(base::WrapUnique(new MockProxyConfigService(config1)),
nullptr, nullptr);
ProxyInfo info;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
ProxyConfig config2;
config2.proxy_rules().ParseFromString("foopy2:8080");
config2.set_auto_detect(false);
service.ResetConfigService(
base::WrapUnique(new MockProxyConfigService(config2)));
TestCompletionCallback callback2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info, callback2.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info,
+ callback2.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_EQ("foopy2:8080", info.proxy_server().ToURI());
}
// Test that when going from a configuration that required PAC to one
// that does NOT, we unset the variable |should_use_proxy_resolver_|.
TEST_F(ProxyServiceTest, UpdateConfigFromPACToDirect) {
ProxyConfig config = ProxyConfig::CreateAutoDetect();
@@ -2673,22 +2632,22 @@ TEST_F(ProxyServiceTest, UpdateConfigFromPACToDirect) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
int rv = service.ResolveProxy(GURL("http://www.google.com"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ &info1, callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Successfully set the autodetect script.
EXPECT_EQ(ProxyResolverScriptData::TYPE_AUTO_DETECT,
factory->pending_requests()[0]->script_data()->type());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
// Complete the pending request.
ASSERT_EQ(1u, resolver.pending_requests().size());
resolver.pending_requests()[0]->results()->UseNamedProxy("request1:80");
@@ -2702,22 +2661,22 @@ TEST_F(ProxyServiceTest, UpdateConfigFromPACToDirect) {
// (Even though the configuration isn't old/bad).
//
// This new configuration no longer has auto_detect set, so
// requests should complete synchronously now as direct-connect.
config_service->SetConfig(ProxyConfig::CreateDirect());
// Start another request -- the effective configuration has changed.
ProxyInfo info2;
TestCompletionCallback callback2;
rv = service.ResolveProxy(GURL("http://www.google.com"), std::string(),
- LOAD_NORMAL, &info2, callback2.callback(), nullptr,
- nullptr, BoundNetLog());
+ &info2, callback2.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(info2.is_direct());
}
TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
MockProxyConfigService* config_service =
new MockProxyConfigService("http://foopy/proxy.pac");
MockAsyncProxyResolver resolver;
@@ -2734,23 +2693,23 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Disable the "wait after IP address changes" hack, so this unit-test can
// complete quickly.
service.set_stall_proxy_auto_config_delay(base::TimeDelta());
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered initial download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
// At this point the ProxyService should be waiting for the
@@ -2777,22 +2736,22 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
// Now simluate a change in the network. The ProxyConfigService is still
// going to return the same PAC URL as before, but this URL needs to be
// refetched on the new network.
NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
base::RunLoop().RunUntilIdle(); // Notification happens async.
// Start a second request.
ProxyInfo info2;
TestCompletionCallback callback2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// This second request should have triggered the re-download of the PAC
// script (since we marked the network as having changed).
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
@@ -2852,23 +2811,23 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered initial download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
// At this point the ProxyService should be waiting for the
@@ -2913,22 +2872,22 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) {
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
// At this point the ProxyService should have re-configured itself to use the
// PAC script (thereby recovering from the initial fetch failure). We will
// verify that the next Resolve request uses the resolver rather than
// DIRECT.
// Start a second request.
ProxyInfo info2;
TestCompletionCallback callback2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that it was sent to the resolver.
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(GURL("http://request2"), resolver.pending_requests()[0]->url());
// Complete the pending second request.
resolver.pending_requests()[0]->results()->UseNamedProxy("request2:80");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -2959,23 +2918,23 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered initial download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
// At this point the ProxyService should be waiting for the
@@ -3026,22 +2985,22 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) {
EXPECT_EQ(ASCIIToUTF16(kValidPacScript2),
factory->pending_requests()[0]->script_data()->utf16());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
// At this point the ProxyService should have re-configured itself to use the
// new PAC script.
// Start a second request.
ProxyInfo info2;
TestCompletionCallback callback2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that it was sent to the resolver.
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(GURL("http://request2"), resolver.pending_requests()[0]->url());
// Complete the pending second request.
resolver.pending_requests()[0]->results()->UseNamedProxy("request2:80");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -3072,23 +3031,23 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered initial download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
// At this point the ProxyService should be waiting for the
@@ -3136,22 +3095,22 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) {
ASSERT_TRUE(factory->pending_requests().empty());
ASSERT_TRUE(resolver.pending_requests().empty());
// At this point the ProxyService is still running the same PAC script as
// before.
// Start a second request.
ProxyInfo info2;
TestCompletionCallback callback2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// Check that it was sent to the resolver.
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(GURL("http://request2"), resolver.pending_requests()[0]->url());
// Complete the pending second request.
resolver.pending_requests()[0]->results()->UseNamedProxy("request2:80");
resolver.pending_requests()[0]->CompleteNow(OK);
@@ -3182,23 +3141,23 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered initial download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
// At this point the ProxyService should be waiting for the
@@ -3243,22 +3202,22 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) {
fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
base::RunLoop().RunUntilIdle();
// At this point the ProxyService should have re-configured itself to use
// DIRECT connections rather than the given proxy resolver.
// Start a second request.
ProxyInfo info2;
TestCompletionCallback callback2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(info2.is_direct());
}
// Tests that the code which decides at what times to poll the PAC
// script follows the expected policy.
TEST_F(ProxyServiceTest, PACScriptPollingPolicy) {
// Retrieve the internal polling policy implementation used by ProxyService.
std::unique_ptr<ProxyService::PacPollPolicy> policy =
@@ -3337,23 +3296,23 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) {
base::WrapUnique(factory), nullptr);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
ProxyInfo info1;
TestCompletionCallback callback1;
- int rv = service.ResolveProxy(GURL("http://request1"), std::string(),
- LOAD_NORMAL, &info1, callback1.callback(),
- nullptr, nullptr, BoundNetLog());
+ int rv = service.ResolveProxy(GURL("http://request1"), std::string(), &info1,
+ callback1.callback(), nullptr, nullptr,
+ BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// The first request should have triggered initial download of PAC script.
EXPECT_TRUE(fetcher->has_pending_request());
EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
// At this point the ProxyService should be waiting for the
@@ -3382,22 +3341,22 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) {
// Our PAC poller is set to update ONLY in response to network activity,
// (i.e. another call to ResolveProxy()).
ASSERT_FALSE(fetcher->has_pending_request());
ASSERT_TRUE(factory->pending_requests().empty());
ASSERT_TRUE(resolver.pending_requests().empty());
// Start a second request.
ProxyInfo info2;
TestCompletionCallback callback2;
- rv = service.ResolveProxy(GURL("http://request2"), std::string(), LOAD_NORMAL,
- &info2, callback2.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request2"), std::string(), &info2,
+ callback2.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// This request should have sent work to the resolver; complete it.
ASSERT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(GURL("http://request2"), resolver.pending_requests()[0]->url());
resolver.pending_requests()[0]->results()->UseNamedProxy("request2:80");
resolver.pending_requests()[0]->CompleteNow(OK);
EXPECT_THAT(callback2.WaitForResult(), IsOk());
@@ -3413,22 +3372,22 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) {
fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
// Drain the message loop, so ProxyService is notified of the change
// and has a chance to re-configure itself.
base::RunLoop().RunUntilIdle();
// Start a third request -- this time we expect to get a direct connection
// since the PAC script poller experienced a failure.
ProxyInfo info3;
TestCompletionCallback callback3;
- rv = service.ResolveProxy(GURL("http://request3"), std::string(), LOAD_NORMAL,
- &info3, callback3.callback(), nullptr, nullptr,
+ rv = service.ResolveProxy(GURL("http://request3"), std::string(), &info3,
+ callback3.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsOk());
EXPECT_TRUE(info3.is_direct());
}
// Test that the synchronous resolution fails when a PAC script is active.
TEST_F(ProxyServiceTest, SynchronousWithPAC) {
MockProxyConfigService* config_service =
new MockProxyConfigService("http://foopy/proxy.pac");
@@ -3438,21 +3397,21 @@ TEST_F(ProxyServiceTest, SynchronousWithPAC) {
ProxyService service(base::WrapUnique(config_service),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
ProxyInfo info;
info.UseDirect();
BoundTestNetLog log;
bool synchronous_success = service.TryResolveProxySynchronously(
- url, std::string(), LOAD_NORMAL, &info, nullptr, log.bound());
+ url, std::string(), &info, nullptr, log.bound());
EXPECT_FALSE(synchronous_success);
// |info| should not have been modified.
EXPECT_TRUE(info.is_direct());
}
// Test that synchronous results are returned correctly if a fixed proxy
// configuration is active.
TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) {
ProxyConfig config;
@@ -3464,21 +3423,21 @@ TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) {
ProxyService service(base::WrapUnique(new MockProxyConfigService(config)),
base::WrapUnique(factory), nullptr);
GURL url("http://www.google.com/");
ProxyInfo info;
BoundTestNetLog log;
bool synchronous_success = service.TryResolveProxySynchronously(
- url, std::string(), LOAD_NORMAL, &info, nullptr, log.bound());
+ url, std::string(), &info, nullptr, log.bound());
EXPECT_TRUE(synchronous_success);
EXPECT_FALSE(info.is_direct());
EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host());
// No request should have been queued.
EXPECT_EQ(0u, factory->pending_requests().size());
}
// Helper class to exercise URL sanitization using the different policies. This
// works by submitted URLs to the ProxyService. In turn the ProxyService
@@ -3494,23 +3453,23 @@ class SanitizeUrlHelper {
service_.reset(new ProxyService(std::move(config_service),
base::WrapUnique(factory), nullptr));
// Do an initial request to initialize the service (configure the PAC
// script).
GURL url("http://example.com");
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service_->ResolveProxy(url, std::string(), LOAD_NORMAL, &info,
- callback.callback(), nullptr, nullptr,
- BoundNetLog());
+ int rv =
+ service_->ResolveProxy(url, std::string(), &info, callback.callback(),
+ nullptr, nullptr, BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
// First step is to download the PAC script.
EXPECT_EQ(GURL("http://foopy/proxy.pac"),
factory->pending_requests()[0]->script_data()->url());
factory->pending_requests()[0]->CompleteNowWithForwarder(OK, &resolver);
EXPECT_EQ(1u, resolver.pending_requests().size());
EXPECT_EQ(url, resolver.pending_requests()[0]->url());
@@ -3526,21 +3485,21 @@ class SanitizeUrlHelper {
void SetSanitizeUrlPolicy(ProxyService::SanitizeUrlPolicy policy) {
service_->set_sanitize_url_policy(policy);
}
// Makes a proxy resolution request through the ProxyService, and returns the
// URL that was submitted to the Proxy Resolver.
GURL SanitizeUrl(const GURL& raw_url) {
// Issue a request and see what URL is sent to the proxy resolver.
ProxyInfo info;
TestCompletionCallback callback;
- int rv = service_->ResolveProxy(raw_url, std::string(), LOAD_NORMAL, &info,
+ int rv = service_->ResolveProxy(raw_url, std::string(), &info,
callback.callback(), nullptr, nullptr,
BoundNetLog());
EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
EXPECT_EQ(1u, resolver.pending_requests().size());
GURL sanitized_url = resolver.pending_requests()[0]->url();
// Complete the request.
resolver.pending_requests()[0]->results()->UsePacString("DIRECT");
« no previous file with comments | « net/proxy/proxy_service_mojo_unittest.cc ('k') | net/url_request/url_request_ftp_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698