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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 results_->config_source_ = config_source_; | 836 results_->config_source_ = config_source_; |
837 results_->did_use_pac_script_ = true; | 837 results_->did_use_pac_script_ = true; |
838 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_; | 838 results_->proxy_resolve_start_time_ = proxy_resolve_start_time_; |
839 results_->proxy_resolve_end_time_ = TimeTicks::Now(); | 839 results_->proxy_resolve_end_time_ = TimeTicks::Now(); |
840 | 840 |
841 // Reset the state associated with in-progress-resolve. | 841 // Reset the state associated with in-progress-resolve. |
842 resolve_job_ = NULL; | 842 resolve_job_ = NULL; |
843 config_id_ = ProxyConfig::kInvalidConfigID; | 843 config_id_ = ProxyConfig::kInvalidConfigID; |
844 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; | 844 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; |
845 | 845 |
846 // If the PAC script failed fatally, it needs to be reloaded. Currently, | |
eroman
2015/03/11 18:48:36
This change would best be proposed as a separate c
Anand Mistry (off Chromium)
2015/03/12 05:10:22
I've removed this from this CL. So out-of-process
| |
847 // this only applies to out-of-process proxy resolution and only happens | |
848 // when the process crashes. | |
849 if (result_code == ERR_PAC_SCRIPT_TERMINATED) { | |
850 VLOG(1) << "Detected PAC script terminated. Resetting proxy config."; | |
851 // Reset the proxy config. | |
852 // REVIEWERS: Should the fetched proxy config be reset? | |
853 service_->ResetProxyConfig(false); | |
854 | |
855 // If there are any pending requests, excluding this one, re-start the | |
856 // config fetch/apply process. | |
857 size_t pending_requests = service_->NumPendingRequests(); | |
858 if (pending_requests > 1 || | |
859 (pending_requests && !service_->ContainsPendingRequest(this))) { | |
860 service_->ApplyProxyConfigIfAvailable(); | |
861 } | |
862 } | |
863 | |
846 return rv; | 864 return rv; |
847 } | 865 } |
848 | 866 |
849 BoundNetLog* net_log() { return &net_log_; } | 867 BoundNetLog* net_log() { return &net_log_; } |
850 | 868 |
851 LoadState GetLoadState() const { | 869 LoadState GetLoadState() const { |
852 if (is_started()) | 870 if (is_started()) |
853 return resolver()->GetLoadState(resolve_job_); | 871 return resolver()->GetLoadState(resolve_job_); |
854 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; | 872 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; |
855 } | 873 } |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1331 return pending_requests_.end() != it; | 1349 return pending_requests_.end() != it; |
1332 } | 1350 } |
1333 | 1351 |
1334 void ProxyService::RemovePendingRequest(PacRequest* req) { | 1352 void ProxyService::RemovePendingRequest(PacRequest* req) { |
1335 DCHECK(ContainsPendingRequest(req)); | 1353 DCHECK(ContainsPendingRequest(req)); |
1336 PendingRequests::iterator it = std::find( | 1354 PendingRequests::iterator it = std::find( |
1337 pending_requests_.begin(), pending_requests_.end(), req); | 1355 pending_requests_.begin(), pending_requests_.end(), req); |
1338 pending_requests_.erase(it); | 1356 pending_requests_.erase(it); |
1339 } | 1357 } |
1340 | 1358 |
1359 size_t ProxyService::NumPendingRequests() const { | |
1360 return pending_requests_.size(); | |
eroman
2015/03/11 18:48:36
Not needed per discussion above.
Anand Mistry (off Chromium)
2015/03/12 05:10:22
Done.
| |
1361 } | |
1362 | |
1341 int ProxyService::DidFinishResolvingProxy(const GURL& url, | 1363 int ProxyService::DidFinishResolvingProxy(const GURL& url, |
1342 int load_flags, | 1364 int load_flags, |
1343 NetworkDelegate* network_delegate, | 1365 NetworkDelegate* network_delegate, |
1344 ProxyInfo* result, | 1366 ProxyInfo* result, |
1345 int result_code, | 1367 int result_code, |
1346 const BoundNetLog& net_log) { | 1368 const BoundNetLog& net_log) { |
1347 // Log the result of the proxy resolution. | 1369 // Log the result of the proxy resolution. |
1348 if (result_code == OK) { | 1370 if (result_code == OK) { |
1349 // Allow the network delegate to interpose on the resolution decision, | 1371 // Allow the network delegate to interpose on the resolution decision, |
1350 // possibly modifying the ProxyInfo. | 1372 // possibly modifying the ProxyInfo. |
(...skipping 250 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 |