Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 | 545 |
| 546 int ProxyService::TryToCompleteSynchronously(const GURL& url, | 546 int ProxyService::TryToCompleteSynchronously(const GURL& url, |
| 547 ProxyInfo* result) { | 547 ProxyInfo* result) { |
| 548 DCHECK_NE(STATE_NONE, current_state_); | 548 DCHECK_NE(STATE_NONE, current_state_); |
| 549 | 549 |
| 550 if (current_state_ != STATE_READY) | 550 if (current_state_ != STATE_READY) |
| 551 return ERR_IO_PENDING; // Still initializing. | 551 return ERR_IO_PENDING; // Still initializing. |
| 552 | 552 |
| 553 DCHECK_NE(config_.id(), ProxyConfig::INVALID_ID); | 553 DCHECK_NE(config_.id(), ProxyConfig::INVALID_ID); |
| 554 | 554 |
| 555 if (config_.block_everything()) | |
| 556 return ERR_PROXY_CONNECTION_FAILED; | |
|
eroman
2011/04/26 21:47:17
Should use a more specific error code here.
battre
2011/04/27 17:02:58
Done.
| |
| 557 | |
| 555 if (config_.HasAutomaticSettings()) | 558 if (config_.HasAutomaticSettings()) |
| 556 return ERR_IO_PENDING; // Must submit the request to the proxy resolver. | 559 return ERR_IO_PENDING; // Must submit the request to the proxy resolver. |
| 557 | 560 |
| 558 // Use the manual proxy settings. | 561 // Use the manual proxy settings. |
| 559 config_.proxy_rules().Apply(url, result); | 562 config_.proxy_rules().Apply(url, result); |
| 560 result->config_id_ = config_.id(); | 563 result->config_id_ = config_.id(); |
| 561 return OK; | 564 return OK; |
| 562 } | 565 } |
| 563 | 566 |
| 564 ProxyService::~ProxyService() { | 567 ProxyService::~ProxyService() { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 635 OnProxyConfigChanged(config, availability); | 638 OnProxyConfigChanged(config, availability); |
| 636 } | 639 } |
| 637 | 640 |
| 638 void ProxyService::OnInitProxyResolverComplete(int result) { | 641 void ProxyService::OnInitProxyResolverComplete(int result) { |
| 639 DCHECK_EQ(STATE_WAITING_FOR_INIT_PROXY_RESOLVER, current_state_); | 642 DCHECK_EQ(STATE_WAITING_FOR_INIT_PROXY_RESOLVER, current_state_); |
| 640 DCHECK(init_proxy_resolver_.get()); | 643 DCHECK(init_proxy_resolver_.get()); |
| 641 DCHECK(fetched_config_.HasAutomaticSettings()); | 644 DCHECK(fetched_config_.HasAutomaticSettings()); |
| 642 init_proxy_resolver_.reset(); | 645 init_proxy_resolver_.reset(); |
| 643 | 646 |
| 644 if (result != OK) { | 647 if (result != OK) { |
| 645 VLOG(1) << "Failed configuring with PAC script, falling-back to manual " | 648 if (fetched_config_.pac_mandatory()) { |
| 646 "proxy servers."; | 649 VLOG(1) << "Failed configuring with mandatory PAC script, blocking all " |
| 647 config_ = fetched_config_; | 650 "traffic."; |
| 648 config_.ClearAutomaticSettings(); | 651 config_ = fetched_config_; |
| 652 config_.set_block_everything(true); | |
| 653 } else { | |
| 654 VLOG(1) << "Failed configuring with PAC script, falling-back to manual " | |
| 655 "proxy servers."; | |
| 656 config_ = fetched_config_; | |
| 657 config_.ClearAutomaticSettings(); | |
| 658 } | |
| 649 } | 659 } |
| 650 | 660 |
| 651 config_.set_id(fetched_config_.id()); | 661 config_.set_id(fetched_config_.id()); |
| 652 | 662 |
| 653 // Resume any requests which we had to defer until the PAC script was | 663 // Resume any requests which we had to defer until the PAC script was |
| 654 // downloaded. | 664 // downloaded. |
| 655 SetReady(); | 665 SetReady(); |
| 656 } | 666 } |
| 657 | 667 |
| 658 int ProxyService::ReconsiderProxyAfterError(const GURL& url, | 668 int ProxyService::ReconsiderProxyAfterError(const GURL& url, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 make_scoped_refptr(new NetLogStringParameter( | 726 make_scoped_refptr(new NetLogStringParameter( |
| 717 "pac_string", result->ToPacString()))); | 727 "pac_string", result->ToPacString()))); |
| 718 } | 728 } |
| 719 result->DeprioritizeBadProxies(proxy_retry_info_); | 729 result->DeprioritizeBadProxies(proxy_retry_info_); |
| 720 } else { | 730 } else { |
| 721 net_log.AddEvent( | 731 net_log.AddEvent( |
| 722 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, | 732 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, |
| 723 make_scoped_refptr(new NetLogIntegerParameter( | 733 make_scoped_refptr(new NetLogIntegerParameter( |
| 724 "net_error", result_code))); | 734 "net_error", result_code))); |
| 725 | 735 |
| 726 // Fall-back to direct when the proxy resolver fails. This corresponds | 736 if (!config_.pac_mandatory()) { |
| 727 // with a javascript runtime error in the PAC script. | 737 // Fall-back to direct when the proxy resolver fails. This corresponds |
| 728 // | 738 // with a javascript runtime error in the PAC script. |
| 729 // This implicit fall-back to direct matches Firefox 3.5 and | 739 // |
| 730 // Internet Explorer 8. For more information, see: | 740 // This implicit fall-back to direct matches Firefox 3.5 and |
| 731 // | 741 // Internet Explorer 8. For more information, see: |
| 732 // http://www.chromium.org/developers/design-documents/proxy-settings-fallba ck | 742 // |
| 733 result->UseDirect(); | 743 // http://www.chromium.org/developers/design-documents/proxy-settings-fall back |
| 734 result_code = OK; | 744 result->UseDirect(); |
| 745 result_code = OK; | |
| 746 } else { | |
| 747 result_code = ERR_PROXY_CONNECTION_FAILED; | |
|
eroman
2011/04/26 21:47:17
Use a more specific error code.
battre
2011/04/27 17:02:58
Done.
| |
| 748 } | |
| 735 } | 749 } |
| 736 | 750 |
| 737 net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL); | 751 net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL); |
| 738 return result_code; | 752 return result_code; |
| 739 } | 753 } |
| 740 | 754 |
| 741 void ProxyService::SetProxyScriptFetcher( | 755 void ProxyService::SetProxyScriptFetcher( |
| 742 ProxyScriptFetcher* proxy_script_fetcher) { | 756 ProxyScriptFetcher* proxy_script_fetcher) { |
| 743 DCHECK(CalledOnValidThread()); | 757 DCHECK(CalledOnValidThread()); |
| 744 State previous_state = ResetProxyConfig(false); | 758 State previous_state = ResetProxyConfig(false); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 OnCompletion(result_); | 988 OnCompletion(result_); |
| 975 } | 989 } |
| 976 } | 990 } |
| 977 | 991 |
| 978 void SyncProxyServiceHelper::OnCompletion(int rv) { | 992 void SyncProxyServiceHelper::OnCompletion(int rv) { |
| 979 result_ = rv; | 993 result_ = rv; |
| 980 event_.Signal(); | 994 event_.Signal(); |
| 981 } | 995 } |
| 982 | 996 |
| 983 } // namespace net | 997 } // namespace net |
| OLD | NEW |