| 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 if (init_proxy_resolver_) |
| 1469 init_proxy_resolver_->OnShutdown(); |
| 1470 if (proxy_script_fetcher_) |
| 1471 proxy_script_fetcher_->OnShutdown(); |
| 1472 if (dhcp_proxy_script_fetcher_) |
| 1473 dhcp_proxy_script_fetcher_->OnShutdown(); |
| 1474 } |
| 1475 |
| 1461 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const { | 1476 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const { |
| 1462 DCHECK(CalledOnValidThread()); | 1477 DCHECK(CalledOnValidThread()); |
| 1463 return proxy_script_fetcher_.get(); | 1478 return proxy_script_fetcher_.get(); |
| 1464 } | 1479 } |
| 1465 | 1480 |
| 1466 ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) { | 1481 ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) { |
| 1467 DCHECK(CalledOnValidThread()); | 1482 DCHECK(CalledOnValidThread()); |
| 1468 State previous_state = current_state_; | 1483 State previous_state = current_state_; |
| 1469 | 1484 |
| 1470 permanent_error_ = OK; | 1485 permanent_error_ = OK; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 State previous_state = ResetProxyConfig(false); | 1671 State previous_state = ResetProxyConfig(false); |
| 1657 if (previous_state != STATE_NONE) | 1672 if (previous_state != STATE_NONE) |
| 1658 ApplyProxyConfigIfAvailable(); | 1673 ApplyProxyConfigIfAvailable(); |
| 1659 } | 1674 } |
| 1660 | 1675 |
| 1661 void ProxyService::OnDNSChanged() { | 1676 void ProxyService::OnDNSChanged() { |
| 1662 OnIPAddressChanged(); | 1677 OnIPAddressChanged(); |
| 1663 } | 1678 } |
| 1664 | 1679 |
| 1665 } // namespace net | 1680 } // namespace net |
| OLD | NEW |