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 |task_runner| should be an IO message |
Wez
2014/10/29 18:27:51
Remove "This" - it doesn't make sense grammaticall
kelvinp
2014/10/29 22:20:17
Done.
| |
45 // loop. | 46 // loop. The policy watcher re-posts any calls to its public interface on the |
46 static PolicyWatcher* Create( | 47 // |task_runner| so it can be called from any thread. |policy_service| is |
Wez
2014/10/29 18:27:51
This isn't true under ChromeOS, though. Is it even
Wez
2014/10/29 18:27:51
It's also the task runner on which the watcher wil
kelvinp
2014/10/29 22:20:17
To be honest, I don't know the historical context
Wez
2014/10/30 01:08:59
Acknowledged.
| |
48 // currently only used on ChromeOS. The caller must ensure that | |
49 // |policy_service| remains valid for the lifetime of PolicyWatcherChromeOS. | |
Wez
2014/10/29 18:27:51
The caller does not see PolicyWatcherChromeOS - it
Wez
2014/10/29 18:27:51
This would be cleaner with separate CrOS and non-C
kelvinp
2014/10/29 22:20:17
Totally, but that would also introduce ifdef's on
kelvinp
2014/10/29 22:20:17
Done.
Wez
2014/10/30 01:08:59
Acknowledged.
| |
50 static scoped_ptr<PolicyWatcher> Create( | |
51 policy::PolicyService* policy_service, | |
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 52 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
48 | 53 |
49 // The name of the NAT traversal policy. | 54 // The name of the NAT traversal policy. |
50 static const char kNatPolicyName[]; | 55 static const char kNatPolicyName[]; |
51 | 56 |
52 // The name of the policy for requiring 2-factor authentication. | 57 // The name of the policy for requiring 2-factor authentication. |
53 static const char kHostRequireTwoFactorPolicyName[]; | 58 static const char kHostRequireTwoFactorPolicyName[]; |
54 | 59 |
55 // The name of the host domain policy. | 60 // The name of the host domain policy. |
56 static const char kHostDomainPolicyName[]; | 61 static const char kHostDomainPolicyName[]; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 | 105 |
101 // Used for time-based reloads in case something goes wrong with the | 106 // Used for time-based reloads in case something goes wrong with the |
102 // notification system. | 107 // notification system. |
103 void ScheduleFallbackReloadTask(); | 108 void ScheduleFallbackReloadTask(); |
104 void ScheduleReloadTask(const base::TimeDelta& delay); | 109 void ScheduleReloadTask(const base::TimeDelta& delay); |
105 | 110 |
106 // Returns a DictionaryValue containing the default values for each policy. | 111 // Returns a DictionaryValue containing the default values for each policy. |
107 const base::DictionaryValue& Defaults() const; | 112 const base::DictionaryValue& Defaults() const; |
108 | 113 |
109 private: | 114 private: |
115 void StopWatchingOnPolicyWatcherThread(); | |
110 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 116 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
111 | 117 |
112 PolicyCallback policy_callback_; | 118 PolicyCallback policy_callback_; |
113 | 119 |
114 scoped_ptr<base::DictionaryValue> old_policies_; | 120 scoped_ptr<base::DictionaryValue> old_policies_; |
115 scoped_ptr<base::DictionaryValue> default_values_; | 121 scoped_ptr<base::DictionaryValue> default_values_; |
116 scoped_ptr<base::DictionaryValue> bad_type_values_; | 122 scoped_ptr<base::DictionaryValue> bad_type_values_; |
117 | 123 |
118 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. | 124 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. |
119 base::WeakPtrFactory<PolicyWatcher> weak_factory_; | 125 base::WeakPtrFactory<PolicyWatcher> weak_factory_; |
120 }; | 126 }; |
121 | 127 |
122 } // namespace policy_hack | 128 } // namespace policy_hack |
123 } // namespace remoting | 129 } // namespace remoting |
124 | 130 |
125 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ | 131 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ |
OLD | NEW |