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 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 LoadState GetLoadState() const { | 450 LoadState GetLoadState() const { |
451 if (next_state_ == STATE_DECIDE_PROXY_SCRIPT_COMPLETE) { | 451 if (next_state_ == STATE_DECIDE_PROXY_SCRIPT_COMPLETE) { |
452 // In addition to downloading, this state may also include the stall time | 452 // In addition to downloading, this state may also include the stall time |
453 // after network change events (kDelayAfterNetworkChangesMs). | 453 // after network change events (kDelayAfterNetworkChangesMs). |
454 return LOAD_STATE_DOWNLOADING_PROXY_SCRIPT; | 454 return LOAD_STATE_DOWNLOADING_PROXY_SCRIPT; |
455 } | 455 } |
456 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; | 456 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; |
457 } | 457 } |
458 | 458 |
| 459 // This must be called before the HostResolver is torn down. |
| 460 void OnShutdown() { |
| 461 if (decider_) |
| 462 decider_->OnShutdown(); |
| 463 } |
| 464 |
459 void set_quick_check_enabled(bool enabled) { quick_check_enabled_ = enabled; } | 465 void set_quick_check_enabled(bool enabled) { quick_check_enabled_ = enabled; } |
460 bool quick_check_enabled() const { return quick_check_enabled_; } | 466 bool quick_check_enabled() const { return quick_check_enabled_; } |
461 | 467 |
462 private: | 468 private: |
463 enum State { | 469 enum State { |
464 STATE_NONE, | 470 STATE_NONE, |
465 STATE_DECIDE_PROXY_SCRIPT, | 471 STATE_DECIDE_PROXY_SCRIPT, |
466 STATE_DECIDE_PROXY_SCRIPT_COMPLETE, | 472 STATE_DECIDE_PROXY_SCRIPT_COMPLETE, |
467 STATE_CREATE_RESOLVER, | 473 STATE_CREATE_RESOLVER, |
468 STATE_CREATE_RESOLVER_COMPLETE, | 474 STATE_CREATE_RESOLVER_COMPLETE, |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 ProxyScriptFetcher* proxy_script_fetcher, | 1457 ProxyScriptFetcher* proxy_script_fetcher, |
1452 std::unique_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher) { | 1458 std::unique_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher) { |
1453 DCHECK(CalledOnValidThread()); | 1459 DCHECK(CalledOnValidThread()); |
1454 State previous_state = ResetProxyConfig(false); | 1460 State previous_state = ResetProxyConfig(false); |
1455 proxy_script_fetcher_.reset(proxy_script_fetcher); | 1461 proxy_script_fetcher_.reset(proxy_script_fetcher); |
1456 dhcp_proxy_script_fetcher_ = std::move(dhcp_proxy_script_fetcher); | 1462 dhcp_proxy_script_fetcher_ = std::move(dhcp_proxy_script_fetcher); |
1457 if (previous_state != STATE_NONE) | 1463 if (previous_state != STATE_NONE) |
1458 ApplyProxyConfigIfAvailable(); | 1464 ApplyProxyConfigIfAvailable(); |
1459 } | 1465 } |
1460 | 1466 |
| 1467 void ProxyService::OnShutdown() { |
| 1468 // Order here does not matter for correctness. |init_proxy_resolver_| is first |
| 1469 // because shutting it down also cancels its requests using the fetcher. |
| 1470 if (init_proxy_resolver_) |
| 1471 init_proxy_resolver_->OnShutdown(); |
| 1472 if (proxy_script_fetcher_) |
| 1473 proxy_script_fetcher_->OnShutdown(); |
| 1474 if (dhcp_proxy_script_fetcher_) |
| 1475 dhcp_proxy_script_fetcher_->OnShutdown(); |
| 1476 } |
| 1477 |
1461 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const { | 1478 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const { |
1462 DCHECK(CalledOnValidThread()); | 1479 DCHECK(CalledOnValidThread()); |
1463 return proxy_script_fetcher_.get(); | 1480 return proxy_script_fetcher_.get(); |
1464 } | 1481 } |
1465 | 1482 |
1466 ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) { | 1483 ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) { |
1467 DCHECK(CalledOnValidThread()); | 1484 DCHECK(CalledOnValidThread()); |
1468 State previous_state = current_state_; | 1485 State previous_state = current_state_; |
1469 | 1486 |
1470 permanent_error_ = OK; | 1487 permanent_error_ = OK; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 State previous_state = ResetProxyConfig(false); | 1673 State previous_state = ResetProxyConfig(false); |
1657 if (previous_state != STATE_NONE) | 1674 if (previous_state != STATE_NONE) |
1658 ApplyProxyConfigIfAvailable(); | 1675 ApplyProxyConfigIfAvailable(); |
1659 } | 1676 } |
1660 | 1677 |
1661 void ProxyService::OnDNSChanged() { | 1678 void ProxyService::OnDNSChanged() { |
1662 OnIPAddressChanged(); | 1679 OnIPAddressChanged(); |
1663 } | 1680 } |
1664 | 1681 |
1665 } // namespace net | 1682 } // namespace net |
OLD | NEW |