diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 00:52:01 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 00:52:01 +0000 |
commit | 00fb5ef53f9afadc88ddaf1e091a8114b5a9365b (patch) | |
tree | d185578d6c611e9d21d05fc9e87ade6b399b3360 /net/proxy/proxy_service.cc | |
parent | 92464e9acbc960e08355d5983560de04a939c1f2 (diff) | |
download | chromium_src-00fb5ef53f9afadc88ddaf1e091a8114b5a9365b.zip chromium_src-00fb5ef53f9afadc88ddaf1e091a8114b5a9365b.tar.gz chromium_src-00fb5ef53f9afadc88ddaf1e091a8114b5a9365b.tar.bz2 |
Change the logging of PROXY_CONFIG_CHANGED so it is not displayed each time the IP address changes.
BUG=53387
Review URL: http://codereview.chromium.org/3404017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60393 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service.cc')
-rw-r--r-- | net/proxy/proxy_service.cc | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index c74b8b0..ee4a403 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -567,10 +567,17 @@ void ProxyService::SetReady() { void ProxyService::ApplyProxyConfigIfAvailable() { DCHECK_EQ(STATE_NONE, current_state_); - current_state_ = STATE_WAITING_FOR_PROXY_CONFIG; - config_service_->OnLazyPoll(); + // If we have already fetched the configuration, start applying it. + if (fetched_config_.is_valid()) { + InitializeUsingLastFetchedConfig(); + return; + } + + // Otherwise we need to first fetch the configuration. + current_state_ = STATE_WAITING_FOR_PROXY_CONFIG; + // Retrieve the current proxy configuration from the ProxyConfigService. // If a configuration is not available yet, we will get called back later // by our ProxyConfigService::Observer once it changes. @@ -680,7 +687,7 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result, void ProxyService::SetProxyScriptFetcher( ProxyScriptFetcher* proxy_script_fetcher) { - State previous_state = ResetProxyConfig(); + State previous_state = ResetProxyConfig(false); proxy_script_fetcher_.reset(proxy_script_fetcher); if (previous_state != STATE_NONE) ApplyProxyConfigIfAvailable(); @@ -690,13 +697,15 @@ ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const { return proxy_script_fetcher_.get(); } -ProxyService::State ProxyService::ResetProxyConfig() { +ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) { State previous_state = current_state_; proxy_retry_info_.clear(); init_proxy_resolver_.reset(); SuspendAllPendingRequests(); config_ = ProxyConfig(); + if (reset_fetched_config) + fetched_config_ = ProxyConfig(); current_state_ = STATE_NONE; return previous_state; @@ -704,7 +713,7 @@ ProxyService::State ProxyService::ResetProxyConfig() { void ProxyService::ResetConfigService( ProxyConfigService* new_proxy_config_service) { - State previous_state = ResetProxyConfig(); + State previous_state = ResetProxyConfig(true); // Release the old configuration service. if (config_service_.get()) @@ -724,7 +733,7 @@ void ProxyService::PurgeMemory() { } void ProxyService::ForceReloadProxyConfig() { - ResetProxyConfig(); + ResetProxyConfig(false); ApplyProxyConfigIfAvailable(); } @@ -767,17 +776,10 @@ ProxyConfigService* ProxyService::CreateSystemProxyConfigService( } void ProxyService::OnProxyConfigChanged(const ProxyConfig& config) { - ProxyConfig old_fetched_config = fetched_config_; - ResetProxyConfig(); - - // Increment the ID to reflect that the config has changed. - fetched_config_ = config; - fetched_config_.set_id(next_config_id_++); - // Emit the proxy settings change to the NetLog stream. if (net_log_) { scoped_refptr<NetLog::EventParameters> params = - new ProxyConfigChangedNetLogParam(old_fetched_config, fetched_config_); + new ProxyConfigChangedNetLogParam(fetched_config_, config); net_log_->AddEntry(net::NetLog::TYPE_PROXY_CONFIG_CHANGED, base::TimeTicks::Now(), NetLog::Source(), @@ -785,6 +787,21 @@ void ProxyService::OnProxyConfigChanged(const ProxyConfig& config) { params); } + // Set the new configuration as the most recently fetched one. + fetched_config_ = config; + fetched_config_.set_id(1); // Needed for a later DCHECK of is_valid(). + + InitializeUsingLastFetchedConfig(); +} + +void ProxyService::InitializeUsingLastFetchedConfig() { + ResetProxyConfig(false); + + DCHECK(fetched_config_.is_valid()); + + // Increment the ID to reflect that the config has changed. + fetched_config_.set_id(next_config_id_++); + if (!fetched_config_.HasAutomaticSettings()) { config_ = fetched_config_; SetReady(); @@ -814,7 +831,7 @@ void ProxyService::OnIPAddressChanged() { stall_proxy_autoconfig_until_ = base::TimeTicks::Now() + stall_proxy_auto_config_delay_; - State previous_state = ResetProxyConfig(); + State previous_state = ResetProxyConfig(false); if (previous_state != STATE_NONE) ApplyProxyConfigIfAvailable(); } |