Chromium Code Reviews| Index: remoting/host/policy_hack/policy_watcher.h |
| diff --git a/remoting/host/policy_hack/policy_watcher.h b/remoting/host/policy_hack/policy_watcher.h |
| index 0ced8f23a4a7c55437e8fb0566dbb359a8c8adef..95df1ee08418a6a926af9513dc6d710e417fc5c1 100644 |
| --- a/remoting/host/policy_hack/policy_watcher.h |
| +++ b/remoting/host/policy_hack/policy_watcher.h |
| @@ -25,17 +25,27 @@ class PolicyWatcher { |
| public: |
| // Called first with all policies, and subsequently with any changed policies. |
| typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> |
| - PolicyCallback; |
| + PolicyUpdatedCallback; |
| + |
| + // Called after detecting malformed policies |
|
Lambros
2014/11/13 00:30:27
nit: Period.
Łukasz Anforowicz
2014/11/13 17:48:08
Done.
|
| + typedef base::Callback<void()> |
| + PolicyErrorCallback; |
|
Lambros
2014/11/13 00:30:27
nit: Fits on one line.
Łukasz Anforowicz
2014/11/13 17:48:08
Done.
|
| explicit PolicyWatcher( |
| scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| virtual ~PolicyWatcher(); |
| - // This guarantees that the |policy_callback| is called at least once with |
| - // the current policies. After that, |policy_callback| will be called |
| - // whenever a change to any policy is detected. It will then be called only |
| - // with the changed policies. |
| - virtual void StartWatching(const PolicyCallback& policy_callback); |
| + // This guarantees that the |policy_updated_callback| is called at least once |
| + // with the current policies. After that, |policy_updated_callback| will be |
| + // called whenever a change to any policy is detected. It will then be called |
| + // only with the changed policies. |
| + // |policy_error_callback| will be called when malformed policies are detected |
| + // (i.e. wrong type of policy value, or unparseable files under |
| + // /etc/opt/chrome/policies/managed) and indicates that we need to shut down |
| + // to avoid the risk of running with incorrectly formulated policies. |
| + virtual void StartWatching( |
| + const PolicyUpdatedCallback& policy_updated_callback, |
| + const PolicyErrorCallback& policy_error_callback); |
| // Should be called after StartWatching() before the object is deleted. Calls |
| // just wait for |done| to be signaled before deleting the object. |
| @@ -98,6 +108,14 @@ class PolicyWatcher { |
| // relevant policies. |
| void UpdatePolicies(const base::DictionaryValue* new_policy); |
| + // Signals policy error to whoever is watching this policy watcher |
|
Lambros
2014/11/13 00:30:27
s/whoever is watching this policy watcher/the regi
Łukasz Anforowicz
2014/11/13 17:48:08
Done.
|
| + void SignalPolicyError(); |
| + |
| + // Notes a transient policy error which shouldn't be reported |
|
Lambros
2014/11/13 00:30:27
I think I would document more fully what is going
Łukasz Anforowicz
2014/11/13 17:48:08
Done.
|
| + // to users of this PolicyWatcher unless |
| + // |transient_policy_error_retry_counter_| has reached a threshold. |
| + void SignalTransientPolicyError(); |
| + |
| // Used for time-based reloads in case something goes wrong with the |
| // notification system. |
| void ScheduleFallbackReloadTask(); |
| @@ -109,7 +127,9 @@ class PolicyWatcher { |
| private: |
| scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| - PolicyCallback policy_callback_; |
| + PolicyUpdatedCallback policy_updated_callback_; |
| + PolicyErrorCallback policy_error_callback_; |
| + int transient_policy_error_retry_counter_; |
| scoped_ptr<base::DictionaryValue> old_policies_; |
| scoped_ptr<base::DictionaryValue> default_values_; |