Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: components/proxy_config/pref_proxy_config_tracker_impl.cc

Issue 2444753002: Reduce usage of FOR_EACH_OBSERVER macro in components/ (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « components/prefs/value_map_pref_store.cc ('k') | components/proxy_config/pref_proxy_config_tracker_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698