| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "components/proxy_config/pref_proxy_config_tracker_impl.h" | 5 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // CONFIG_PENDING, we are using the system proxy service, but it doesn't have | 87 // CONFIG_PENDING, we are using the system proxy service, but it doesn't have |
| 88 // a valid configuration yet. Once it is ready, OnProxyConfigChanged() will be | 88 // a valid configuration yet. Once it is ready, OnProxyConfigChanged() will be |
| 89 // called and broadcast the proxy configuration. | 89 // called and broadcast the proxy configuration. |
| 90 // Note: If a switch between a preference proxy configuration and the system | 90 // Note: If a switch between a preference proxy configuration and the system |
| 91 // proxy configuration occurs an unnecessary notification might get send if | 91 // proxy configuration occurs an unnecessary notification might get send if |
| 92 // the two configurations agree. This case should be rare however, so we don't | 92 // the two configurations agree. This case should be rare however, so we don't |
| 93 // handle that case specially. | 93 // handle that case specially. |
| 94 net::ProxyConfig new_config; | 94 net::ProxyConfig new_config; |
| 95 ConfigAvailability availability = GetLatestProxyConfig(&new_config); | 95 ConfigAvailability availability = GetLatestProxyConfig(&new_config); |
| 96 if (availability != CONFIG_PENDING) { | 96 if (availability != CONFIG_PENDING) { |
| 97 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, | 97 for (net::ProxyConfigService::Observer& observer : observers_) |
| 98 OnProxyConfigChanged(new_config, availability)); | 98 observer.OnProxyConfigChanged(new_config, availability); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 void ProxyConfigServiceImpl::OnProxyConfigChanged( | 102 void ProxyConfigServiceImpl::OnProxyConfigChanged( |
| 103 const net::ProxyConfig& config, | 103 const net::ProxyConfig& config, |
| 104 ConfigAvailability availability) { | 104 ConfigAvailability availability) { |
| 105 DCHECK(thread_checker_.CalledOnValidThread()); | 105 DCHECK(thread_checker_.CalledOnValidThread()); |
| 106 | 106 |
| 107 // Check whether there is a proxy configuration defined by preferences. In | 107 // Check whether there is a proxy configuration defined by preferences. In |
| 108 // this case that proxy configuration takes precedence and the change event | 108 // this case that proxy configuration takes precedence and the change event |
| 109 // from the delegate proxy service can be disregarded. | 109 // from the delegate proxy service can be disregarded. |
| 110 if (!PrefProxyConfigTrackerImpl::PrefPrecedes(pref_config_state_)) { | 110 if (!PrefProxyConfigTrackerImpl::PrefPrecedes(pref_config_state_)) { |
| 111 net::ProxyConfig actual_config; | 111 net::ProxyConfig actual_config; |
| 112 availability = GetLatestProxyConfig(&actual_config); | 112 availability = GetLatestProxyConfig(&actual_config); |
| 113 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, | 113 for (net::ProxyConfigService::Observer& observer : observers_) |
| 114 OnProxyConfigChanged(actual_config, availability)); | 114 observer.OnProxyConfigChanged(actual_config, availability); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void ProxyConfigServiceImpl::RegisterObserver() { | 118 void ProxyConfigServiceImpl::RegisterObserver() { |
| 119 DCHECK(thread_checker_.CalledOnValidThread()); | 119 DCHECK(thread_checker_.CalledOnValidThread()); |
| 120 if (!registered_observer_ && base_service_.get()) { | 120 if (!registered_observer_ && base_service_.get()) { |
| 121 base_service_->AddObserver(this); | 121 base_service_->AddObserver(this); |
| 122 registered_observer_ = true; | 122 registered_observer_ = true; |
| 123 } | 123 } |
| 124 } | 124 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 (config_state_ != ProxyPrefs::CONFIG_UNSET && | 347 (config_state_ != ProxyPrefs::CONFIG_UNSET && |
| 348 !pref_config_.Equals(new_config))) { | 348 !pref_config_.Equals(new_config))) { |
| 349 config_state_ = config_state; | 349 config_state_ = config_state; |
| 350 if (config_state_ != ProxyPrefs::CONFIG_UNSET) | 350 if (config_state_ != ProxyPrefs::CONFIG_UNSET) |
| 351 pref_config_ = new_config; | 351 pref_config_ = new_config; |
| 352 update_pending_ = true; | 352 update_pending_ = true; |
| 353 } | 353 } |
| 354 if (update_pending_) | 354 if (update_pending_) |
| 355 OnProxyConfigChanged(config_state, new_config); | 355 OnProxyConfigChanged(config_state, new_config); |
| 356 } | 356 } |
| OLD | NEW |