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

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

Issue 1296663003: Componentize proxy code from chrome/browser/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated PROXY_CONFIG_EXPORT Created 5 years, 4 months 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 "chrome/browser/net/pref_proxy_config_tracker_impl.h" 5 #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h"
8 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
9 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/single_thread_task_runner.h"
11 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
12 #include "base/values.h" 14 #include "base/values.h"
13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/common/pref_names.h"
15 #include "components/pref_registry/pref_registry_syncable.h" 15 #include "components/pref_registry/pref_registry_syncable.h"
16 #include "components/proxy_config/proxy_config_dictionary.h" 16 #include "components/proxy_config/proxy_config_dictionary.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "components/proxy_config/proxy_config_pref_names.h"
18 #include "content/public/browser/notification_details.h"
19 #include "content/public/browser/notification_source.h"
20 #include "net/proxy/proxy_list.h" 18 #include "net/proxy/proxy_list.h"
21 #include "net/proxy/proxy_server.h" 19 #include "net/proxy/proxy_server.h"
22 20 #include "url/gurl.h"
23 using content::BrowserThread;
24 21
25 namespace { 22 namespace {
26 23
27 // Determine if |proxy| is of the form "*.googlezip.net". 24 // Determine if |proxy| is of the form "*.googlezip.net".
28 bool IsGooglezipDataReductionProxy(const net::ProxyServer& proxy) { 25 bool IsGooglezipDataReductionProxy(const net::ProxyServer& proxy) {
29 return proxy.is_valid() && !proxy.is_direct() && 26 return proxy.is_valid() && !proxy.is_direct() &&
30 base::EndsWith(proxy.host_port_pair().host(), ".googlezip.net", 27 base::EndsWith(proxy.host_port_pair().host(), ".googlezip.net",
31 base::CompareCase::SENSITIVE); 28 base::CompareCase::SENSITIVE);
32 } 29 }
33 30
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 RemoveGooglezipDataReductionProxiesFromList( 76 RemoveGooglezipDataReductionProxiesFromList(
80 &proxy_rules->proxies_for_https) + 77 &proxy_rules->proxies_for_https) +
81 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies); 78 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies);
82 79
83 UMA_HISTOGRAM_COUNTS_100("Net.PrefProxyConfig.GooglezipProxyRemovalCount", 80 UMA_HISTOGRAM_COUNTS_100("Net.PrefProxyConfig.GooglezipProxyRemovalCount",
84 num_removed_proxies); 81 num_removed_proxies);
85 } 82 }
86 83
87 } // namespace 84 } // namespace
88 85
89 //============================= ChromeProxyConfigService ======================= 86 //============================= ProxyConfigServiceImpl =======================
90 87
91 ChromeProxyConfigService::ChromeProxyConfigService( 88 ProxyConfigServiceImpl::ProxyConfigServiceImpl(
92 net::ProxyConfigService* base_service) 89 net::ProxyConfigService* base_service)
93 : base_service_(base_service), 90 : base_service_(base_service),
94 pref_config_state_(ProxyPrefs::CONFIG_UNSET), 91 pref_config_state_(ProxyPrefs::CONFIG_UNSET),
95 pref_config_read_pending_(true), 92 pref_config_read_pending_(true),
96 registered_observer_(false) { 93 registered_observer_(false) {}
97 }
98 94
99 ChromeProxyConfigService::~ChromeProxyConfigService() { 95 ProxyConfigServiceImpl::~ProxyConfigServiceImpl() {
100 if (registered_observer_ && base_service_.get()) 96 if (registered_observer_ && base_service_.get())
101 base_service_->RemoveObserver(this); 97 base_service_->RemoveObserver(this);
102 } 98 }
103 99
104 void ChromeProxyConfigService::AddObserver( 100 void ProxyConfigServiceImpl::AddObserver(
105 net::ProxyConfigService::Observer* observer) { 101 net::ProxyConfigService::Observer* observer) {
106 RegisterObserver(); 102 RegisterObserver();
107 observers_.AddObserver(observer); 103 observers_.AddObserver(observer);
108 } 104 }
109 105
110 void ChromeProxyConfigService::RemoveObserver( 106 void ProxyConfigServiceImpl::RemoveObserver(
111 net::ProxyConfigService::Observer* observer) { 107 net::ProxyConfigService::Observer* observer) {
112 observers_.RemoveObserver(observer); 108 observers_.RemoveObserver(observer);
113 } 109 }
114 110
115 net::ProxyConfigService::ConfigAvailability 111 net::ProxyConfigService::ConfigAvailability
116 ChromeProxyConfigService::GetLatestProxyConfig(net::ProxyConfig* config) { 112 ProxyConfigServiceImpl::GetLatestProxyConfig(net::ProxyConfig* config) {
117 RegisterObserver(); 113 RegisterObserver();
118 114
119 if (pref_config_read_pending_) 115 if (pref_config_read_pending_)
120 return net::ProxyConfigService::CONFIG_PENDING; 116 return net::ProxyConfigService::CONFIG_PENDING;
121 117
122 // Ask the base service if available. 118 // Ask the base service if available.
123 net::ProxyConfig system_config; 119 net::ProxyConfig system_config;
124 ConfigAvailability system_availability = 120 ConfigAvailability system_availability =
125 net::ProxyConfigService::CONFIG_UNSET; 121 net::ProxyConfigService::CONFIG_UNSET;
126 if (base_service_.get()) 122 if (base_service_.get())
127 system_availability = base_service_->GetLatestProxyConfig(&system_config); 123 system_availability = base_service_->GetLatestProxyConfig(&system_config);
128 124
129 ProxyPrefs::ConfigState config_state; 125 ProxyPrefs::ConfigState config_state;
130 return PrefProxyConfigTrackerImpl::GetEffectiveProxyConfig( 126 return PrefProxyConfigTrackerImpl::GetEffectiveProxyConfig(
131 pref_config_state_, pref_config_, 127 pref_config_state_, pref_config_, system_availability, system_config,
132 system_availability, system_config, false, 128 false, &config_state, config);
133 &config_state, config);
134 } 129 }
135 130
136 void ChromeProxyConfigService::OnLazyPoll() { 131 void ProxyConfigServiceImpl::OnLazyPoll() {
137 if (base_service_.get()) 132 if (base_service_.get())
138 base_service_->OnLazyPoll(); 133 base_service_->OnLazyPoll();
139 } 134 }
140 135
141 void ChromeProxyConfigService::UpdateProxyConfig( 136 void ProxyConfigServiceImpl::UpdateProxyConfig(
142 ProxyPrefs::ConfigState config_state, 137 ProxyPrefs::ConfigState config_state,
143 const net::ProxyConfig& config) { 138 const net::ProxyConfig& config) {
144 DCHECK_CURRENTLY_ON(BrowserThread::IO); 139 DCHECK(thread_checker_.CalledOnValidThread());
Abhishek 2015/08/26 09:48:59 Tests are crashing at this place. http://build.ch
droger 2015/08/26 10:11:22 It looks like it happens because the object is cre
Abhishek 2015/08/26 13:44:36 I've changed it as suggested here.
145
146 pref_config_read_pending_ = false; 140 pref_config_read_pending_ = false;
147 pref_config_state_ = config_state; 141 pref_config_state_ = config_state;
148 pref_config_ = config; 142 pref_config_ = config;
149 143
150 if (!observers_.might_have_observers()) 144 if (!observers_.might_have_observers())
151 return; 145 return;
152 146
153 // Evaluate the proxy configuration. If GetLatestProxyConfig returns 147 // Evaluate the proxy configuration. If GetLatestProxyConfig returns
154 // CONFIG_PENDING, we are using the system proxy service, but it doesn't have 148 // CONFIG_PENDING, we are using the system proxy service, but it doesn't have
155 // a valid configuration yet. Once it is ready, OnProxyConfigChanged() will be 149 // a valid configuration yet. Once it is ready, OnProxyConfigChanged() will be
156 // called and broadcast the proxy configuration. 150 // called and broadcast the proxy configuration.
157 // Note: If a switch between a preference proxy configuration and the system 151 // Note: If a switch between a preference proxy configuration and the system
158 // proxy configuration occurs an unnecessary notification might get send if 152 // proxy configuration occurs an unnecessary notification might get send if
159 // the two configurations agree. This case should be rare however, so we don't 153 // the two configurations agree. This case should be rare however, so we don't
160 // handle that case specially. 154 // handle that case specially.
161 net::ProxyConfig new_config; 155 net::ProxyConfig new_config;
162 ConfigAvailability availability = GetLatestProxyConfig(&new_config); 156 ConfigAvailability availability = GetLatestProxyConfig(&new_config);
163 if (availability != CONFIG_PENDING) { 157 if (availability != CONFIG_PENDING) {
164 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, 158 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_,
165 OnProxyConfigChanged(new_config, availability)); 159 OnProxyConfigChanged(new_config, availability));
166 } 160 }
167 } 161 }
168 162
169 void ChromeProxyConfigService::OnProxyConfigChanged( 163 void ProxyConfigServiceImpl::OnProxyConfigChanged(
170 const net::ProxyConfig& config, 164 const net::ProxyConfig& config,
171 ConfigAvailability availability) { 165 ConfigAvailability availability) {
172 DCHECK_CURRENTLY_ON(BrowserThread::IO); 166 DCHECK(thread_checker_.CalledOnValidThread());
173 167
174 // Check whether there is a proxy configuration defined by preferences. In 168 // Check whether there is a proxy configuration defined by preferences. In
175 // this case that proxy configuration takes precedence and the change event 169 // this case that proxy configuration takes precedence and the change event
176 // from the delegate proxy service can be disregarded. 170 // from the delegate proxy service can be disregarded.
177 if (!PrefProxyConfigTrackerImpl::PrefPrecedes(pref_config_state_)) { 171 if (!PrefProxyConfigTrackerImpl::PrefPrecedes(pref_config_state_)) {
178 net::ProxyConfig actual_config; 172 net::ProxyConfig actual_config;
179 availability = GetLatestProxyConfig(&actual_config); 173 availability = GetLatestProxyConfig(&actual_config);
180 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, 174 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_,
181 OnProxyConfigChanged(actual_config, availability)); 175 OnProxyConfigChanged(actual_config, availability));
182 } 176 }
183 } 177 }
184 178
185 void ChromeProxyConfigService::RegisterObserver() { 179 void ProxyConfigServiceImpl::RegisterObserver() {
186 DCHECK_CURRENTLY_ON(BrowserThread::IO); 180 DCHECK(thread_checker_.CalledOnValidThread());
187 if (!registered_observer_ && base_service_.get()) { 181 if (!registered_observer_ && base_service_.get()) {
188 base_service_->AddObserver(this); 182 base_service_->AddObserver(this);
189 registered_observer_ = true; 183 registered_observer_ = true;
190 } 184 }
191 } 185 }
192 186
193 //========================= PrefProxyConfigTrackerImpl ========================= 187 //========================= PrefProxyConfigTrackerImpl =========================
194 188
195 PrefProxyConfigTrackerImpl::PrefProxyConfigTrackerImpl( 189 PrefProxyConfigTrackerImpl::PrefProxyConfigTrackerImpl(
196 PrefService* pref_service) 190 PrefService* pref_service,
191 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
197 : pref_service_(pref_service), 192 : pref_service_(pref_service),
198 chrome_proxy_config_service_(NULL), 193 proxy_config_service_impl_(NULL),
199 update_pending_(true) { 194 update_pending_(true),
195 io_task_runner_(io_task_runner) {
200 config_state_ = ReadPrefConfig(pref_service_, &pref_config_); 196 config_state_ = ReadPrefConfig(pref_service_, &pref_config_);
201 proxy_prefs_.Init(pref_service); 197 proxy_prefs_.Init(pref_service);
202 proxy_prefs_.Add(prefs::kProxy, 198 proxy_prefs_.Add(ProxyPrefs::prefs::kProxy,
203 base::Bind(&PrefProxyConfigTrackerImpl::OnProxyPrefChanged, 199 base::Bind(&PrefProxyConfigTrackerImpl::OnProxyPrefChanged,
204 base::Unretained(this))); 200 base::Unretained(this)));
205 } 201 }
206 202
207 PrefProxyConfigTrackerImpl::~PrefProxyConfigTrackerImpl() { 203 PrefProxyConfigTrackerImpl::~PrefProxyConfigTrackerImpl() {
208 DCHECK(pref_service_ == NULL); 204 DCHECK(pref_service_ == NULL);
209 } 205 }
210 206
211 scoped_ptr<net::ProxyConfigService> 207 scoped_ptr<net::ProxyConfigService>
212 PrefProxyConfigTrackerImpl::CreateTrackingProxyConfigService( 208 PrefProxyConfigTrackerImpl::CreateTrackingProxyConfigService(
213 scoped_ptr<net::ProxyConfigService> base_service) { 209 scoped_ptr<net::ProxyConfigService> base_service) {
214 chrome_proxy_config_service_ = 210 proxy_config_service_impl_ =
215 new ChromeProxyConfigService(base_service.release()); 211 new ProxyConfigServiceImpl(base_service.release());
216 VLOG(1) << this << ": set chrome proxy config service to " 212 VLOG(1) << this << ": set chrome proxy config service to "
217 << chrome_proxy_config_service_; 213 << proxy_config_service_impl_;
218 if (chrome_proxy_config_service_ && update_pending_) 214 if (proxy_config_service_impl_ && update_pending_)
219 OnProxyConfigChanged(config_state_, pref_config_); 215 OnProxyConfigChanged(config_state_, pref_config_);
220 216
221 return scoped_ptr<net::ProxyConfigService>(chrome_proxy_config_service_); 217 return scoped_ptr<net::ProxyConfigService>(proxy_config_service_impl_);
222 } 218 }
223 219
224 void PrefProxyConfigTrackerImpl::DetachFromPrefService() { 220 void PrefProxyConfigTrackerImpl::DetachFromPrefService() {
225 DCHECK_CURRENTLY_ON(BrowserThread::UI); 221 DCHECK(thread_checker_.CalledOnValidThread());
226 // Stop notifications. 222 // Stop notifications.
227 proxy_prefs_.RemoveAll(); 223 proxy_prefs_.RemoveAll();
228 pref_service_ = NULL; 224 pref_service_ = NULL;
229 chrome_proxy_config_service_ = NULL; 225 proxy_config_service_impl_ = NULL;
230 } 226 }
231 227
232 // static 228 // static
233 bool PrefProxyConfigTrackerImpl::PrefPrecedes( 229 bool PrefProxyConfigTrackerImpl::PrefPrecedes(
234 ProxyPrefs::ConfigState config_state) { 230 ProxyPrefs::ConfigState config_state) {
235 return config_state == ProxyPrefs::CONFIG_POLICY || 231 return config_state == ProxyPrefs::CONFIG_POLICY ||
236 config_state == ProxyPrefs::CONFIG_EXTENSION || 232 config_state == ProxyPrefs::CONFIG_EXTENSION ||
237 config_state == ProxyPrefs::CONFIG_OTHER_PRECEDE; 233 config_state == ProxyPrefs::CONFIG_OTHER_PRECEDE;
238 } 234 }
239 235
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (rv == net::ProxyConfigService::CONFIG_VALID) 273 if (rv == net::ProxyConfigService::CONFIG_VALID)
278 RemoveGooglezipDataReductionProxies(&effective_config->proxy_rules()); 274 RemoveGooglezipDataReductionProxies(&effective_config->proxy_rules());
279 275
280 return rv; 276 return rv;
281 } 277 }
282 278
283 // static 279 // static
284 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) { 280 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) {
285 base::DictionaryValue* default_settings = 281 base::DictionaryValue* default_settings =
286 ProxyConfigDictionary::CreateSystem(); 282 ProxyConfigDictionary::CreateSystem();
287 registry->RegisterDictionaryPref(prefs::kProxy, default_settings); 283 registry->RegisterDictionaryPref(ProxyPrefs::prefs::kProxy, default_settings);
288 } 284 }
289 285
290 // static 286 // static
291 void PrefProxyConfigTrackerImpl::RegisterProfilePrefs( 287 void PrefProxyConfigTrackerImpl::RegisterProfilePrefs(
292 user_prefs::PrefRegistrySyncable* pref_service) { 288 user_prefs::PrefRegistrySyncable* pref_service) {
293 base::DictionaryValue* default_settings = 289 base::DictionaryValue* default_settings =
294 ProxyConfigDictionary::CreateSystem(); 290 ProxyConfigDictionary::CreateSystem();
295 pref_service->RegisterDictionaryPref(prefs::kProxy, default_settings); 291 pref_service->RegisterDictionaryPref(ProxyPrefs::prefs::kProxy,
292 default_settings);
296 } 293 }
297 294
298 // static 295 // static
299 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig( 296 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig(
300 const PrefService* pref_service, 297 const PrefService* pref_service,
301 net::ProxyConfig* config) { 298 net::ProxyConfig* config) {
302 DCHECK_CURRENTLY_ON(BrowserThread::UI);
303
304 // Clear the configuration and source. 299 // Clear the configuration and source.
305 *config = net::ProxyConfig(); 300 *config = net::ProxyConfig();
306 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET; 301 ProxyPrefs::ConfigState config_state = ProxyPrefs::CONFIG_UNSET;
307 302
308 const PrefService::Preference* pref = 303 const PrefService::Preference* pref =
309 pref_service->FindPreference(prefs::kProxy); 304 pref_service->FindPreference(ProxyPrefs::prefs::kProxy);
310 DCHECK(pref); 305 DCHECK(pref);
311 306
312 const base::DictionaryValue* dict = 307 const base::DictionaryValue* dict =
313 pref_service->GetDictionary(prefs::kProxy); 308 pref_service->GetDictionary(ProxyPrefs::prefs::kProxy);
314 DCHECK(dict); 309 DCHECK(dict);
315 ProxyConfigDictionary proxy_dict(dict); 310 ProxyConfigDictionary proxy_dict(dict);
316 311
317 if (PrefConfigToNetConfig(proxy_dict, config)) { 312 if (PrefConfigToNetConfig(proxy_dict, config)) {
318 if (!pref->IsUserModifiable() || pref->HasUserSetting()) { 313 if (!pref->IsUserModifiable() || pref->HasUserSetting()) {
319 if (pref->IsManaged()) 314 if (pref->IsManaged())
320 config_state = ProxyPrefs::CONFIG_POLICY; 315 config_state = ProxyPrefs::CONFIG_POLICY;
321 else if (pref->IsExtensionControlled()) 316 else if (pref->IsExtensionControlled())
322 config_state = ProxyPrefs::CONFIG_EXTENSION; 317 config_state = ProxyPrefs::CONFIG_EXTENSION;
323 else 318 else
324 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE; 319 config_state = ProxyPrefs::CONFIG_OTHER_PRECEDE;
325 } else { 320 } else {
326 config_state = ProxyPrefs::CONFIG_FALLBACK; 321 config_state = ProxyPrefs::CONFIG_FALLBACK;
327 } 322 }
328 } 323 }
329 324
330 return config_state; 325 return config_state;
331 } 326 }
332 327
333 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::GetProxyConfig( 328 ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::GetProxyConfig(
334 net::ProxyConfig* config) { 329 net::ProxyConfig* config) {
335 DCHECK_CURRENTLY_ON(BrowserThread::UI); 330 DCHECK(thread_checker_.CalledOnValidThread());
336 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 331 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
337 *config = pref_config_; 332 *config = pref_config_;
338 return config_state_; 333 return config_state_;
339 } 334 }
340 335
341 void PrefProxyConfigTrackerImpl::OnProxyConfigChanged( 336 void PrefProxyConfigTrackerImpl::OnProxyConfigChanged(
342 ProxyPrefs::ConfigState config_state, 337 ProxyPrefs::ConfigState config_state,
343 const net::ProxyConfig& config) { 338 const net::ProxyConfig& config) {
344 if (!chrome_proxy_config_service_) { 339 if (!proxy_config_service_impl_) {
345 VLOG(1) << "No chrome proxy config service to push to UpdateProxyConfig"; 340 VLOG(1) << "No chrome proxy config service to push to UpdateProxyConfig";
346 update_pending_ = true; 341 update_pending_ = true;
347 return; 342 return;
348 } 343 }
349 update_pending_ = !BrowserThread::PostTask( 344 update_pending_ = !io_task_runner_->PostTask(
350 BrowserThread::IO, FROM_HERE, 345 FROM_HERE, base::Bind(&ProxyConfigServiceImpl::UpdateProxyConfig,
351 base::Bind(&ChromeProxyConfigService::UpdateProxyConfig, 346 base::Unretained(proxy_config_service_impl_),
352 base::Unretained(chrome_proxy_config_service_), 347 config_state, config));
353 config_state, config));
354 VLOG(1) << this << (update_pending_ ? ": Error" : ": Done") 348 VLOG(1) << this << (update_pending_ ? ": Error" : ": Done")
355 << " pushing proxy to UpdateProxyConfig"; 349 << " pushing proxy to UpdateProxyConfig";
356 } 350 }
357 351
358 bool PrefProxyConfigTrackerImpl::PrefConfigToNetConfig( 352 bool PrefProxyConfigTrackerImpl::PrefConfigToNetConfig(
359 const ProxyConfigDictionary& proxy_dict, 353 const ProxyConfigDictionary& proxy_dict,
360 net::ProxyConfig* config) { 354 net::ProxyConfig* config) {
361 ProxyPrefs::ProxyMode mode; 355 ProxyPrefs::ProxyMode mode;
362 if (!proxy_dict.GetMode(&mode)) { 356 if (!proxy_dict.GetMode(&mode)) {
363 // Fall back to system settings if the mode preference is invalid. 357 // Fall back to system settings if the mode preference is invalid.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 404 }
411 case ProxyPrefs::kModeCount: { 405 case ProxyPrefs::kModeCount: {
412 // Fall through to NOTREACHED(). 406 // Fall through to NOTREACHED().
413 } 407 }
414 } 408 }
415 NOTREACHED() << "Unknown proxy mode, falling back to system settings."; 409 NOTREACHED() << "Unknown proxy mode, falling back to system settings.";
416 return false; 410 return false;
417 } 411 }
418 412
419 void PrefProxyConfigTrackerImpl::OnProxyPrefChanged() { 413 void PrefProxyConfigTrackerImpl::OnProxyPrefChanged() {
420 DCHECK_CURRENTLY_ON(BrowserThread::UI); 414 DCHECK(thread_checker_.CalledOnValidThread());
421 net::ProxyConfig new_config; 415 net::ProxyConfig new_config;
422 ProxyPrefs::ConfigState config_state = ReadPrefConfig(pref_service_, 416 ProxyPrefs::ConfigState config_state =
423 &new_config); 417 ReadPrefConfig(pref_service_, &new_config);
424 if (config_state_ != config_state || 418 if (config_state_ != config_state ||
425 (config_state_ != ProxyPrefs::CONFIG_UNSET && 419 (config_state_ != ProxyPrefs::CONFIG_UNSET &&
426 !pref_config_.Equals(new_config))) { 420 !pref_config_.Equals(new_config))) {
427 config_state_ = config_state; 421 config_state_ = config_state;
428 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 422 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
429 pref_config_ = new_config; 423 pref_config_ = new_config;
430 update_pending_ = true; 424 update_pending_ = true;
431 } 425 }
432 if (update_pending_) 426 if (update_pending_)
433 OnProxyConfigChanged(config_state, new_config); 427 OnProxyConfigChanged(config_state, new_config);
434 } 428 }
OLDNEW
« no previous file with comments | « components/proxy_config/pref_proxy_config_tracker_impl.h ('k') | components/proxy_config/proxy_config_pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698