Chromium Code Reviews| Index: chrome/browser/net/pref_proxy_config_service.cc |
| =================================================================== |
| --- chrome/browser/net/pref_proxy_config_service.cc (revision 103881) |
| +++ chrome/browser/net/pref_proxy_config_service.cc (working copy) |
| @@ -16,7 +16,9 @@ |
| PrefProxyConfigTracker::PrefProxyConfigTracker(PrefService* pref_service) |
| : pref_service_(pref_service) { |
| - config_state_ = ReadPrefConfig(&pref_config_); |
| + ui_config_state_ = ReadPrefConfig(&ui_pref_config_); |
| + io_config_state_ = ui_config_state_; |
| + io_pref_config_ = ui_pref_config_; |
| proxy_prefs_observer_.reset( |
| PrefSetObserver::CreateProxyPrefSetObserver(pref_service_, this)); |
| } |
| @@ -26,13 +28,21 @@ |
| } |
| PrefProxyConfigTracker::ConfigState |
| - PrefProxyConfigTracker::GetProxyConfig(net::ProxyConfig* config) { |
| + PrefProxyConfigTracker::IOGetProxyConfig(net::ProxyConfig* config) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - if (config_state_ != CONFIG_UNSET) |
| - *config = pref_config_; |
| - return config_state_; |
| + if (io_config_state_ != CONFIG_UNSET) |
| + *config = io_pref_config_; |
| + return io_config_state_; |
| } |
| +PrefProxyConfigTracker::ConfigState |
| + PrefProxyConfigTracker::UIGetProxyConfig(net::ProxyConfig* config) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + if (ui_config_state_ != CONFIG_UNSET) |
| + *config = ui_pref_config_; |
| + return ui_config_state_; |
| +} |
| + |
| void PrefProxyConfigTracker::DetachFromPrefService() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| // Stop notifications. |
| @@ -60,11 +70,18 @@ |
| Source<PrefService>(source).ptr() == pref_service_) { |
| net::ProxyConfig new_config; |
| ConfigState config_state = ReadPrefConfig(&new_config); |
| - BrowserThread::PostTask( |
| - BrowserThread::IO, FROM_HERE, |
| - NewRunnableMethod(this, |
| - &PrefProxyConfigTracker::InstallProxyConfig, |
| - new_config, config_state)); |
| + if (ui_config_state_ != config_state || |
| + (ui_config_state_ != CONFIG_UNSET && |
|
Mattias Nissler (ping if slow)
2011/10/05 10:18:36
nit: not breaking this line would make the thing m
kuan
2011/10/07 00:30:41
i didn't want to, but it won't fit, so i don't hv
|
| + !ui_pref_config_.Equals(new_config))) { |
| + ui_config_state_ = config_state; |
| + if (ui_config_state_ != CONFIG_UNSET) |
| + ui_pref_config_ = new_config; |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + NewRunnableMethod(this, |
| + &PrefProxyConfigTracker::InstallProxyConfig, |
| + new_config, config_state)); |
| + } |
| } else { |
| NOTREACHED() << "Unexpected notification of type " << type; |
| } |
| @@ -74,13 +91,10 @@ |
| const net::ProxyConfig& config, |
| PrefProxyConfigTracker::ConfigState config_state) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - if (config_state_ != config_state || |
| - (config_state_ != CONFIG_UNSET && !pref_config_.Equals(config))) { |
| - config_state_ = config_state; |
| - if (config_state_ != CONFIG_UNSET) |
| - pref_config_ = config; |
| - FOR_EACH_OBSERVER(Observer, observers_, OnPrefProxyConfigChanged()); |
| - } |
| + io_config_state_ = config_state; |
| + if (io_config_state_ != CONFIG_UNSET) |
| + io_pref_config_ = config; |
| + FOR_EACH_OBSERVER(Observer, observers_, OnPrefProxyConfigChanged()); |
| } |
| PrefProxyConfigTracker::ConfigState |
| @@ -198,7 +212,7 @@ |
| RegisterObservers(); |
| net::ProxyConfig pref_config; |
| PrefProxyConfigTracker::ConfigState state = |
| - pref_config_tracker_->GetProxyConfig(&pref_config); |
| + pref_config_tracker_->IOGetProxyConfig(&pref_config); |
| if (state == PrefProxyConfigTracker::CONFIG_PRESENT) { |
| *config = pref_config; |
| return CONFIG_VALID; |
| @@ -232,7 +246,7 @@ |
| // this case that proxy configuration takes precedence and the change event |
| // from the delegate proxy service can be disregarded. |
| net::ProxyConfig actual_config; |
| - if (pref_config_tracker_->GetProxyConfig(&actual_config) != |
| + if (pref_config_tracker_->IOGetProxyConfig(&actual_config) != |
| PrefProxyConfigTracker::CONFIG_PRESENT) { |
| availability = GetLatestProxyConfig(&actual_config); |
| FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, |