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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
20 #include "base/metrics/sparse_histogram.h" | 20 #include "base/metrics/sparse_histogram.h" |
21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "base/values.h" | 25 #include "base/values.h" |
26 #include "net/base/completion_callback.h" | 26 #include "net/base/completion_callback.h" |
27 #include "net/base/load_flags.h" | |
28 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
29 #include "net/base/proxy_delegate.h" | 28 #include "net/base/proxy_delegate.h" |
30 #include "net/base/url_util.h" | 29 #include "net/base/url_util.h" |
31 #include "net/log/net_log.h" | 30 #include "net/log/net_log.h" |
32 #include "net/proxy/dhcp_proxy_script_fetcher.h" | 31 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
33 #include "net/proxy/multi_threaded_proxy_resolver.h" | 32 #include "net/proxy/multi_threaded_proxy_resolver.h" |
34 #include "net/proxy/proxy_config_service_fixed.h" | 33 #include "net/proxy/proxy_config_service_fixed.h" |
35 #include "net/proxy/proxy_resolver.h" | 34 #include "net/proxy/proxy_resolver.h" |
36 #include "net/proxy/proxy_resolver_factory.h" | 35 #include "net/proxy/proxy_resolver_factory.h" |
37 #include "net/proxy/proxy_script_decider.h" | 36 #include "net/proxy/proxy_script_decider.h" |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 ProxyService::ProxyScriptDeciderPoller::poll_policy_ = NULL; | 781 ProxyService::ProxyScriptDeciderPoller::poll_policy_ = NULL; |
783 | 782 |
784 // ProxyService::PacRequest --------------------------------------------------- | 783 // ProxyService::PacRequest --------------------------------------------------- |
785 | 784 |
786 class ProxyService::PacRequest | 785 class ProxyService::PacRequest |
787 : public base::RefCounted<ProxyService::PacRequest> { | 786 : public base::RefCounted<ProxyService::PacRequest> { |
788 public: | 787 public: |
789 PacRequest(ProxyService* service, | 788 PacRequest(ProxyService* service, |
790 const GURL& url, | 789 const GURL& url, |
791 const std::string& method, | 790 const std::string& method, |
792 int load_flags, | |
793 ProxyDelegate* proxy_delegate, | 791 ProxyDelegate* proxy_delegate, |
794 ProxyInfo* results, | 792 ProxyInfo* results, |
795 const CompletionCallback& user_callback, | 793 const CompletionCallback& user_callback, |
796 const BoundNetLog& net_log) | 794 const BoundNetLog& net_log) |
797 : service_(service), | 795 : service_(service), |
798 user_callback_(user_callback), | 796 user_callback_(user_callback), |
799 results_(results), | 797 results_(results), |
800 url_(url), | 798 url_(url), |
801 method_(method), | 799 method_(method), |
802 load_flags_(load_flags), | |
803 proxy_delegate_(proxy_delegate), | 800 proxy_delegate_(proxy_delegate), |
804 resolve_job_(NULL), | 801 resolve_job_(NULL), |
805 config_id_(ProxyConfig::kInvalidConfigID), | 802 config_id_(ProxyConfig::kInvalidConfigID), |
806 config_source_(PROXY_CONFIG_SOURCE_UNKNOWN), | 803 config_source_(PROXY_CONFIG_SOURCE_UNKNOWN), |
807 net_log_(net_log), | 804 net_log_(net_log), |
808 creation_time_(TimeTicks::Now()) { | 805 creation_time_(TimeTicks::Now()) { |
809 DCHECK(!user_callback.is_null()); | 806 DCHECK(!user_callback.is_null()); |
810 } | 807 } |
811 | 808 |
812 // Starts the resolve proxy request. | 809 // Starts the resolve proxy request. |
(...skipping 11 matching lines...) Expand all Loading... |
824 base::Bind(&PacRequest::QueryComplete, base::Unretained(this)), | 821 base::Bind(&PacRequest::QueryComplete, base::Unretained(this)), |
825 &resolve_job_, net_log_); | 822 &resolve_job_, net_log_); |
826 } | 823 } |
827 | 824 |
828 bool is_started() const { | 825 bool is_started() const { |
829 // Note that !! casts to bool. (VS gives a warning otherwise). | 826 // Note that !! casts to bool. (VS gives a warning otherwise). |
830 return !!resolve_job_; | 827 return !!resolve_job_; |
831 } | 828 } |
832 | 829 |
833 void StartAndCompleteCheckingForSynchronous() { | 830 void StartAndCompleteCheckingForSynchronous() { |
834 int rv = service_->TryToCompleteSynchronously(url_, load_flags_, | 831 int rv = |
835 proxy_delegate_, results_); | 832 service_->TryToCompleteSynchronously(url_, proxy_delegate_, results_); |
836 if (rv == ERR_IO_PENDING) | 833 if (rv == ERR_IO_PENDING) |
837 rv = Start(); | 834 rv = Start(); |
838 if (rv != ERR_IO_PENDING) | 835 if (rv != ERR_IO_PENDING) |
839 QueryComplete(rv); | 836 QueryComplete(rv); |
840 } | 837 } |
841 | 838 |
842 void CancelResolveJob() { | 839 void CancelResolveJob() { |
843 DCHECK(is_started()); | 840 DCHECK(is_started()); |
844 // The request may already be running in the resolver. | 841 // The request may already be running in the resolver. |
845 resolver()->CancelRequest(resolve_job_); | 842 resolver()->CancelRequest(resolve_job_); |
(...skipping 26 matching lines...) Expand all Loading... |
872 DCHECK(!was_cancelled()); | 869 DCHECK(!was_cancelled()); |
873 | 870 |
874 // This state is cleared when resolve_job_ is set to nullptr below. | 871 // This state is cleared when resolve_job_ is set to nullptr below. |
875 bool script_executed = is_started(); | 872 bool script_executed = is_started(); |
876 | 873 |
877 // Clear |resolve_job_| so is_started() returns false while | 874 // Clear |resolve_job_| so is_started() returns false while |
878 // DidFinishResolvingProxy() runs. | 875 // DidFinishResolvingProxy() runs. |
879 resolve_job_ = nullptr; | 876 resolve_job_ = nullptr; |
880 | 877 |
881 // Note that DidFinishResolvingProxy might modify |results_|. | 878 // Note that DidFinishResolvingProxy might modify |results_|. |
882 int rv = service_->DidFinishResolvingProxy( | 879 int rv = service_->DidFinishResolvingProxy(url_, method_, proxy_delegate_, |
883 url_, method_, load_flags_, proxy_delegate_, results_, result_code, | 880 results_, result_code, net_log_, |
884 net_log_, creation_time_, script_executed); | 881 creation_time_, script_executed); |
885 | 882 |
886 // Make a note in the results which configuration was in use at the | 883 // Make a note in the results which configuration was in use at the |
887 // time of the resolve. | 884 // time of the resolve. |
888 results_->config_id_ = config_id_; | 885 results_->config_id_ = config_id_; |
889 results_->config_source_ = config_source_; | 886 results_->config_source_ = config_source_; |
890 results_->did_use_pac_script_ = true; | 887 results_->did_use_pac_script_ = true; |
891 results_->proxy_resolve_start_time_ = creation_time_; | 888 results_->proxy_resolve_start_time_ = creation_time_; |
892 results_->proxy_resolve_end_time_ = TimeTicks::Now(); | 889 results_->proxy_resolve_end_time_ = TimeTicks::Now(); |
893 | 890 |
894 // Reset the state associated with in-progress-resolve. | 891 // Reset the state associated with in-progress-resolve. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 ProxyResolver* resolver() const { return service_->resolver_.get(); } | 924 ProxyResolver* resolver() const { return service_->resolver_.get(); } |
928 | 925 |
929 // Note that we don't hold a reference to the ProxyService. Outstanding | 926 // Note that we don't hold a reference to the ProxyService. Outstanding |
930 // requests are cancelled during ~ProxyService, so this is guaranteed | 927 // requests are cancelled during ~ProxyService, so this is guaranteed |
931 // to be valid throughout our lifetime. | 928 // to be valid throughout our lifetime. |
932 ProxyService* service_; | 929 ProxyService* service_; |
933 CompletionCallback user_callback_; | 930 CompletionCallback user_callback_; |
934 ProxyInfo* results_; | 931 ProxyInfo* results_; |
935 GURL url_; | 932 GURL url_; |
936 std::string method_; | 933 std::string method_; |
937 int load_flags_; | |
938 ProxyDelegate* proxy_delegate_; | 934 ProxyDelegate* proxy_delegate_; |
939 ProxyResolver::RequestHandle resolve_job_; | 935 ProxyResolver::RequestHandle resolve_job_; |
940 ProxyConfig::ID config_id_; // The config id when the resolve was started. | 936 ProxyConfig::ID config_id_; // The config id when the resolve was started. |
941 ProxyConfigSource config_source_; // The source of proxy settings. | 937 ProxyConfigSource config_source_; // The source of proxy settings. |
942 BoundNetLog net_log_; | 938 BoundNetLog net_log_; |
943 // Time when the request was created. Stored here rather than in |results_| | 939 // Time when the request was created. Stored here rather than in |results_| |
944 // because the time in |results_| will be cleared. | 940 // because the time in |results_| will be cleared. |
945 TimeTicks creation_time_; | 941 TimeTicks creation_time_; |
946 }; | 942 }; |
947 | 943 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 new ProxyConfigServiceFixed(ProxyConfig::CreateAutoDetect())); | 1028 new ProxyConfigServiceFixed(ProxyConfig::CreateAutoDetect())); |
1033 | 1029 |
1034 return base::WrapUnique(new ProxyService( | 1030 return base::WrapUnique(new ProxyService( |
1035 std::move(proxy_config_service), | 1031 std::move(proxy_config_service), |
1036 base::WrapUnique(new ProxyResolverFactoryForPacResult(pac_string)), | 1032 base::WrapUnique(new ProxyResolverFactoryForPacResult(pac_string)), |
1037 NULL)); | 1033 NULL)); |
1038 } | 1034 } |
1039 | 1035 |
1040 int ProxyService::ResolveProxy(const GURL& raw_url, | 1036 int ProxyService::ResolveProxy(const GURL& raw_url, |
1041 const std::string& method, | 1037 const std::string& method, |
1042 int load_flags, | |
1043 ProxyInfo* result, | 1038 ProxyInfo* result, |
1044 const CompletionCallback& callback, | 1039 const CompletionCallback& callback, |
1045 PacRequest** pac_request, | 1040 PacRequest** pac_request, |
1046 ProxyDelegate* proxy_delegate, | 1041 ProxyDelegate* proxy_delegate, |
1047 const BoundNetLog& net_log) { | 1042 const BoundNetLog& net_log) { |
1048 DCHECK(!callback.is_null()); | 1043 DCHECK(!callback.is_null()); |
1049 return ResolveProxyHelper(raw_url, method, load_flags, result, callback, | 1044 return ResolveProxyHelper(raw_url, method, result, callback, pac_request, |
1050 pac_request, proxy_delegate, net_log); | 1045 proxy_delegate, net_log); |
1051 } | 1046 } |
1052 | 1047 |
1053 int ProxyService::ResolveProxyHelper(const GURL& raw_url, | 1048 int ProxyService::ResolveProxyHelper(const GURL& raw_url, |
1054 const std::string& method, | 1049 const std::string& method, |
1055 int load_flags, | |
1056 ProxyInfo* result, | 1050 ProxyInfo* result, |
1057 const CompletionCallback& callback, | 1051 const CompletionCallback& callback, |
1058 PacRequest** pac_request, | 1052 PacRequest** pac_request, |
1059 ProxyDelegate* proxy_delegate, | 1053 ProxyDelegate* proxy_delegate, |
1060 const BoundNetLog& net_log) { | 1054 const BoundNetLog& net_log) { |
1061 DCHECK(CalledOnValidThread()); | 1055 DCHECK(CalledOnValidThread()); |
1062 | 1056 |
1063 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE); | 1057 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE); |
1064 | 1058 |
1065 // Notify our polling-based dependencies that a resolve is taking place. | 1059 // Notify our polling-based dependencies that a resolve is taking place. |
1066 // This way they can schedule their polls in response to network activity. | 1060 // This way they can schedule their polls in response to network activity. |
1067 config_service_->OnLazyPoll(); | 1061 config_service_->OnLazyPoll(); |
1068 if (script_poller_.get()) | 1062 if (script_poller_.get()) |
1069 script_poller_->OnLazyPoll(); | 1063 script_poller_->OnLazyPoll(); |
1070 | 1064 |
1071 if (current_state_ == STATE_NONE) | 1065 if (current_state_ == STATE_NONE) |
1072 ApplyProxyConfigIfAvailable(); | 1066 ApplyProxyConfigIfAvailable(); |
1073 | 1067 |
1074 // Sanitize the URL before passing it on to the proxy resolver (i.e. PAC | 1068 // Sanitize the URL before passing it on to the proxy resolver (i.e. PAC |
1075 // script). The goal is to remove sensitive data (like embedded user names | 1069 // script). The goal is to remove sensitive data (like embedded user names |
1076 // and password), and local data (i.e. reference fragment) which does not need | 1070 // and password), and local data (i.e. reference fragment) which does not need |
1077 // to be disclosed to the resolver. | 1071 // to be disclosed to the resolver. |
1078 GURL url = SanitizeUrl(raw_url, sanitize_url_policy_); | 1072 GURL url = SanitizeUrl(raw_url, sanitize_url_policy_); |
1079 | 1073 |
1080 // Check if the request can be completed right away. (This is the case when | 1074 // Check if the request can be completed right away. (This is the case when |
1081 // using a direct connection for example). | 1075 // using a direct connection for example). |
1082 int rv = TryToCompleteSynchronously(url, load_flags, proxy_delegate, result); | 1076 int rv = TryToCompleteSynchronously(url, proxy_delegate, result); |
1083 if (rv != ERR_IO_PENDING) { | 1077 if (rv != ERR_IO_PENDING) { |
1084 rv = DidFinishResolvingProxy( | 1078 rv = DidFinishResolvingProxy( |
1085 url, method, load_flags, proxy_delegate, result, rv, net_log, | 1079 url, method, proxy_delegate, result, rv, net_log, |
1086 callback.is_null() ? TimeTicks() : TimeTicks::Now(), false); | 1080 callback.is_null() ? TimeTicks() : TimeTicks::Now(), false); |
1087 return rv; | 1081 return rv; |
1088 } | 1082 } |
1089 | 1083 |
1090 if (callback.is_null()) | 1084 if (callback.is_null()) |
1091 return ERR_IO_PENDING; | 1085 return ERR_IO_PENDING; |
1092 | 1086 |
1093 scoped_refptr<PacRequest> req(new PacRequest(this, url, method, load_flags, | 1087 scoped_refptr<PacRequest> req(new PacRequest( |
1094 proxy_delegate, result, callback, | 1088 this, url, method, proxy_delegate, result, callback, net_log)); |
1095 net_log)); | |
1096 | 1089 |
1097 if (current_state_ == STATE_READY) { | 1090 if (current_state_ == STATE_READY) { |
1098 // Start the resolve request. | 1091 // Start the resolve request. |
1099 rv = req->Start(); | 1092 rv = req->Start(); |
1100 if (rv != ERR_IO_PENDING) | 1093 if (rv != ERR_IO_PENDING) |
1101 return req->QueryDidComplete(rv); | 1094 return req->QueryDidComplete(rv); |
1102 } else { | 1095 } else { |
1103 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); | 1096 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); |
1104 } | 1097 } |
1105 | 1098 |
1106 DCHECK_EQ(ERR_IO_PENDING, rv); | 1099 DCHECK_EQ(ERR_IO_PENDING, rv); |
1107 DCHECK(!ContainsPendingRequest(req.get())); | 1100 DCHECK(!ContainsPendingRequest(req.get())); |
1108 pending_requests_.insert(req); | 1101 pending_requests_.insert(req); |
1109 | 1102 |
1110 // Completion will be notified through |callback|, unless the caller cancels | 1103 // Completion will be notified through |callback|, unless the caller cancels |
1111 // the request using |pac_request|. | 1104 // the request using |pac_request|. |
1112 if (pac_request) | 1105 if (pac_request) |
1113 *pac_request = req.get(); | 1106 *pac_request = req.get(); |
1114 return rv; // ERR_IO_PENDING | 1107 return rv; // ERR_IO_PENDING |
1115 } | 1108 } |
1116 | 1109 |
1117 bool ProxyService::TryResolveProxySynchronously(const GURL& raw_url, | 1110 bool ProxyService::TryResolveProxySynchronously(const GURL& raw_url, |
1118 const std::string& method, | 1111 const std::string& method, |
1119 int load_flags, | |
1120 ProxyInfo* result, | 1112 ProxyInfo* result, |
1121 ProxyDelegate* proxy_delegate, | 1113 ProxyDelegate* proxy_delegate, |
1122 const BoundNetLog& net_log) { | 1114 const BoundNetLog& net_log) { |
1123 CompletionCallback null_callback; | 1115 CompletionCallback null_callback; |
1124 return ResolveProxyHelper(raw_url, method, load_flags, result, null_callback, | 1116 return ResolveProxyHelper(raw_url, method, result, null_callback, |
1125 nullptr /* pac_request*/, proxy_delegate, | 1117 nullptr /* pac_request*/, proxy_delegate, |
1126 net_log) == OK; | 1118 net_log) == OK; |
1127 } | 1119 } |
1128 | 1120 |
1129 int ProxyService::TryToCompleteSynchronously(const GURL& url, | 1121 int ProxyService::TryToCompleteSynchronously(const GURL& url, |
1130 int load_flags, | |
1131 ProxyDelegate* proxy_delegate, | 1122 ProxyDelegate* proxy_delegate, |
1132 ProxyInfo* result) { | 1123 ProxyInfo* result) { |
1133 DCHECK_NE(STATE_NONE, current_state_); | 1124 DCHECK_NE(STATE_NONE, current_state_); |
1134 | 1125 |
1135 if (current_state_ != STATE_READY) | 1126 if (current_state_ != STATE_READY) |
1136 return ERR_IO_PENDING; // Still initializing. | 1127 return ERR_IO_PENDING; // Still initializing. |
1137 | 1128 |
1138 DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID); | 1129 DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID); |
1139 | 1130 |
1140 // If it was impossible to fetch or parse the PAC script, we cannot complete | 1131 // If it was impossible to fetch or parse the PAC script, we cannot complete |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 config_.set_id(fetched_config_.id()); | 1266 config_.set_id(fetched_config_.id()); |
1276 config_.set_source(fetched_config_.source()); | 1267 config_.set_source(fetched_config_.source()); |
1277 | 1268 |
1278 // Resume any requests which we had to defer until the PAC script was | 1269 // Resume any requests which we had to defer until the PAC script was |
1279 // downloaded. | 1270 // downloaded. |
1280 SetReady(); | 1271 SetReady(); |
1281 } | 1272 } |
1282 | 1273 |
1283 int ProxyService::ReconsiderProxyAfterError(const GURL& url, | 1274 int ProxyService::ReconsiderProxyAfterError(const GURL& url, |
1284 const std::string& method, | 1275 const std::string& method, |
1285 int load_flags, | |
1286 int net_error, | 1276 int net_error, |
1287 ProxyInfo* result, | 1277 ProxyInfo* result, |
1288 const CompletionCallback& callback, | 1278 const CompletionCallback& callback, |
1289 PacRequest** pac_request, | 1279 PacRequest** pac_request, |
1290 ProxyDelegate* proxy_delegate, | 1280 ProxyDelegate* proxy_delegate, |
1291 const BoundNetLog& net_log) { | 1281 const BoundNetLog& net_log) { |
1292 DCHECK(CalledOnValidThread()); | 1282 DCHECK(CalledOnValidThread()); |
1293 | 1283 |
1294 // Check to see if we have a new config since ResolveProxy was called. We | 1284 // Check to see if we have a new config since ResolveProxy was called. We |
1295 // want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a | 1285 // want to re-run ResolveProxy in two cases: 1) we have a new config, or 2) a |
1296 // direct connection failed and we never tried the current config. | 1286 // direct connection failed and we never tried the current config. |
1297 | 1287 |
1298 DCHECK(result); | 1288 DCHECK(result); |
1299 bool re_resolve = result->config_id_ != config_.id(); | 1289 bool re_resolve = result->config_id_ != config_.id(); |
1300 | 1290 |
1301 if (re_resolve) { | 1291 if (re_resolve) { |
1302 // If we have a new config or the config was never tried, we delete the | 1292 // If we have a new config or the config was never tried, we delete the |
1303 // list of bad proxies and we try again. | 1293 // list of bad proxies and we try again. |
1304 proxy_retry_info_.clear(); | 1294 proxy_retry_info_.clear(); |
1305 return ResolveProxy(url, method, load_flags, result, callback, pac_request, | 1295 return ResolveProxy(url, method, result, callback, pac_request, |
1306 proxy_delegate, net_log); | 1296 proxy_delegate, net_log); |
1307 } | 1297 } |
1308 | 1298 |
1309 DCHECK(!result->is_empty()); | 1299 DCHECK(!result->is_empty()); |
1310 ProxyServer bad_proxy = result->proxy_server(); | 1300 ProxyServer bad_proxy = result->proxy_server(); |
1311 | 1301 |
1312 // We don't have new proxy settings to try, try to fallback to the next proxy | 1302 // We don't have new proxy settings to try, try to fallback to the next proxy |
1313 // in the list. | 1303 // in the list. |
1314 bool did_fallback = result->Fallback(net_error, net_log); | 1304 bool did_fallback = result->Fallback(net_error, net_log); |
1315 | 1305 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 return pending_requests_.count(req) == 1; | 1367 return pending_requests_.count(req) == 1; |
1378 } | 1368 } |
1379 | 1369 |
1380 void ProxyService::RemovePendingRequest(PacRequest* req) { | 1370 void ProxyService::RemovePendingRequest(PacRequest* req) { |
1381 DCHECK(ContainsPendingRequest(req)); | 1371 DCHECK(ContainsPendingRequest(req)); |
1382 pending_requests_.erase(req); | 1372 pending_requests_.erase(req); |
1383 } | 1373 } |
1384 | 1374 |
1385 int ProxyService::DidFinishResolvingProxy(const GURL& url, | 1375 int ProxyService::DidFinishResolvingProxy(const GURL& url, |
1386 const std::string& method, | 1376 const std::string& method, |
1387 int load_flags, | |
1388 ProxyDelegate* proxy_delegate, | 1377 ProxyDelegate* proxy_delegate, |
1389 ProxyInfo* result, | 1378 ProxyInfo* result, |
1390 int result_code, | 1379 int result_code, |
1391 const BoundNetLog& net_log, | 1380 const BoundNetLog& net_log, |
1392 base::TimeTicks start_time, | 1381 base::TimeTicks start_time, |
1393 bool script_executed) { | 1382 bool script_executed) { |
1394 // Don't track any metrics if start_time is 0, which will happen when the user | 1383 // Don't track any metrics if start_time is 0, which will happen when the user |
1395 // calls |TryResolveProxySynchronously|. | 1384 // calls |TryResolveProxySynchronously|. |
1396 if (!start_time.is_null()) { | 1385 if (!start_time.is_null()) { |
1397 TimeDelta diff = TimeTicks::Now() - start_time; | 1386 TimeDelta diff = TimeTicks::Now() - start_time; |
(...skipping 14 matching lines...) Expand all Loading... |
1412 UMA_HISTOGRAM_CUSTOM_TIMES("Net.ProxyService.ResolveProxyTime", diff, | 1401 UMA_HISTOGRAM_CUSTOM_TIMES("Net.ProxyService.ResolveProxyTime", diff, |
1413 base::TimeDelta::FromMicroseconds(100), | 1402 base::TimeDelta::FromMicroseconds(100), |
1414 base::TimeDelta::FromSeconds(20), 50); | 1403 base::TimeDelta::FromSeconds(20), 50); |
1415 } | 1404 } |
1416 | 1405 |
1417 // Log the result of the proxy resolution. | 1406 // Log the result of the proxy resolution. |
1418 if (result_code == OK) { | 1407 if (result_code == OK) { |
1419 // Allow the proxy delegate to interpose on the resolution decision, | 1408 // Allow the proxy delegate to interpose on the resolution decision, |
1420 // possibly modifying the ProxyInfo. | 1409 // possibly modifying the ProxyInfo. |
1421 if (proxy_delegate) | 1410 if (proxy_delegate) |
1422 proxy_delegate->OnResolveProxy(url, method, load_flags, *this, result); | 1411 proxy_delegate->OnResolveProxy(url, method, *this, result); |
1423 | 1412 |
1424 net_log.AddEvent(NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, | 1413 net_log.AddEvent(NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, |
1425 base::Bind(&NetLogFinishedResolvingProxyCallback, result)); | 1414 base::Bind(&NetLogFinishedResolvingProxyCallback, result)); |
1426 | 1415 |
1427 // This check is done to only log the NetLog event when necessary, it's | 1416 // This check is done to only log the NetLog event when necessary, it's |
1428 // not a performance optimization. | 1417 // not a performance optimization. |
1429 if (!proxy_retry_info_.empty()) { | 1418 if (!proxy_retry_info_.empty()) { |
1430 result->DeprioritizeBadProxies(proxy_retry_info_); | 1419 result->DeprioritizeBadProxies(proxy_retry_info_); |
1431 net_log.AddEvent( | 1420 net_log.AddEvent( |
1432 NetLog::TYPE_PROXY_SERVICE_DEPRIORITIZED_BAD_PROXIES, | 1421 NetLog::TYPE_PROXY_SERVICE_DEPRIORITIZED_BAD_PROXIES, |
(...skipping 11 matching lines...) Expand all Loading... |
1444 // This implicit fall-back to direct matches Firefox 3.5 and | 1433 // This implicit fall-back to direct matches Firefox 3.5 and |
1445 // Internet Explorer 8. For more information, see: | 1434 // Internet Explorer 8. For more information, see: |
1446 // | 1435 // |
1447 // http://www.chromium.org/developers/design-documents/proxy-settings-fall
back | 1436 // http://www.chromium.org/developers/design-documents/proxy-settings-fall
back |
1448 result->UseDirect(); | 1437 result->UseDirect(); |
1449 result_code = OK; | 1438 result_code = OK; |
1450 | 1439 |
1451 // Allow the proxy delegate to interpose on the resolution decision, | 1440 // Allow the proxy delegate to interpose on the resolution decision, |
1452 // possibly modifying the ProxyInfo. | 1441 // possibly modifying the ProxyInfo. |
1453 if (proxy_delegate) | 1442 if (proxy_delegate) |
1454 proxy_delegate->OnResolveProxy(url, method, load_flags, *this, result); | 1443 proxy_delegate->OnResolveProxy(url, method, *this, result); |
1455 } else { | 1444 } else { |
1456 result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED; | 1445 result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED; |
1457 } | 1446 } |
1458 if (reset_config) { | 1447 if (reset_config) { |
1459 ResetProxyConfig(false); | 1448 ResetProxyConfig(false); |
1460 // If the ProxyResolver crashed, force it to be re-initialized for the | 1449 // If the ProxyResolver crashed, force it to be re-initialized for the |
1461 // next request by resetting the proxy config. If there are other pending | 1450 // next request by resetting the proxy config. If there are other pending |
1462 // requests, trigger the recreation immediately so those requests retry. | 1451 // requests, trigger the recreation immediately so those requests retry. |
1463 if (pending_requests_.size() > 1) | 1452 if (pending_requests_.size() > 1) |
1464 ApplyProxyConfigIfAvailable(); | 1453 ApplyProxyConfigIfAvailable(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 State previous_state = ResetProxyConfig(false); | 1667 State previous_state = ResetProxyConfig(false); |
1679 if (previous_state != STATE_NONE) | 1668 if (previous_state != STATE_NONE) |
1680 ApplyProxyConfigIfAvailable(); | 1669 ApplyProxyConfigIfAvailable(); |
1681 } | 1670 } |
1682 | 1671 |
1683 void ProxyService::OnDNSChanged() { | 1672 void ProxyService::OnDNSChanged() { |
1684 OnIPAddressChanged(); | 1673 OnIPAddressChanged(); |
1685 } | 1674 } |
1686 | 1675 |
1687 } // namespace net | 1676 } // namespace net |
OLD | NEW |