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 829eac71e085239f974a3e3739654b2680a1d991..b99157760502aa2c38a7e343b9e52d56b5a49716 100644 |
| --- a/remoting/host/policy_hack/policy_watcher.h |
| +++ b/remoting/host/policy_hack/policy_watcher.h |
| @@ -9,6 +9,7 @@ |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/threading/non_thread_safe.h" |
| #include "components/policy/core/common/policy_service.h" |
| namespace base { |
| @@ -25,11 +26,9 @@ class SchemaRegistry; |
| namespace remoting { |
| namespace policy_hack { |
| -// Watches for changes to the managed remote access host policies. If |
| -// StartWatching() has been called, then before this object can be deleted, |
| -// StopWatching() has to be completed (the provided |done| event must be |
| -// signaled). |
| -class PolicyWatcher : public policy::PolicyService::Observer { |
| +// Watches for changes to the managed remote access host policies. |
| +class PolicyWatcher : public policy::PolicyService::Observer, |
| + public base::NonThreadSafe { |
| public: |
| // Called first with all policies, and subsequently with any changed policies. |
| typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> |
| @@ -61,35 +60,28 @@ class PolicyWatcher : public policy::PolicyService::Observer { |
| // for policy changes and will call |policy_updated_callback| when the error |
| // is recovered from and may call |policy_error_callback| when new errors are |
| // found. |
| - // |
| - // See |Create| method's description for comments about which thread will |
| - // be used to run the callbacks. |
| virtual void StartWatching( |
| const PolicyUpdatedCallback& policy_updated_callback, |
| const PolicyErrorCallback& policy_error_callback); |
| - // Should be called after StartWatching() before the object is deleted. Calls |
| - // should wait for |stopped_callback| to be called before deleting it. |
| - virtual void StopWatching(const base::Closure& stopped_callback); |
| - |
| // Specify a |policy_service| to borrow (on Chrome OS, from the browser |
| // process) or specify nullptr to internally construct and use a new |
| - // PolicyService (on other OS-es). |
| + // PolicyService (on other OS-es). PolicyWatcher must be used on th thread on |
|
Łukasz Anforowicz
2015/01/30 19:50:59
nit: typo ("th thread")
Sergey Ulanov
2015/01/30 20:06:07
Done.
|
| + // which it is created. |policy_service| is called on the same thread. |
| // |
| - // When |policy_service| is null, then |task_runner| is used for reading the |
| - // policy from files / registry / preferences. PolicyUpdatedCallback and |
| - // PolicyErrorCallback will be called on the same |task_runner|. |
| - // |task_runner| should be of TYPE_IO type. |
| + // When |policy_service| is null, then |file_task_runner| is used for reading |
| + // the policy from files / registry / preferences (which are blocking |
| + // operations). |file_task_runner| should be of TYPE_IO type. |
| // |
| - // When |policy_service| is specified then |task_runner| argument is ignored |
| - // and 1) BrowserThread::UI is used for PolicyUpdatedCallback and |
| + // When |policy_service| is specified then |file_task_runner| argument is |
| + // ignored and 1) BrowserThread::UI is used for PolicyUpdatedCallback and |
| // PolicyErrorCallback and 2) BrowserThread::FILE is used for reading the |
| // policy from files / registry / preferences (although (2) is just an |
| // implementation detail and should likely be ignored outside of |
| // PolicyWatcher). |
| static scoped_ptr<PolicyWatcher> Create( |
| policy::PolicyService* policy_service, |
| - const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| + const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); |
| private: |
| friend class PolicyWatcherTest; |
| @@ -114,8 +106,6 @@ class PolicyWatcher : public policy::PolicyService::Observer { |
| // to call |policy_service_| methods and where we expect to get callbacks |
| // from |policy_service_|. |
| PolicyWatcher( |
| - const scoped_refptr<base::SingleThreadTaskRunner>& |
| - policy_service_task_runner, |
| policy::PolicyService* policy_service, |
| scoped_ptr<policy::PolicyService> owned_policy_service, |
| scoped_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider, |
| @@ -127,8 +117,6 @@ class PolicyWatcher : public policy::PolicyService::Observer { |
| // |policy_service_task_runner| is passed through to the constructor of |
| // PolicyWatcher. |
| static scoped_ptr<PolicyWatcher> CreateFromPolicyLoader( |
| - const scoped_refptr<base::SingleThreadTaskRunner>& |
| - policy_service_task_runner, |
| scoped_ptr<policy::AsyncPolicyLoader> async_policy_loader); |
| // PolicyService::Observer interface. |
| @@ -137,10 +125,6 @@ class PolicyWatcher : public policy::PolicyService::Observer { |
| const policy::PolicyMap& current) override; |
| void OnPolicyServiceInitialized(policy::PolicyDomain domain) override; |
| - void StopWatchingOnPolicyServiceThread(); |
| - |
| - scoped_refptr<base::SingleThreadTaskRunner> policy_service_task_runner_; |
| - |
| PolicyUpdatedCallback policy_updated_callback_; |
| PolicyErrorCallback policy_error_callback_; |
| int transient_policy_error_retry_counter_; |