summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-31 01:12:03 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-31 01:12:03 +0000
commit5c2f0f2753645decbc85276a03d13ba225d4b5be (patch)
tree1a46fafa51bdc1a45b9a85406846823786be3bd4 /remoting/host
parent8b7420e06adefe6ac10de4c87a164d90f83db28c (diff)
downloadchromium_src-5c2f0f2753645decbc85276a03d13ba225d4b5be.zip
chromium_src-5c2f0f2753645decbc85276a03d13ba225d4b5be.tar.gz
chromium_src-5c2f0f2753645decbc85276a03d13ba225d4b5be.tar.bz2
[Chromoting] Stop the Linux policy watcher treating a failure to read policies
in the same way as reading the default values of all polices. BUG=155381 Review URL: https://chromiumcodereview.appspot.com/11338044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/policy_hack/policy_watcher_linux.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/remoting/host/policy_hack/policy_watcher_linux.cc b/remoting/host/policy_hack/policy_watcher_linux.cc
index 9d0e5ed..99de8b0 100644
--- a/remoting/host/policy_hack/policy_watcher_linux.cc
+++ b/remoting/host/policy_hack/policy_watcher_linux.cc
@@ -156,8 +156,8 @@ class PolicyWatcherLinux : public PolicyWatcher {
return last_modification;
}
- // Caller owns the value.
- DictionaryValue* Load() {
+ // Returns NULL if the policy dictionary couldn't be read.
+ scoped_ptr<DictionaryValue> Load() {
DCHECK(OnPolicyWatcherThread());
// Enumerate the files and sort them lexicographically.
std::set<FilePath> files;
@@ -168,7 +168,7 @@ class PolicyWatcherLinux : public PolicyWatcher {
files.insert(config_file_path);
// Start with an empty dictionary and merge the files' contents.
- DictionaryValue* policy = new DictionaryValue();
+ scoped_ptr<DictionaryValue> policy(new DictionaryValue());
for (std::set<FilePath>::iterator config_file_iter = files.begin();
config_file_iter != files.end(); ++config_file_iter) {
JSONFileValueSerializer deserializer(*config_file_iter);
@@ -180,17 +180,17 @@ class PolicyWatcherLinux : public PolicyWatcher {
if (!value.get()) {
LOG(WARNING) << "Failed to read configuration file "
<< config_file_iter->value() << ": " << error_msg;
- continue;
+ return scoped_ptr<DictionaryValue>();
}
if (!value->IsType(Value::TYPE_DICTIONARY)) {
LOG(WARNING) << "Expected JSON dictionary in configuration file "
<< config_file_iter->value();
- continue;
+ return scoped_ptr<DictionaryValue>();
}
policy->MergeDictionary(static_cast<DictionaryValue*>(value.get()));
}
- return policy;
+ return policy.Pass();
}
void Reload() {
@@ -210,10 +210,15 @@ class PolicyWatcherLinux : public PolicyWatcher {
}
// Load the policy definitions.
- scoped_ptr<DictionaryValue> new_policy(Load());
- UpdatePolicies(new_policy.get());
-
- ScheduleFallbackReloadTask();
+ scoped_ptr<DictionaryValue> new_policy = Load();
+ if (new_policy.get()) {
+ UpdatePolicies(new_policy.get());
+ ScheduleFallbackReloadTask();
+ } else {
+ // A failure to load policy definitions is probably temporary, so try
+ // again soon.
+ ScheduleReloadTask(base::TimeDelta::FromSeconds(kSettleIntervalSeconds));
+ }
}
bool IsSafeToReloadPolicy(const base::Time& now, base::TimeDelta* delay) {