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

Side by Side Diff: net/proxy/proxy_service.cc

Issue 332313003: Add Finch experiment for selectively bypassing proxies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address mmenke's feedback R2 Created 6 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 unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/message_loop/message_loop_proxy.h" 15 #include "base/message_loop/message_loop_proxy.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/metrics/sparse_histogram.h" 17 #include "base/metrics/sparse_histogram.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "net/base/completion_callback.h" 21 #include "net/base/completion_callback.h"
22 #include "net/base/load_flags.h"
22 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
23 #include "net/base/net_log.h" 24 #include "net/base/net_log.h"
24 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
25 #include "net/proxy/dhcp_proxy_script_fetcher.h" 26 #include "net/proxy/dhcp_proxy_script_fetcher.h"
26 #include "net/proxy/multi_threaded_proxy_resolver.h" 27 #include "net/proxy/multi_threaded_proxy_resolver.h"
27 #include "net/proxy/network_delegate_error_observer.h" 28 #include "net/proxy/network_delegate_error_observer.h"
28 #include "net/proxy/proxy_config_service_fixed.h" 29 #include "net/proxy/proxy_config_service_fixed.h"
29 #include "net/proxy/proxy_resolver.h" 30 #include "net/proxy/proxy_resolver.h"
30 #include "net/proxy/proxy_script_decider.h" 31 #include "net/proxy/proxy_script_decider.h"
31 #include "net/proxy/proxy_script_fetcher.h" 32 #include "net/proxy/proxy_script_fetcher.h"
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 const ProxyService::PacPollPolicy* 728 const ProxyService::PacPollPolicy*
728 ProxyService::ProxyScriptDeciderPoller::poll_policy_ = NULL; 729 ProxyService::ProxyScriptDeciderPoller::poll_policy_ = NULL;
729 730
730 // ProxyService::PacRequest --------------------------------------------------- 731 // ProxyService::PacRequest ---------------------------------------------------
731 732
732 class ProxyService::PacRequest 733 class ProxyService::PacRequest
733 : public base::RefCounted<ProxyService::PacRequest> { 734 : public base::RefCounted<ProxyService::PacRequest> {
734 public: 735 public:
735 PacRequest(ProxyService* service, 736 PacRequest(ProxyService* service,
736 const GURL& url, 737 const GURL& url,
738 int load_flags,
739 NetworkDelegate* network_delegate,
737 ProxyInfo* results, 740 ProxyInfo* results,
738 const net::CompletionCallback& user_callback, 741 const net::CompletionCallback& user_callback,
739 const BoundNetLog& net_log) 742 const BoundNetLog& net_log)
740 : service_(service), 743 : service_(service),
741 user_callback_(user_callback), 744 user_callback_(user_callback),
742 results_(results), 745 results_(results),
743 url_(url), 746 url_(url),
747 load_flags_(load_flags),
748 network_delegate_(network_delegate),
744 resolve_job_(NULL), 749 resolve_job_(NULL),
745 config_id_(ProxyConfig::kInvalidConfigID), 750 config_id_(ProxyConfig::kInvalidConfigID),
746 config_source_(PROXY_CONFIG_SOURCE_UNKNOWN), 751 config_source_(PROXY_CONFIG_SOURCE_UNKNOWN),
747 net_log_(net_log) { 752 net_log_(net_log) {
748 DCHECK(!user_callback.is_null()); 753 DCHECK(!user_callback.is_null());
749 } 754 }
750 755
751 // Starts the resolve proxy request. 756 // Starts the resolve proxy request.
752 int Start() { 757 int Start() {
753 DCHECK(!was_cancelled()); 758 DCHECK(!was_cancelled());
(...skipping 10 matching lines...) Expand all
764 base::Bind(&PacRequest::QueryComplete, base::Unretained(this)), 769 base::Bind(&PacRequest::QueryComplete, base::Unretained(this)),
765 &resolve_job_, net_log_); 770 &resolve_job_, net_log_);
766 } 771 }
767 772
768 bool is_started() const { 773 bool is_started() const {
769 // Note that !! casts to bool. (VS gives a warning otherwise). 774 // Note that !! casts to bool. (VS gives a warning otherwise).
770 return !!resolve_job_; 775 return !!resolve_job_;
771 } 776 }
772 777
773 void StartAndCompleteCheckingForSynchronous() { 778 void StartAndCompleteCheckingForSynchronous() {
774 int rv = service_->TryToCompleteSynchronously(url_, results_); 779 int rv = service_->TryToCompleteSynchronously(url_, load_flags_,
780 network_delegate_, results_);
775 if (rv == ERR_IO_PENDING) 781 if (rv == ERR_IO_PENDING)
776 rv = Start(); 782 rv = Start();
777 if (rv != ERR_IO_PENDING) 783 if (rv != ERR_IO_PENDING)
778 QueryComplete(rv); 784 QueryComplete(rv);
779 } 785 }
780 786
781 void CancelResolveJob() { 787 void CancelResolveJob() {
782 DCHECK(is_started()); 788 DCHECK(is_started());
783 // The request may already be running in the resolver. 789 // The request may already be running in the resolver.
784 resolver()->CancelRequest(resolve_job_); 790 resolver()->CancelRequest(resolve_job_);
(...skipping 19 matching lines...) Expand all
804 bool was_cancelled() const { 810 bool was_cancelled() const {
805 return user_callback_.is_null(); 811 return user_callback_.is_null();
806 } 812 }
807 813
808 // Helper to call after ProxyResolver completion (both synchronous and 814 // Helper to call after ProxyResolver completion (both synchronous and
809 // asynchronous). Fixes up the result that is to be returned to user. 815 // asynchronous). Fixes up the result that is to be returned to user.
810 int QueryDidComplete(int result_code) { 816 int QueryDidComplete(int result_code) {
811 DCHECK(!was_cancelled()); 817 DCHECK(!was_cancelled());
812 818
813 // Note that DidFinishResolvingProxy might modify |results_|. 819 // Note that DidFinishResolvingProxy might modify |results_|.
814 int rv = service_->DidFinishResolvingProxy(results_, result_code, net_log_); 820 int rv = service_->DidFinishResolvingProxy(url_, load_flags_,
821 network_delegate_, results_,
822 result_code, net_log_);
815 823
816 // Make a note in the results which configuration was in use at the 824 // Make a note in the results which configuration was in use at the
817 // time of the resolve. 825 // time of the resolve.
818 results_->config_id_ = config_id_; 826 results_->config_id_ = config_id_;
819 results_->config_source_ = config_source_; 827 results_->config_source_ = config_source_;
820 results_->did_use_pac_script_ = true; 828 results_->did_use_pac_script_ = true;
821 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_; 829 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_;
822 results_->proxy_resolve_end_time_ = TimeTicks::Now(); 830 results_->proxy_resolve_end_time_ = TimeTicks::Now();
823 831
824 // Reset the state associated with in-progress-resolve. 832 // Reset the state associated with in-progress-resolve.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 865
858 ProxyResolver* resolver() const { return service_->resolver_.get(); } 866 ProxyResolver* resolver() const { return service_->resolver_.get(); }
859 867
860 // Note that we don't hold a reference to the ProxyService. Outstanding 868 // Note that we don't hold a reference to the ProxyService. Outstanding
861 // requests are cancelled during ~ProxyService, so this is guaranteed 869 // requests are cancelled during ~ProxyService, so this is guaranteed
862 // to be valid throughout our lifetime. 870 // to be valid throughout our lifetime.
863 ProxyService* service_; 871 ProxyService* service_;
864 net::CompletionCallback user_callback_; 872 net::CompletionCallback user_callback_;
865 ProxyInfo* results_; 873 ProxyInfo* results_;
866 GURL url_; 874 GURL url_;
875 int load_flags_;
876 NetworkDelegate* network_delegate_;
867 ProxyResolver::RequestHandle resolve_job_; 877 ProxyResolver::RequestHandle resolve_job_;
868 ProxyConfig::ID config_id_; // The config id when the resolve was started. 878 ProxyConfig::ID config_id_; // The config id when the resolve was started.
869 ProxyConfigSource config_source_; // The source of proxy settings. 879 ProxyConfigSource config_source_; // The source of proxy settings.
870 BoundNetLog net_log_; 880 BoundNetLog net_log_;
871 // Time when the PAC is started. Cached here since resetting ProxyInfo also 881 // Time when the PAC is started. Cached here since resetting ProxyInfo also
872 // clears the proxy times. 882 // clears the proxy times.
873 TimeTicks proxy_resolve_start_time_; 883 TimeTicks proxy_resolve_start_time_;
874 }; 884 };
875 885
876 // ProxyService --------------------------------------------------------------- 886 // ProxyService ---------------------------------------------------------------
877 887
878 ProxyService::ProxyService(ProxyConfigService* config_service, 888 ProxyService::ProxyService(ProxyConfigService* config_service,
879 ProxyResolver* resolver, 889 ProxyResolver* resolver,
880 NetLog* net_log) 890 NetLog* net_log)
881 : resolver_(resolver), 891 : resolver_(resolver),
882 next_config_id_(1), 892 next_config_id_(1),
883 current_state_(STATE_NONE) , 893 current_state_(STATE_NONE),
884 net_log_(net_log), 894 net_log_(net_log),
885 stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds( 895 stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds(
886 kDelayAfterNetworkChangesMs)), 896 kDelayAfterNetworkChangesMs)),
887 quick_check_enabled_(true) { 897 quick_check_enabled_(true) {
888 NetworkChangeNotifier::AddIPAddressObserver(this); 898 NetworkChangeNotifier::AddIPAddressObserver(this);
889 NetworkChangeNotifier::AddDNSObserver(this); 899 NetworkChangeNotifier::AddDNSObserver(this);
890 ResetConfigService(config_service); 900 ResetConfigService(config_service);
891 } 901 }
892 902
893 // static 903 // static
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 968
959 scoped_ptr<ProxyResolver> proxy_resolver( 969 scoped_ptr<ProxyResolver> proxy_resolver(
960 new ProxyResolverFromPacString(pac_string)); 970 new ProxyResolverFromPacString(pac_string));
961 971
962 return new ProxyService(proxy_config_service.release(), 972 return new ProxyService(proxy_config_service.release(),
963 proxy_resolver.release(), 973 proxy_resolver.release(),
964 NULL); 974 NULL);
965 } 975 }
966 976
967 int ProxyService::ResolveProxy(const GURL& raw_url, 977 int ProxyService::ResolveProxy(const GURL& raw_url,
978 int load_flags,
968 ProxyInfo* result, 979 ProxyInfo* result,
969 const net::CompletionCallback& callback, 980 const net::CompletionCallback& callback,
970 PacRequest** pac_request, 981 PacRequest** pac_request,
982 NetworkDelegate* network_delegate,
971 const BoundNetLog& net_log) { 983 const BoundNetLog& net_log) {
972 DCHECK(CalledOnValidThread()); 984 DCHECK(CalledOnValidThread());
973 DCHECK(!callback.is_null()); 985 DCHECK(!callback.is_null());
974 986
975 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE); 987 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE);
976 988
977 // Notify our polling-based dependencies that a resolve is taking place. 989 // Notify our polling-based dependencies that a resolve is taking place.
978 // This way they can schedule their polls in response to network activity. 990 // This way they can schedule their polls in response to network activity.
979 config_service_->OnLazyPoll(); 991 config_service_->OnLazyPoll();
980 if (script_poller_.get()) 992 if (script_poller_.get())
981 script_poller_->OnLazyPoll(); 993 script_poller_->OnLazyPoll();
982 994
983 if (current_state_ == STATE_NONE) 995 if (current_state_ == STATE_NONE)
984 ApplyProxyConfigIfAvailable(); 996 ApplyProxyConfigIfAvailable();
985 997
986 // Strip away any reference fragments and the username/password, as they 998 // Strip away any reference fragments and the username/password, as they
987 // are not relevant to proxy resolution. 999 // are not relevant to proxy resolution.
988 GURL url = SimplifyUrlForRequest(raw_url); 1000 GURL url = SimplifyUrlForRequest(raw_url);
989 1001
990 // Check if the request can be completed right away. (This is the case when 1002 // Check if the request can be completed right away. (This is the case when
991 // using a direct connection for example). 1003 // using a direct connection for example).
992 int rv = TryToCompleteSynchronously(url, result); 1004 int rv = TryToCompleteSynchronously(url, load_flags,
1005 network_delegate, result);
993 if (rv != ERR_IO_PENDING) 1006 if (rv != ERR_IO_PENDING)
994 return DidFinishResolvingProxy(result, rv, net_log); 1007 return DidFinishResolvingProxy(url, load_flags, network_delegate,
1008 result, rv, net_log);
995 1009
996 scoped_refptr<PacRequest> req( 1010 scoped_refptr<PacRequest> req(
997 new PacRequest(this, url, result, callback, net_log)); 1011 new PacRequest(this, url, load_flags, network_delegate,
1012 result, callback, net_log));
998 1013
999 if (current_state_ == STATE_READY) { 1014 if (current_state_ == STATE_READY) {
1000 // Start the resolve request. 1015 // Start the resolve request.
1001 rv = req->Start(); 1016 rv = req->Start();
1002 if (rv != ERR_IO_PENDING) 1017 if (rv != ERR_IO_PENDING)
1003 return req->QueryDidComplete(rv); 1018 return req->QueryDidComplete(rv);
1004 } else { 1019 } else {
1005 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); 1020 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
1006 } 1021 }
1007 1022
1008 DCHECK_EQ(ERR_IO_PENDING, rv); 1023 DCHECK_EQ(ERR_IO_PENDING, rv);
1009 DCHECK(!ContainsPendingRequest(req.get())); 1024 DCHECK(!ContainsPendingRequest(req.get()));
1010 pending_requests_.push_back(req); 1025 pending_requests_.push_back(req);
1011 1026
1012 // Completion will be notified through |callback|, unless the caller cancels 1027 // Completion will be notified through |callback|, unless the caller cancels
1013 // the request using |pac_request|. 1028 // the request using |pac_request|.
1014 if (pac_request) 1029 if (pac_request)
1015 *pac_request = req.get(); 1030 *pac_request = req.get();
1016 return rv; // ERR_IO_PENDING 1031 return rv; // ERR_IO_PENDING
1017 } 1032 }
1018 1033
1019 int ProxyService::TryToCompleteSynchronously(const GURL& url, 1034 int ProxyService::TryToCompleteSynchronously(const GURL& url,
1035 int load_flags,
1036 NetworkDelegate* network_delegate,
1020 ProxyInfo* result) { 1037 ProxyInfo* result) {
1021 DCHECK_NE(STATE_NONE, current_state_); 1038 DCHECK_NE(STATE_NONE, current_state_);
1022 1039
1023 if (current_state_ != STATE_READY) 1040 if (current_state_ != STATE_READY)
1024 return ERR_IO_PENDING; // Still initializing. 1041 return ERR_IO_PENDING; // Still initializing.
1025 1042
1026 DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID); 1043 DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID);
1027 1044
1028 // If it was impossible to fetch or parse the PAC script, we cannot complete 1045 // If it was impossible to fetch or parse the PAC script, we cannot complete
1029 // the request here and bail out. 1046 // the request here and bail out.
1030 if (permanent_error_ != OK) 1047 if (permanent_error_ != OK)
1031 return permanent_error_; 1048 return permanent_error_;
1032 1049
1033 if (config_.HasAutomaticSettings()) 1050 if (config_.HasAutomaticSettings())
1034 return ERR_IO_PENDING; // Must submit the request to the proxy resolver. 1051 return ERR_IO_PENDING; // Must submit the request to the proxy resolver.
1035 1052
1036 // Use the manual proxy settings. 1053 // Use the manual proxy settings.
1037 config_.proxy_rules().Apply(url, result); 1054 config_.proxy_rules().Apply(url, result);
1038 result->config_source_ = config_.source(); 1055 result->config_source_ = config_.source();
1039 result->config_id_ = config_.id(); 1056 result->config_id_ = config_.id();
1057
1040 return OK; 1058 return OK;
1041 } 1059 }
1042 1060
1043 ProxyService::~ProxyService() { 1061 ProxyService::~ProxyService() {
1044 NetworkChangeNotifier::RemoveIPAddressObserver(this); 1062 NetworkChangeNotifier::RemoveIPAddressObserver(this);
1045 NetworkChangeNotifier::RemoveDNSObserver(this); 1063 NetworkChangeNotifier::RemoveDNSObserver(this);
1046 config_service_->RemoveObserver(this); 1064 config_service_->RemoveObserver(this);
1047 1065
1048 // Cancel any inprogress requests. 1066 // Cancel any inprogress requests.
1049 for (PendingRequests::iterator it = pending_requests_.begin(); 1067 for (PendingRequests::iterator it = pending_requests_.begin();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 // due to ProxyScriptDeciderPoller. 1177 // due to ProxyScriptDeciderPoller.
1160 config_.set_id(fetched_config_.id()); 1178 config_.set_id(fetched_config_.id());
1161 config_.set_source(fetched_config_.source()); 1179 config_.set_source(fetched_config_.source());
1162 1180
1163 // Resume any requests which we had to defer until the PAC script was 1181 // Resume any requests which we had to defer until the PAC script was
1164 // downloaded. 1182 // downloaded.
1165 SetReady(); 1183 SetReady();
1166 } 1184 }
1167 1185
1168 int ProxyService::ReconsiderProxyAfterError(const GURL& url, 1186 int ProxyService::ReconsiderProxyAfterError(const GURL& url,
1187 int load_flags,
1169 int net_error, 1188 int net_error,
1170 ProxyInfo* result, 1189 ProxyInfo* result,
1171 const CompletionCallback& callback, 1190 const CompletionCallback& callback,
1172 PacRequest** pac_request, 1191 PacRequest** pac_request,
1192 NetworkDelegate* network_delegate,
1173 const BoundNetLog& net_log) { 1193 const BoundNetLog& net_log) {
1174 DCHECK(CalledOnValidThread()); 1194 DCHECK(CalledOnValidThread());
1175 1195
1176 // Check to see if we have a new config since ResolveProxy was called. We 1196 // Check to see if we have a new config since ResolveProxy was called. We
1177 // want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a 1197 // want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a
1178 // direct connection failed and we never tried the current config. 1198 // direct connection failed and we never tried the current config.
1179 1199
1180 bool re_resolve = result->config_id_ != config_.id(); 1200 bool re_resolve = result->config_id_ != config_.id();
1181 1201
1182 if (re_resolve) { 1202 if (re_resolve) {
1183 // If we have a new config or the config was never tried, we delete the 1203 // If we have a new config or the config was never tried, we delete the
1184 // list of bad proxies and we try again. 1204 // list of bad proxies and we try again.
1185 proxy_retry_info_.clear(); 1205 proxy_retry_info_.clear();
1186 return ResolveProxy(url, result, callback, pac_request, net_log); 1206 return ResolveProxy(url, load_flags, result, callback, pac_request,
1207 network_delegate, net_log);
1187 } 1208 }
1188 1209
1189 #if defined(SPDY_PROXY_AUTH_ORIGIN) 1210 #if defined(SPDY_PROXY_AUTH_ORIGIN)
1190 if (result->proxy_server().isDataReductionProxy()) { 1211 if (result->proxy_server().isDataReductionProxy()) {
1191 RecordDataReductionProxyBypassInfo( 1212 RecordDataReductionProxyBypassInfo(
1192 true, result->proxy_server(), ERROR_BYPASS); 1213 true, result->proxy_server(), ERROR_BYPASS);
1193 RecordDataReductionProxyBypassOnNetworkError( 1214 RecordDataReductionProxyBypassOnNetworkError(
1194 true, result->proxy_server(), net_error); 1215 true, result->proxy_server(), net_error);
1195 } else if (result->proxy_server().isDataReductionProxyFallback()) { 1216 } else if (result->proxy_server().isDataReductionProxyFallback()) {
1196 RecordDataReductionProxyBypassInfo( 1217 RecordDataReductionProxyBypassInfo(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 return pending_requests_.end() != it; 1287 return pending_requests_.end() != it;
1267 } 1288 }
1268 1289
1269 void ProxyService::RemovePendingRequest(PacRequest* req) { 1290 void ProxyService::RemovePendingRequest(PacRequest* req) {
1270 DCHECK(ContainsPendingRequest(req)); 1291 DCHECK(ContainsPendingRequest(req));
1271 PendingRequests::iterator it = std::find( 1292 PendingRequests::iterator it = std::find(
1272 pending_requests_.begin(), pending_requests_.end(), req); 1293 pending_requests_.begin(), pending_requests_.end(), req);
1273 pending_requests_.erase(it); 1294 pending_requests_.erase(it);
1274 } 1295 }
1275 1296
1276 int ProxyService::DidFinishResolvingProxy(ProxyInfo* result, 1297 int ProxyService::DidFinishResolvingProxy(const GURL& url,
1298 int load_flags,
1299 NetworkDelegate* network_delegate,
1300 ProxyInfo* result,
1277 int result_code, 1301 int result_code,
1278 const BoundNetLog& net_log) { 1302 const BoundNetLog& net_log) {
1279 // Log the result of the proxy resolution. 1303 // Log the result of the proxy resolution.
1280 if (result_code == OK) { 1304 if (result_code == OK) {
1305 // Allow the network delegate to interpose on the resolution decision,
1306 // possibly modifying the ProxyInfo.
1307 if (network_delegate)
1308 network_delegate->NotifyResolveProxy(url, load_flags, result);
1309
1281 // When logging all events is enabled, dump the proxy list. 1310 // When logging all events is enabled, dump the proxy list.
1282 if (net_log.IsLogging()) { 1311 if (net_log.IsLogging()) {
1283 net_log.AddEvent( 1312 net_log.AddEvent(
1284 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, 1313 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST,
1285 base::Bind(&NetLogFinishedResolvingProxyCallback, result)); 1314 base::Bind(&NetLogFinishedResolvingProxyCallback, result));
1286 } 1315 }
1287 result->DeprioritizeBadProxies(proxy_retry_info_); 1316 result->DeprioritizeBadProxies(proxy_retry_info_);
1288 } else { 1317 } else {
1289 net_log.AddEventWithNetErrorCode( 1318 net_log.AddEventWithNetErrorCode(
1290 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, result_code); 1319 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, result_code);
1291 1320
1292 if (!config_.pac_mandatory()) { 1321 if (!config_.pac_mandatory()) {
1293 // Fall-back to direct when the proxy resolver fails. This corresponds 1322 // Fall-back to direct when the proxy resolver fails. This corresponds
1294 // with a javascript runtime error in the PAC script. 1323 // with a javascript runtime error in the PAC script.
1295 // 1324 //
1296 // This implicit fall-back to direct matches Firefox 3.5 and 1325 // This implicit fall-back to direct matches Firefox 3.5 and
1297 // Internet Explorer 8. For more information, see: 1326 // Internet Explorer 8. For more information, see:
1298 // 1327 //
1299 // http://www.chromium.org/developers/design-documents/proxy-settings-fall back 1328 // http://www.chromium.org/developers/design-documents/proxy-settings-fall back
1300 result->UseDirect(); 1329 result->UseDirect();
1301 result_code = OK; 1330 result_code = OK;
1331
1332 // Allow the network delegate to interpose on the resolution decision,
1333 // possibly modifying the ProxyInfo.
1334 if (network_delegate)
1335 network_delegate->NotifyResolveProxy(url, load_flags, result);
1302 } else { 1336 } else {
1303 result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED; 1337 result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED;
1304 } 1338 }
1305 } 1339 }
1306 1340
1307 net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE); 1341 net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE);
1308 return result_code; 1342 return result_code;
1309 } 1343 }
1310 1344
1311 void ProxyService::SetProxyScriptFetchers( 1345 void ProxyService::SetProxyScriptFetchers(
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 *proxy_info = proxy_info_; 1650 *proxy_info = proxy_info_;
1617 } 1651 }
1618 return result_; 1652 return result_;
1619 } 1653 }
1620 1654
1621 SyncProxyServiceHelper::~SyncProxyServiceHelper() {} 1655 SyncProxyServiceHelper::~SyncProxyServiceHelper() {}
1622 1656
1623 void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url, 1657 void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url,
1624 const BoundNetLog& net_log) { 1658 const BoundNetLog& net_log) {
1625 result_ = proxy_service_->ResolveProxy( 1659 result_ = proxy_service_->ResolveProxy(
1626 url, &proxy_info_, callback_, NULL, net_log); 1660 url, net::LOAD_NORMAL, &proxy_info_, callback_, NULL, NULL, net_log);
1627 if (result_ != net::ERR_IO_PENDING) { 1661 if (result_ != net::ERR_IO_PENDING) {
1628 OnCompletion(result_); 1662 OnCompletion(result_);
1629 } 1663 }
1630 } 1664 }
1631 1665
1632 void SyncProxyServiceHelper::StartAsyncReconsider(const GURL& url, 1666 void SyncProxyServiceHelper::StartAsyncReconsider(const GURL& url,
1633 int net_error, 1667 int net_error,
1634 const BoundNetLog& net_log) { 1668 const BoundNetLog& net_log) {
1635 result_ = proxy_service_->ReconsiderProxyAfterError( 1669 result_ = proxy_service_->ReconsiderProxyAfterError(
1636 url, net_error, &proxy_info_, callback_, NULL, net_log); 1670 url, net::LOAD_NORMAL, net_error, &proxy_info_, callback_, NULL, NULL,
1671 net_log);
1637 if (result_ != net::ERR_IO_PENDING) { 1672 if (result_ != net::ERR_IO_PENDING) {
1638 OnCompletion(result_); 1673 OnCompletion(result_);
1639 } 1674 }
1640 } 1675 }
1641 1676
1642 void SyncProxyServiceHelper::OnCompletion(int rv) { 1677 void SyncProxyServiceHelper::OnCompletion(int rv) {
1643 result_ = rv; 1678 result_ = rv;
1644 event_.Signal(); 1679 event_.Signal();
1645 } 1680 }
1646 1681
1647 } // namespace net 1682 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698