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 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 results_->config_source_ = config_source_; | 820 results_->config_source_ = config_source_; |
821 results_->did_use_pac_script_ = true; | 821 results_->did_use_pac_script_ = true; |
822 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_; | 822 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_; |
823 results_->proxy_resolve_end_time_ = TimeTicks::Now(); | 823 results_->proxy_resolve_end_time_ = TimeTicks::Now(); |
824 | 824 |
825 // Reset the state associated with in-progress-resolve. | 825 // Reset the state associated with in-progress-resolve. |
826 resolve_job_ = NULL; | 826 resolve_job_ = NULL; |
827 config_id_ = ProxyConfig::kInvalidConfigID; | 827 config_id_ = ProxyConfig::kInvalidConfigID; |
828 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; | 828 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; |
829 | 829 |
| 830 // If the PAC script failed fatally, it needs to be reloaded. Currently, |
| 831 // this only applies to out-of-process proxy resolution and only happens |
| 832 // when the process crashes. |
| 833 if (result_code == ERR_PAC_SCRIPT_TERMINATED) { |
| 834 VLOG(1) << "Detected PAC script terminated. Resetting proxy config."; |
| 835 // Reset the proxy config. |
| 836 // REVIEWERS: Should the fetched proxy config be reset? |
| 837 service_->ResetProxyConfig(false); |
| 838 |
| 839 // If there are any pending requests, excluding this one, re-start the |
| 840 // config fetch/apply process. |
| 841 size_t pending_requests = service_->NumPendingRequests(); |
| 842 if (pending_requests > 1 || |
| 843 (pending_requests && !service_->ContainsPendingRequest(this))) { |
| 844 service_->ApplyProxyConfigIfAvailable(); |
| 845 } |
| 846 } |
| 847 |
830 return rv; | 848 return rv; |
831 } | 849 } |
832 | 850 |
833 BoundNetLog* net_log() { return &net_log_; } | 851 BoundNetLog* net_log() { return &net_log_; } |
834 | 852 |
835 LoadState GetLoadState() const { | 853 LoadState GetLoadState() const { |
836 if (is_started()) | 854 if (is_started()) |
837 return resolver()->GetLoadState(resolve_job_); | 855 return resolver()->GetLoadState(resolve_job_); |
838 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; | 856 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; |
839 } | 857 } |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 return pending_requests_.end() != it; | 1337 return pending_requests_.end() != it; |
1320 } | 1338 } |
1321 | 1339 |
1322 void ProxyService::RemovePendingRequest(PacRequest* req) { | 1340 void ProxyService::RemovePendingRequest(PacRequest* req) { |
1323 DCHECK(ContainsPendingRequest(req)); | 1341 DCHECK(ContainsPendingRequest(req)); |
1324 PendingRequests::iterator it = std::find( | 1342 PendingRequests::iterator it = std::find( |
1325 pending_requests_.begin(), pending_requests_.end(), req); | 1343 pending_requests_.begin(), pending_requests_.end(), req); |
1326 pending_requests_.erase(it); | 1344 pending_requests_.erase(it); |
1327 } | 1345 } |
1328 | 1346 |
| 1347 size_t ProxyService::NumPendingRequests() const { |
| 1348 return pending_requests_.size(); |
| 1349 } |
| 1350 |
1329 int ProxyService::DidFinishResolvingProxy(const GURL& url, | 1351 int ProxyService::DidFinishResolvingProxy(const GURL& url, |
1330 int load_flags, | 1352 int load_flags, |
1331 NetworkDelegate* network_delegate, | 1353 NetworkDelegate* network_delegate, |
1332 ProxyInfo* result, | 1354 ProxyInfo* result, |
1333 int result_code, | 1355 int result_code, |
1334 const BoundNetLog& net_log) { | 1356 const BoundNetLog& net_log) { |
1335 // Log the result of the proxy resolution. | 1357 // Log the result of the proxy resolution. |
1336 if (result_code == OK) { | 1358 if (result_code == OK) { |
1337 // Allow the network delegate to interpose on the resolution decision, | 1359 // Allow the network delegate to interpose on the resolution decision, |
1338 // possibly modifying the ProxyInfo. | 1360 // possibly modifying the ProxyInfo. |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 State previous_state = ResetProxyConfig(false); | 1623 State previous_state = ResetProxyConfig(false); |
1602 if (previous_state != STATE_NONE) | 1624 if (previous_state != STATE_NONE) |
1603 ApplyProxyConfigIfAvailable(); | 1625 ApplyProxyConfigIfAvailable(); |
1604 } | 1626 } |
1605 | 1627 |
1606 void ProxyService::OnDNSChanged() { | 1628 void ProxyService::OnDNSChanged() { |
1607 OnIPAddressChanged(); | 1629 OnIPAddressChanged(); |
1608 } | 1630 } |
1609 | 1631 |
1610 } // namespace net | 1632 } // namespace net |
OLD | NEW |