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

Unified Diff: components/proxy_config/pref_proxy_config_tracker_impl.cc

Issue 2946153002: Fix chromeos::ProxyConfigService starting with the wrong ProxyConfig. (Closed)
Patch Set: Remove incorrect comment Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/proxy_config/pref_proxy_config_tracker_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proxy_config/pref_proxy_config_tracker_impl.cc
diff --git a/components/proxy_config/pref_proxy_config_tracker_impl.cc b/components/proxy_config/pref_proxy_config_tracker_impl.cc
index ab770b2ddab0329bac1acb1d6c147486c237d77b..6c4f03d9124f9ac48ab09562e3efdc64caf86abd 100644
--- a/components/proxy_config/pref_proxy_config_tracker_impl.cc
+++ b/components/proxy_config/pref_proxy_config_tracker_impl.cc
@@ -13,7 +13,6 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/values.h"
-#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/proxy_config_dictionary.h"
@@ -132,7 +131,10 @@ PrefProxyConfigTrackerImpl::PrefProxyConfigTrackerImpl(
: pref_service_(pref_service),
proxy_config_service_impl_(NULL),
io_task_runner_(io_task_runner) {
- config_state_ = ReadPrefConfig(pref_service_, &pref_config_);
+ pref_config_state_ = ReadPrefConfig(pref_service_, &pref_config_);
+ active_config_state_ = pref_config_state_;
+ active_config_ = pref_config_;
+
proxy_prefs_.Init(pref_service);
proxy_prefs_.Add(proxy_config::prefs::kProxy,
base::Bind(&PrefProxyConfigTrackerImpl::OnProxyPrefChanged,
@@ -148,7 +150,7 @@ PrefProxyConfigTrackerImpl::CreateTrackingProxyConfigService(
std::unique_ptr<net::ProxyConfigService> base_service) {
DCHECK(!proxy_config_service_impl_);
proxy_config_service_impl_ = new ProxyConfigServiceImpl(
- std::move(base_service), config_state_, pref_config_);
+ std::move(base_service), active_config_state_, active_config_);
VLOG(1) << this << ": set chrome proxy config service to "
<< proxy_config_service_impl_;
@@ -212,13 +214,12 @@ void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) {
// static
void PrefProxyConfigTrackerImpl::RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* pref_service) {
+ PrefRegistrySimple* registry) {
std::unique_ptr<base::DictionaryValue> default_settings =
ProxyConfigDictionary::CreateSystem();
- pref_service->RegisterDictionaryPref(proxy_config::prefs::kProxy,
- std::move(default_settings));
- pref_service->RegisterBooleanPref(proxy_config::prefs::kUseSharedProxies,
- false);
+ registry->RegisterDictionaryPref(proxy_config::prefs::kProxy,
+ std::move(default_settings));
+ registry->RegisterBooleanPref(proxy_config::prefs::kUseSharedProxies, false);
}
// static
@@ -257,14 +258,25 @@ ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::ReadPrefConfig(
ProxyPrefs::ConfigState PrefProxyConfigTrackerImpl::GetProxyConfig(
net::ProxyConfig* config) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (config_state_ != ProxyPrefs::CONFIG_UNSET)
+ if (pref_config_state_ != ProxyPrefs::CONFIG_UNSET)
*config = pref_config_;
- return config_state_;
+ return pref_config_state_;
}
void PrefProxyConfigTrackerImpl::OnProxyConfigChanged(
ProxyPrefs::ConfigState config_state,
const net::ProxyConfig& config) {
+ // If the configuration hasn't changed, do nothing.
+ if (active_config_state_ == config_state &&
+ (active_config_state_ == ProxyPrefs::CONFIG_UNSET ||
+ active_config_.Equals(config))) {
+ return;
+ }
+
+ active_config_state_ = config_state;
+ if (active_config_state_ != ProxyPrefs::CONFIG_UNSET)
+ active_config_ = config;
+
if (!proxy_config_service_impl_)
return;
io_task_runner_->PostTask(
@@ -339,11 +351,11 @@ void PrefProxyConfigTrackerImpl::OnProxyPrefChanged() {
net::ProxyConfig new_config;
ProxyPrefs::ConfigState config_state =
ReadPrefConfig(pref_service_, &new_config);
- if (config_state_ != config_state ||
- (config_state_ != ProxyPrefs::CONFIG_UNSET &&
+ if (pref_config_state_ != config_state ||
+ (pref_config_state_ != ProxyPrefs::CONFIG_UNSET &&
!pref_config_.Equals(new_config))) {
- config_state_ = config_state;
- if (config_state_ != ProxyPrefs::CONFIG_UNSET)
+ pref_config_state_ = config_state;
+ if (pref_config_state_ != ProxyPrefs::CONFIG_UNSET)
pref_config_ = new_config;
OnProxyConfigChanged(config_state, new_config);
}
« no previous file with comments | « components/proxy_config/pref_proxy_config_tracker_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698