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

Unified Diff: chrome/browser/chromeos/proxy_config_service_impl.cc

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT and removed some debug output left. Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/proxy_config_service_impl.cc
diff --git a/chrome/browser/chromeos/proxy_config_service_impl.cc b/chrome/browser/chromeos/proxy_config_service_impl.cc
index 38aca01f2dd3fa0833e1f652cf0929fd4643dec2..468503776f5e6f5cbc8da0e8747ab54fc37cb7b0 100644
--- a/chrome/browser/chromeos/proxy_config_service_impl.cc
+++ b/chrome/browser/chromeos/proxy_config_service_impl.cc
@@ -6,10 +6,12 @@
#include <ostream>
+#include "base/bind.h"
#include "base/json/json_value_serializer.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros_settings.h"
#include "chrome/browser/chromeos/cros_settings_names.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/policy/proto/chrome_device_policy.pb.h"
@@ -352,7 +354,8 @@ void ProxyConfigServiceImpl::ProxyConfig::EncodeAndAppendProxyServer(
ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* pref_service)
: PrefProxyConfigTrackerImpl(pref_service),
- active_config_state_(ProxyPrefs::CONFIG_UNSET) {
+ active_config_state_(ProxyPrefs::CONFIG_UNSET),
+ pointer_factory_(this) {
// Register for notification when user logs in, so that we can activate the
// new proxy config.
@@ -363,16 +366,11 @@ ProxyConfigServiceImpl::ProxyConfigServiceImpl(PrefService* pref_service)
if (pref_service->FindPreference(prefs::kUseSharedProxies))
use_shared_proxies_.Init(prefs::kUseSharedProxies, pref_service, this);
- // Start async fetch of proxy config from settings persisted on device.
- if (CrosLibrary::Get()->libcros_loaded()) {
- retrieve_property_op_ = SignedSettings::CreateRetrievePropertyOp(
- kSettingProxyEverywhere, this);
- if (retrieve_property_op_) {
- retrieve_property_op_->Execute();
- VLOG(1) << this << ": Start retrieving proxy setting from device";
- } else {
- VLOG(1) << this << ": Fail to retrieve proxy setting from device";
- }
+ if (CrosSettings::Get()->GetTrusted(
+ kSettingProxyEverywhere,
+ base::Bind(&ProxyConfigServiceImpl::FetchProxyPolicy,
+ pointer_factory_.GetWeakPtr()))) {
+ FetchProxyPolicy();
}
// Register for flimflam network notifications.
@@ -524,32 +522,6 @@ void ProxyConfigServiceImpl::OnProxyConfigChanged(
DetermineEffectiveConfig(network, true);
}
-void ProxyConfigServiceImpl::OnSettingsOpCompleted(
- SignedSettings::ReturnCode code,
- const base::Value* value) {
- retrieve_property_op_ = NULL;
- if (code != SignedSettings::SUCCESS) {
- LOG(WARNING) << this << ": Error retrieving proxy setting from device";
- device_config_.clear();
- return;
- }
- std::string policy_value;
- value->GetAsString(&policy_value);
- VLOG(1) << "Retrieved proxy setting from device, value=["
- << policy_value << "]";
- ProxyConfig device_config;
- if (!device_config.DeserializeForDevice(policy_value) ||
- !device_config.SerializeForNetwork(&device_config_)) {
- LOG(WARNING) << "Can't deserialize device setting or serialize for network";
- device_config_.clear();
- return;
- }
- if (!active_network_.empty()) {
- VLOG(1) << this << ": try migrating device config to " << active_network_;
- SetProxyConfigForNetwork(active_network_, device_config_, true);
- }
-}
-
void ProxyConfigServiceImpl::OnNetworkManagerChanged(
NetworkLibrary* network_lib) {
VLOG(1) << this << " OnNetworkManagerChanged: use-shared-proxies="
@@ -819,4 +791,30 @@ void ProxyConfigServiceImpl::ResetUICache() {
current_ui_config_ = ProxyConfig();
}
+void ProxyConfigServiceImpl::FetchProxyPolicy() {
+ // We assume ownership here to make sure this gets deleted no matter where
+ // this function ends.
Mattias Nissler (ping if slow) 2011/11/30 12:25:50 ?
pastarmovj 2011/11/30 17:21:16 Dead comment :)
+ std::string policy_value = "";
+ if (!CrosSettings::Get()->GetString(kSettingProxyEverywhere,
+ &policy_value)) {
+ LOG(WARNING) << this << ": Error retrieving proxy setting from device";
+ device_config_.clear();
+ return;
+ }
+
+ VLOG(1) << "Retrieved proxy setting from device, value=["
+ << policy_value << "]";
+ ProxyConfig device_config;
+ if (!device_config.DeserializeForDevice(policy_value) ||
+ !device_config.SerializeForNetwork(&device_config_)) {
+ LOG(WARNING) << "Can't deserialize device setting or serialize for network";
+ device_config_.clear();
+ return;
+ }
+ if (!active_network_.empty()) {
+ VLOG(1) << this << ": try migrating device config to " << active_network_;
+ SetProxyConfigForNetwork(active_network_, device_config_, true);
+ }
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698