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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
873 // Returns true if Cancel() has been called. | 873 // Returns true if Cancel() has been called. |
874 bool was_cancelled() const { | 874 bool was_cancelled() const { |
875 return user_callback_.is_null(); | 875 return user_callback_.is_null(); |
876 } | 876 } |
877 | 877 |
878 // Helper to call after ProxyResolver completion (both synchronous and | 878 // Helper to call after ProxyResolver completion (both synchronous and |
879 // asynchronous). Fixes up the result that is to be returned to user. | 879 // asynchronous). Fixes up the result that is to be returned to user. |
880 int QueryDidComplete(int result_code) { | 880 int QueryDidComplete(int result_code) { |
881 DCHECK(!was_cancelled()); | 881 DCHECK(!was_cancelled()); |
882 | 882 |
883 // Clear |resolve_job_| so is_started() returns false while | |
884 // DidFinishResolvingProxy() runs. | |
885 resolve_job_ = nullptr; | |
886 | |
883 // Note that DidFinishResolvingProxy might modify |results_|. | 887 // Note that DidFinishResolvingProxy might modify |results_|. |
884 int rv = service_->DidFinishResolvingProxy(url_, load_flags_, | 888 int rv = service_->DidFinishResolvingProxy(url_, load_flags_, |
885 network_delegate_, results_, | 889 network_delegate_, results_, |
886 result_code, net_log_); | 890 result_code, net_log_); |
887 | 891 |
888 // Make a note in the results which configuration was in use at the | 892 // Make a note in the results which configuration was in use at the |
889 // time of the resolve. | 893 // time of the resolve. |
890 results_->config_id_ = config_id_; | 894 results_->config_id_ = config_id_; |
891 results_->config_source_ = config_source_; | 895 results_->config_source_ = config_source_; |
892 results_->did_use_pac_script_ = true; | 896 results_->did_use_pac_script_ = true; |
893 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_; | 897 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_; |
894 results_->proxy_resolve_end_time_ = TimeTicks::Now(); | 898 results_->proxy_resolve_end_time_ = TimeTicks::Now(); |
895 | 899 |
896 // Reset the state associated with in-progress-resolve. | 900 // Reset the state associated with in-progress-resolve. |
897 resolve_job_ = NULL; | |
898 config_id_ = ProxyConfig::kInvalidConfigID; | 901 config_id_ = ProxyConfig::kInvalidConfigID; |
899 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; | 902 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; |
900 | 903 |
901 return rv; | 904 return rv; |
902 } | 905 } |
903 | 906 |
904 BoundNetLog* net_log() { return &net_log_; } | 907 BoundNetLog* net_log() { return &net_log_; } |
905 | 908 |
906 LoadState GetLoadState() const { | 909 LoadState GetLoadState() const { |
907 if (is_started()) | 910 if (is_started()) |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1404 if (net_log.IsLogging()) { | 1407 if (net_log.IsLogging()) { |
1405 net_log.AddEvent( | 1408 net_log.AddEvent( |
1406 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, | 1409 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, |
1407 base::Bind(&NetLogFinishedResolvingProxyCallback, result)); | 1410 base::Bind(&NetLogFinishedResolvingProxyCallback, result)); |
1408 } | 1411 } |
1409 result->DeprioritizeBadProxies(proxy_retry_info_); | 1412 result->DeprioritizeBadProxies(proxy_retry_info_); |
1410 } else { | 1413 } else { |
1411 net_log.AddEventWithNetErrorCode( | 1414 net_log.AddEventWithNetErrorCode( |
1412 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, result_code); | 1415 NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST, result_code); |
1413 | 1416 |
1417 if (result_code == ERR_PAC_SCRIPT_TERMINATED) { | |
1418 // If the ProxyResolver crashed, force it to be re-initialized for the | |
1419 // next request by resetting the proxy config. If there are other | |
1420 // requests, trigger the recreation immediately so those requests retry. | |
1421 bool requests_in_progress = false; | |
1422 for (const auto& request : pending_requests_) { | |
1423 if (request->is_started()) { | |
eroman
2015/04/15 00:56:52
why not reset the config whenever there are reques
Sam McNally
2015/04/15 04:35:56
Done.
| |
1424 requests_in_progress = true; | |
1425 break; | |
1426 } | |
1427 } | |
1428 ResetProxyConfig(false); | |
1429 if (requests_in_progress) | |
1430 ApplyProxyConfigIfAvailable(); | |
1431 } | |
1432 | |
1414 if (!config_.pac_mandatory()) { | 1433 if (!config_.pac_mandatory()) { |
eroman
2015/04/15 00:56:52
config_ should not be tested and relied upon after
Sam McNally
2015/04/15 04:35:56
Done.
| |
1415 // Fall-back to direct when the proxy resolver fails. This corresponds | 1434 // Fall-back to direct when the proxy resolver fails. This corresponds |
1416 // with a javascript runtime error in the PAC script. | 1435 // with a javascript runtime error in the PAC script. |
1417 // | 1436 // |
1418 // This implicit fall-back to direct matches Firefox 3.5 and | 1437 // This implicit fall-back to direct matches Firefox 3.5 and |
1419 // Internet Explorer 8. For more information, see: | 1438 // Internet Explorer 8. For more information, see: |
1420 // | 1439 // |
1421 // http://www.chromium.org/developers/design-documents/proxy-settings-fall back | 1440 // http://www.chromium.org/developers/design-documents/proxy-settings-fall back |
1422 result->UseDirect(); | 1441 result->UseDirect(); |
1423 result_code = OK; | 1442 result_code = OK; |
1424 | 1443 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1644 State previous_state = ResetProxyConfig(false); | 1663 State previous_state = ResetProxyConfig(false); |
1645 if (previous_state != STATE_NONE) | 1664 if (previous_state != STATE_NONE) |
1646 ApplyProxyConfigIfAvailable(); | 1665 ApplyProxyConfigIfAvailable(); |
1647 } | 1666 } |
1648 | 1667 |
1649 void ProxyService::OnDNSChanged() { | 1668 void ProxyService::OnDNSChanged() { |
1650 OnIPAddressChanged(); | 1669 OnIPAddressChanged(); |
1651 } | 1670 } |
1652 | 1671 |
1653 } // namespace net | 1672 } // namespace net |
OLD | NEW |