| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/proxy/proxy_service.h" | 5 #include "net/proxy/proxy_service.h" |
| 6 | 6 |
| 7 #include <cstdarg> | 7 #include <cstdarg> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/base/proxy_delegate.h" | 17 #include "net/base/network_delegate_impl.h" |
| 18 #include "net/base/test_completion_callback.h" | 18 #include "net/base/test_completion_callback.h" |
| 19 #include "net/log/net_log.h" | 19 #include "net/log/net_log.h" |
| 20 #include "net/log/test_net_log.h" | 20 #include "net/log/test_net_log.h" |
| 21 #include "net/log/test_net_log_entry.h" | 21 #include "net/log/test_net_log_entry.h" |
| 22 #include "net/log/test_net_log_util.h" | 22 #include "net/log/test_net_log_util.h" |
| 23 #include "net/proxy/dhcp_proxy_script_fetcher.h" | 23 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
| 24 #include "net/proxy/mock_proxy_resolver.h" | 24 #include "net/proxy/mock_proxy_resolver.h" |
| 25 #include "net/proxy/mock_proxy_script_fetcher.h" | 25 #include "net/proxy/mock_proxy_script_fetcher.h" |
| 26 #include "net/proxy/proxy_config_service.h" | 26 #include "net/proxy/proxy_config_service.h" |
| 27 #include "net/proxy/proxy_resolver.h" | 27 #include "net/proxy/proxy_resolver.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 OnProxyConfigChanged(config_, availability_)); | 155 OnProxyConfigChanged(config_, availability_)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 ConfigAvailability availability_; | 159 ConfigAvailability availability_; |
| 160 ProxyConfig config_; | 160 ProxyConfig config_; |
| 161 base::ObserverList<Observer, true> observers_; | 161 base::ObserverList<Observer, true> observers_; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 // A test network delegate that exercises the OnResolveProxy callback. | 164 // A test network delegate that exercises the OnResolveProxy callback. |
| 165 class TestResolveProxyDelegate : public ProxyDelegate { | 165 class TestResolveProxyNetworkDelegate : public NetworkDelegateImpl { |
| 166 public: | 166 public: |
| 167 TestResolveProxyDelegate() | 167 TestResolveProxyNetworkDelegate() |
| 168 : on_resolve_proxy_called_(false), | 168 : on_resolve_proxy_called_(false), |
| 169 add_proxy_(false), | 169 add_proxy_(false), |
| 170 remove_proxy_(false), | 170 remove_proxy_(false), |
| 171 proxy_service_(nullptr) {} | 171 proxy_service_(NULL) { |
| 172 } |
| 172 | 173 |
| 173 void OnResolveProxy(const GURL& url, | 174 void OnResolveProxy(const GURL& url, |
| 174 int load_flags, | 175 int load_flags, |
| 175 const ProxyService& proxy_service, | 176 const ProxyService& proxy_service, |
| 176 ProxyInfo* result) override { | 177 ProxyInfo* result) override { |
| 177 on_resolve_proxy_called_ = true; | 178 on_resolve_proxy_called_ = true; |
| 178 proxy_service_ = &proxy_service; | 179 proxy_service_ = &proxy_service; |
| 179 DCHECK(!add_proxy_ || !remove_proxy_); | 180 DCHECK(!add_proxy_ || !remove_proxy_); |
| 180 if (add_proxy_) { | 181 if (add_proxy_) { |
| 181 result->UseNamedProxy("delegate_proxy.com"); | 182 result->UseNamedProxy("delegate_proxy.com"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 193 } | 194 } |
| 194 | 195 |
| 195 void set_remove_proxy(bool remove_proxy) { | 196 void set_remove_proxy(bool remove_proxy) { |
| 196 remove_proxy_ = remove_proxy; | 197 remove_proxy_ = remove_proxy; |
| 197 } | 198 } |
| 198 | 199 |
| 199 const ProxyService* proxy_service() const { | 200 const ProxyService* proxy_service() const { |
| 200 return proxy_service_; | 201 return proxy_service_; |
| 201 } | 202 } |
| 202 | 203 |
| 203 void OnTunnelConnectCompleted(const HostPortPair& endpoint, | |
| 204 const HostPortPair& proxy_server, | |
| 205 int net_error) override {} | |
| 206 void OnFallback(const ProxyServer& bad_proxy, int net_error) override {} | |
| 207 void OnBeforeSendHeaders(URLRequest* request, | |
| 208 const ProxyInfo& proxy_info, | |
| 209 HttpRequestHeaders* headers) override {} | |
| 210 void OnBeforeTunnelRequest(const HostPortPair& proxy_server, | |
| 211 HttpRequestHeaders* extra_headers) override {} | |
| 212 void OnTunnelHeadersReceived( | |
| 213 const HostPortPair& origin, | |
| 214 const HostPortPair& proxy_server, | |
| 215 const HttpResponseHeaders& response_headers) override {} | |
| 216 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override { | |
| 217 return true; | |
| 218 } | |
| 219 | |
| 220 private: | 204 private: |
| 221 bool on_resolve_proxy_called_; | 205 bool on_resolve_proxy_called_; |
| 222 bool add_proxy_; | 206 bool add_proxy_; |
| 223 bool remove_proxy_; | 207 bool remove_proxy_; |
| 224 const ProxyService* proxy_service_; | 208 const ProxyService* proxy_service_; |
| 225 }; | 209 }; |
| 226 | 210 |
| 227 // A test network delegate that exercises the OnProxyFallback callback. | 211 // A test network delegate that exercises the OnProxyFallback callback. |
| 228 class TestProxyFallbackProxyDelegate : public ProxyDelegate { | 212 class TestProxyFallbackNetworkDelegate : public NetworkDelegateImpl { |
| 229 public: | 213 public: |
| 230 TestProxyFallbackProxyDelegate() | 214 TestProxyFallbackNetworkDelegate() |
| 231 : on_proxy_fallback_called_(false), proxy_fallback_net_error_(OK) {} | 215 : on_proxy_fallback_called_(false), |
| 216 proxy_fallback_net_error_(OK) { |
| 217 } |
| 232 | 218 |
| 233 // ProxyDelegate implementation: | 219 void OnProxyFallback(const ProxyServer& proxy_server, |
| 234 void OnResolveProxy(const GURL& url, | 220 int net_error) override { |
| 235 int load_flags, | 221 proxy_server_ = proxy_server; |
| 236 const ProxyService& proxy_service, | |
| 237 ProxyInfo* result) override {} | |
| 238 void OnTunnelConnectCompleted(const HostPortPair& endpoint, | |
| 239 const HostPortPair& proxy_server, | |
| 240 int net_error) override {} | |
| 241 void OnFallback(const ProxyServer& bad_proxy, int net_error) override { | |
| 242 proxy_server_ = bad_proxy; | |
| 243 proxy_fallback_net_error_ = net_error; | 222 proxy_fallback_net_error_ = net_error; |
| 244 on_proxy_fallback_called_ = true; | 223 on_proxy_fallback_called_ = true; |
| 245 } | 224 } |
| 246 void OnBeforeSendHeaders(URLRequest* request, | |
| 247 const ProxyInfo& proxy_info, | |
| 248 HttpRequestHeaders* headers) override {} | |
| 249 void OnBeforeTunnelRequest(const HostPortPair& proxy_server, | |
| 250 HttpRequestHeaders* extra_headers) override {} | |
| 251 void OnTunnelHeadersReceived( | |
| 252 const HostPortPair& origin, | |
| 253 const HostPortPair& proxy_server, | |
| 254 const HttpResponseHeaders& response_headers) override {} | |
| 255 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override { | |
| 256 return true; | |
| 257 } | |
| 258 | 225 |
| 259 bool on_proxy_fallback_called() const { | 226 bool on_proxy_fallback_called() const { |
| 260 return on_proxy_fallback_called_; | 227 return on_proxy_fallback_called_; |
| 261 } | 228 } |
| 262 | 229 |
| 263 const ProxyServer& proxy_server() const { | 230 const ProxyServer& proxy_server() const { |
| 264 return proxy_server_; | 231 return proxy_server_; |
| 265 } | 232 } |
| 266 | 233 |
| 267 int proxy_fallback_net_error() const { | 234 int proxy_fallback_net_error() const { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 ProxyInfo info; | 359 ProxyInfo info; |
| 393 TestCompletionCallback callback; | 360 TestCompletionCallback callback; |
| 394 BoundTestNetLog log; | 361 BoundTestNetLog log; |
| 395 | 362 |
| 396 // First, warm up the ProxyService. | 363 // First, warm up the ProxyService. |
| 397 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), | 364 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), |
| 398 NULL, NULL, log.bound()); | 365 NULL, NULL, log.bound()); |
| 399 EXPECT_EQ(OK, rv); | 366 EXPECT_EQ(OK, rv); |
| 400 | 367 |
| 401 // Verify that network delegate is invoked. | 368 // Verify that network delegate is invoked. |
| 402 TestResolveProxyDelegate delegate; | 369 TestResolveProxyNetworkDelegate delegate; |
| 403 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 370 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 404 &delegate, log.bound()); | 371 &delegate, log.bound()); |
| 405 EXPECT_TRUE(delegate.on_resolve_proxy_called()); | 372 EXPECT_TRUE(delegate.on_resolve_proxy_called()); |
| 406 EXPECT_EQ(&service, delegate.proxy_service()); | 373 EXPECT_EQ(&service, delegate.proxy_service()); |
| 407 | 374 |
| 408 // Verify that the ProxyDelegate's behavior is stateless across | 375 // Verify that the NetworkDelegate's behavior is stateless across |
| 409 // invocations of ResolveProxy. Start by having the callback add a proxy | 376 // invocations of ResolveProxy. Start by having the callback add a proxy |
| 410 // and checking that subsequent requests are not affected. | 377 // and checking that subsequent requests are not affected. |
| 411 delegate.set_add_proxy(true); | 378 delegate.set_add_proxy(true); |
| 412 | 379 |
| 413 // Callback should interpose: | 380 // Callback should interpose: |
| 414 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 381 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 415 &delegate, log.bound()); | 382 &delegate, log.bound()); |
| 416 EXPECT_FALSE(info.is_direct()); | 383 EXPECT_FALSE(info.is_direct()); |
| 417 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com"); | 384 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com"); |
| 418 delegate.set_add_proxy(false); | 385 delegate.set_add_proxy(false); |
| 419 | 386 |
| 420 // Check non-bypassed URL: | 387 // Check non-bypassed URL: |
| 421 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 388 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 422 &delegate, log.bound()); | 389 &delegate, log.bound()); |
| 423 EXPECT_FALSE(info.is_direct()); | 390 EXPECT_FALSE(info.is_direct()); |
| 424 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1"); | 391 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1"); |
| 425 | 392 |
| 426 // Check bypassed URL: | 393 // Check bypassed URL: |
| 427 rv = service.ResolveProxy(bypass_url, LOAD_NORMAL, &info, callback.callback(), | 394 rv = service.ResolveProxy(bypass_url, LOAD_NORMAL, &info, callback.callback(), |
| 428 NULL, &delegate, log.bound()); | 395 NULL, &delegate, log.bound()); |
| 429 EXPECT_TRUE(info.is_direct()); | 396 EXPECT_TRUE(info.is_direct()); |
| 430 } | 397 } |
| 431 | 398 |
| 432 TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) { | 399 TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) { |
| 433 // Same as OnResolveProxyCallbackAddProxy, but verify that the | 400 // Same as OnResolveProxyCallbackAddProxy, but verify that the |
| 434 // ProxyDelegate's behavior is stateless across invocations after it | 401 // NetworkDelegate's behavior is stateless across invocations after it |
| 435 // *removes* a proxy. | 402 // *removes* a proxy. |
| 436 ProxyConfig config; | 403 ProxyConfig config; |
| 437 config.proxy_rules().ParseFromString("foopy1:8080"); | 404 config.proxy_rules().ParseFromString("foopy1:8080"); |
| 438 config.set_auto_detect(false); | 405 config.set_auto_detect(false); |
| 439 config.proxy_rules().bypass_rules.ParseFromString("*.org"); | 406 config.proxy_rules().bypass_rules.ParseFromString("*.org"); |
| 440 | 407 |
| 441 ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)), | 408 ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)), |
| 442 nullptr, NULL); | 409 nullptr, NULL); |
| 443 | 410 |
| 444 GURL url("http://www.google.com/"); | 411 GURL url("http://www.google.com/"); |
| 445 GURL bypass_url("http://internet.org"); | 412 GURL bypass_url("http://internet.org"); |
| 446 | 413 |
| 447 ProxyInfo info; | 414 ProxyInfo info; |
| 448 TestCompletionCallback callback; | 415 TestCompletionCallback callback; |
| 449 BoundTestNetLog log; | 416 BoundTestNetLog log; |
| 450 | 417 |
| 451 // First, warm up the ProxyService. | 418 // First, warm up the ProxyService. |
| 452 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), | 419 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), |
| 453 NULL, NULL, log.bound()); | 420 NULL, NULL, log.bound()); |
| 454 EXPECT_EQ(OK, rv); | 421 EXPECT_EQ(OK, rv); |
| 455 | 422 |
| 456 TestResolveProxyDelegate delegate; | 423 TestResolveProxyNetworkDelegate delegate; |
| 457 delegate.set_remove_proxy(true); | 424 delegate.set_remove_proxy(true); |
| 458 | 425 |
| 459 // Callback should interpose: | 426 // Callback should interpose: |
| 460 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 427 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 461 &delegate, log.bound()); | 428 &delegate, log.bound()); |
| 462 EXPECT_TRUE(info.is_direct()); | 429 EXPECT_TRUE(info.is_direct()); |
| 463 delegate.set_remove_proxy(false); | 430 delegate.set_remove_proxy(false); |
| 464 | 431 |
| 465 // Check non-bypassed URL: | 432 // Check non-bypassed URL: |
| 466 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 433 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 EXPECT_EQ("foopy:8080", info.proxy_server().ToURI()); | 569 EXPECT_EQ("foopy:8080", info.proxy_server().ToURI()); |
| 603 EXPECT_TRUE(info.did_use_pac_script()); | 570 EXPECT_TRUE(info.did_use_pac_script()); |
| 604 | 571 |
| 605 EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); | 572 EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); |
| 606 EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); | 573 EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); |
| 607 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time()); | 574 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time()); |
| 608 | 575 |
| 609 // Now, imagine that connecting to foopy:8080 fails: there is nothing | 576 // Now, imagine that connecting to foopy:8080 fails: there is nothing |
| 610 // left to fallback to, since our proxy list was NOT terminated by | 577 // left to fallback to, since our proxy list was NOT terminated by |
| 611 // DIRECT. | 578 // DIRECT. |
| 612 TestResolveProxyDelegate proxy_delegate; | 579 NetworkDelegateImpl network_delegate; |
| 613 TestCompletionCallback callback2; | 580 TestCompletionCallback callback2; |
| 614 ProxyServer expected_proxy_server = info.proxy_server(); | 581 ProxyServer expected_proxy_server = info.proxy_server(); |
| 615 rv = service.ReconsiderProxyAfterError( | 582 rv = service.ReconsiderProxyAfterError( |
| 616 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 583 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 617 callback2.callback(), NULL, &proxy_delegate, BoundNetLog()); | 584 callback2.callback(), NULL, &network_delegate, BoundNetLog()); |
| 618 // ReconsiderProxyAfterError returns error indicating nothing left. | 585 // ReconsiderProxyAfterError returns error indicating nothing left. |
| 619 EXPECT_EQ(ERR_FAILED, rv); | 586 EXPECT_EQ(ERR_FAILED, rv); |
| 620 EXPECT_TRUE(info.is_empty()); | 587 EXPECT_TRUE(info.is_empty()); |
| 621 } | 588 } |
| 622 | 589 |
| 623 // Test that if the execution of the PAC script fails (i.e. javascript runtime | 590 // Test that if the execution of the PAC script fails (i.e. javascript runtime |
| 624 // error), and the PAC settings are non-mandatory, that we fall-back to direct. | 591 // error), and the PAC settings are non-mandatory, that we fall-back to direct. |
| 625 TEST_F(ProxyServiceTest, PAC_RuntimeError) { | 592 TEST_F(ProxyServiceTest, PAC_RuntimeError) { |
| 626 MockProxyConfigService* config_service = | 593 MockProxyConfigService* config_service = |
| 627 new MockProxyConfigService("http://foopy/proxy.pac"); | 594 new MockProxyConfigService("http://foopy/proxy.pac"); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 // Fallback 1. | 683 // Fallback 1. |
| 717 TestCompletionCallback callback2; | 684 TestCompletionCallback callback2; |
| 718 rv = service.ReconsiderProxyAfterError( | 685 rv = service.ReconsiderProxyAfterError( |
| 719 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 686 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 720 callback2.callback(), NULL, NULL, BoundNetLog()); | 687 callback2.callback(), NULL, NULL, BoundNetLog()); |
| 721 EXPECT_EQ(OK, rv); | 688 EXPECT_EQ(OK, rv); |
| 722 EXPECT_FALSE(info.is_direct()); | 689 EXPECT_FALSE(info.is_direct()); |
| 723 EXPECT_EQ("foobar:10", info.proxy_server().ToURI()); | 690 EXPECT_EQ("foobar:10", info.proxy_server().ToURI()); |
| 724 | 691 |
| 725 // Fallback 2. | 692 // Fallback 2. |
| 726 TestResolveProxyDelegate proxy_delegate; | 693 NetworkDelegateImpl network_delegate; |
| 727 ProxyServer expected_proxy_server3 = info.proxy_server(); | 694 ProxyServer expected_proxy_server3 = info.proxy_server(); |
| 728 TestCompletionCallback callback3; | 695 TestCompletionCallback callback3; |
| 729 rv = service.ReconsiderProxyAfterError( | 696 rv = service.ReconsiderProxyAfterError( |
| 730 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 697 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 731 callback3.callback(), NULL, &proxy_delegate, BoundNetLog()); | 698 callback3.callback(), NULL, &network_delegate, BoundNetLog()); |
| 732 EXPECT_EQ(OK, rv); | 699 EXPECT_EQ(OK, rv); |
| 733 EXPECT_TRUE(info.is_direct()); | 700 EXPECT_TRUE(info.is_direct()); |
| 734 | 701 |
| 735 // Fallback 3. | 702 // Fallback 3. |
| 736 ProxyServer expected_proxy_server4 = info.proxy_server(); | 703 ProxyServer expected_proxy_server4 = info.proxy_server(); |
| 737 TestCompletionCallback callback4; | 704 TestCompletionCallback callback4; |
| 738 rv = service.ReconsiderProxyAfterError( | 705 rv = service.ReconsiderProxyAfterError( |
| 739 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 706 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 740 callback4.callback(), NULL, &proxy_delegate, BoundNetLog()); | 707 callback4.callback(), NULL, &network_delegate, BoundNetLog()); |
| 741 EXPECT_EQ(OK, rv); | 708 EXPECT_EQ(OK, rv); |
| 742 EXPECT_FALSE(info.is_direct()); | 709 EXPECT_FALSE(info.is_direct()); |
| 743 EXPECT_EQ("foobar:20", info.proxy_server().ToURI()); | 710 EXPECT_EQ("foobar:20", info.proxy_server().ToURI()); |
| 744 | 711 |
| 745 // Fallback 4 -- Nothing to fall back to! | 712 // Fallback 4 -- Nothing to fall back to! |
| 746 ProxyServer expected_proxy_server5 = info.proxy_server(); | 713 ProxyServer expected_proxy_server5 = info.proxy_server(); |
| 747 TestCompletionCallback callback5; | 714 TestCompletionCallback callback5; |
| 748 rv = service.ReconsiderProxyAfterError( | 715 rv = service.ReconsiderProxyAfterError( |
| 749 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 716 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 750 callback5.callback(), NULL, &proxy_delegate, BoundNetLog()); | 717 callback5.callback(), NULL, &network_delegate, BoundNetLog()); |
| 751 EXPECT_EQ(ERR_FAILED, rv); | 718 EXPECT_EQ(ERR_FAILED, rv); |
| 752 EXPECT_TRUE(info.is_empty()); | 719 EXPECT_TRUE(info.is_empty()); |
| 753 } | 720 } |
| 754 | 721 |
| 755 TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) { | 722 TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) { |
| 756 // Test whether the ProxyConfigSource set by the ProxyConfigService is applied | 723 // Test whether the ProxyConfigSource set by the ProxyConfigService is applied |
| 757 // to ProxyInfo after the proxy is resolved via a PAC script. | 724 // to ProxyInfo after the proxy is resolved via a PAC script. |
| 758 ProxyConfig config = | 725 ProxyConfig config = |
| 759 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac")); | 726 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac")); |
| 760 config.set_source(PROXY_CONFIG_SOURCE_TEST); | 727 config.set_source(PROXY_CONFIG_SOURCE_TEST); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 EXPECT_EQ(OK, rv); | 1168 EXPECT_EQ(OK, rv); |
| 1202 | 1169 |
| 1203 // Proxy times should not have been modified by fallback. | 1170 // Proxy times should not have been modified by fallback. |
| 1204 EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time()); | 1171 EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time()); |
| 1205 EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time()); | 1172 EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time()); |
| 1206 | 1173 |
| 1207 // The second proxy should be specified. | 1174 // The second proxy should be specified. |
| 1208 EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI()); | 1175 EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI()); |
| 1209 // Report back that the second proxy worked. This will globally mark the | 1176 // Report back that the second proxy worked. This will globally mark the |
| 1210 // first proxy as bad. | 1177 // first proxy as bad. |
| 1211 TestProxyFallbackProxyDelegate test_delegate; | 1178 TestProxyFallbackNetworkDelegate test_delegate; |
| 1212 service.ReportSuccess(info, &test_delegate); | 1179 service.ReportSuccess(info, &test_delegate); |
| 1213 EXPECT_EQ("foopy1:8080", test_delegate.proxy_server().ToURI()); | 1180 EXPECT_EQ("foopy1:8080", test_delegate.proxy_server().ToURI()); |
| 1214 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, | 1181 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, |
| 1215 test_delegate.proxy_fallback_net_error()); | 1182 test_delegate.proxy_fallback_net_error()); |
| 1216 | 1183 |
| 1217 TestCompletionCallback callback3; | 1184 TestCompletionCallback callback3; |
| 1218 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback3.callback(), NULL, | 1185 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback3.callback(), NULL, |
| 1219 NULL, BoundNetLog()); | 1186 NULL, BoundNetLog()); |
| 1220 EXPECT_EQ(ERR_IO_PENDING, rv); | 1187 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1221 | 1188 |
| (...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3410 url, LOAD_NORMAL, &info, NULL, log.bound()); | 3377 url, LOAD_NORMAL, &info, NULL, log.bound()); |
| 3411 EXPECT_TRUE(synchronous_success); | 3378 EXPECT_TRUE(synchronous_success); |
| 3412 EXPECT_FALSE(info.is_direct()); | 3379 EXPECT_FALSE(info.is_direct()); |
| 3413 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); | 3380 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); |
| 3414 | 3381 |
| 3415 // No request should have been queued. | 3382 // No request should have been queued. |
| 3416 EXPECT_EQ(0u, factory->pending_requests().size()); | 3383 EXPECT_EQ(0u, factory->pending_requests().size()); |
| 3417 } | 3384 } |
| 3418 | 3385 |
| 3419 } // namespace net | 3386 } // namespace net |
| OLD | NEW |