Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ | 5 #ifndef REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ |
| 6 #define REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ | 6 #define REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "components/policy/core/common/policy_service.h" | |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
| 14 class TimeDelta; | 15 class TimeDelta; |
| 15 class WaitableEvent; | 16 class WaitableEvent; |
| 16 } // namespace base | 17 } // namespace base |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 namespace policy_hack { | 20 namespace policy_hack { |
| 20 | 21 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 32 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 32 virtual ~PolicyWatcher(); | 33 virtual ~PolicyWatcher(); |
| 33 | 34 |
| 34 // This guarantees that the |policy_callback| is called at least once with | 35 // This guarantees that the |policy_callback| is called at least once with |
| 35 // the current policies. After that, |policy_callback| will be called | 36 // the current policies. After that, |policy_callback| will be called |
| 36 // whenever a change to any policy is detected. It will then be called only | 37 // whenever a change to any policy is detected. It will then be called only |
| 37 // with the changed policies. | 38 // with the changed policies. |
| 38 virtual void StartWatching(const PolicyCallback& policy_callback); | 39 virtual void StartWatching(const PolicyCallback& policy_callback); |
| 39 | 40 |
| 40 // Should be called after StartWatching() before the object is deleted. Calls | 41 // Should be called after StartWatching() before the object is deleted. Calls |
| 41 // just wait for |done| to be signaled before deleting the object. | 42 // should wait for |stopped_callback| to be called before deleting it. |
| 42 virtual void StopWatching(base::WaitableEvent* done); | 43 virtual void StopWatching(const base::Closure& stopped_callback); |
| 43 | 44 |
| 44 // Implemented by each platform. This message loop should be an IO message | 45 // Implemented by each platform. This message loop of |task_runner| should be |
|
Wez
2014/10/24 23:29:27
"This message loop of" seems redundant
kelvinp
2014/10/29 01:22:52
Done.
| |
| 45 // loop. | 46 // an IO message loop. |policy_service| is currently only used on ChromeOS. |
|
Wez
2014/10/24 23:29:27
What is task_runner used for by the PolicyWatcher?
kelvinp
2014/10/29 01:22:52
Done.
| |
| 46 static PolicyWatcher* Create( | 47 // The caller must ensure that |policy_service| remains valid for the lifetime |
| 48 // of PolicyWatcherChromeOS. | |
| 49 static scoped_ptr<PolicyWatcher> Create( | |
| 50 policy::PolicyService* policy_service, | |
| 47 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 48 | 52 |
| 49 // The name of the NAT traversal policy. | 53 // The name of the NAT traversal policy. |
| 50 static const char kNatPolicyName[]; | 54 static const char kNatPolicyName[]; |
| 51 | 55 |
| 52 // The name of the policy for requiring 2-factor authentication. | 56 // The name of the policy for requiring 2-factor authentication. |
| 53 static const char kHostRequireTwoFactorPolicyName[]; | 57 static const char kHostRequireTwoFactorPolicyName[]; |
| 54 | 58 |
| 55 // The name of the host domain policy. | 59 // The name of the host domain policy. |
| 56 static const char kHostDomainPolicyName[]; | 60 static const char kHostDomainPolicyName[]; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 | 104 |
| 101 // Used for time-based reloads in case something goes wrong with the | 105 // Used for time-based reloads in case something goes wrong with the |
| 102 // notification system. | 106 // notification system. |
| 103 void ScheduleFallbackReloadTask(); | 107 void ScheduleFallbackReloadTask(); |
| 104 void ScheduleReloadTask(const base::TimeDelta& delay); | 108 void ScheduleReloadTask(const base::TimeDelta& delay); |
| 105 | 109 |
| 106 // Returns a DictionaryValue containing the default values for each policy. | 110 // Returns a DictionaryValue containing the default values for each policy. |
| 107 const base::DictionaryValue& Defaults() const; | 111 const base::DictionaryValue& Defaults() const; |
| 108 | 112 |
| 109 private: | 113 private: |
| 114 void StopWatchingOnPolicyWatcherThread(); | |
| 110 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 115 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 111 | 116 |
| 112 PolicyCallback policy_callback_; | 117 PolicyCallback policy_callback_; |
| 113 | 118 |
| 114 scoped_ptr<base::DictionaryValue> old_policies_; | 119 scoped_ptr<base::DictionaryValue> old_policies_; |
| 115 scoped_ptr<base::DictionaryValue> default_values_; | 120 scoped_ptr<base::DictionaryValue> default_values_; |
| 116 scoped_ptr<base::DictionaryValue> bad_type_values_; | 121 scoped_ptr<base::DictionaryValue> bad_type_values_; |
| 117 | 122 |
| 118 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. | 123 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. |
| 119 base::WeakPtrFactory<PolicyWatcher> weak_factory_; | 124 base::WeakPtrFactory<PolicyWatcher> weak_factory_; |
| 120 }; | 125 }; |
| 121 | 126 |
| 122 } // namespace policy_hack | 127 } // namespace policy_hack |
| 123 } // namespace remoting | 128 } // namespace remoting |
| 124 | 129 |
| 125 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ | 130 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ |
| OLD | NEW |