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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 virtual void StopWatching(base::WaitableEvent* done); | 42 virtual void StopWatching(base::WaitableEvent* done); |
43 | 43 |
44 // Implemented by each platform. This message loop should be an IO message | 44 // Implemented by each platform. This message loop should be an IO message |
45 // loop. | 45 // loop. |
46 static PolicyWatcher* Create( | 46 static PolicyWatcher* Create( |
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 47 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
48 | 48 |
49 // The name of the NAT traversal policy. | 49 // The name of the NAT traversal policy. |
50 static const char kNatPolicyName[]; | 50 static const char kNatPolicyName[]; |
51 | 51 |
| 52 // The name of the host domain policy. |
| 53 static const char kHostDomainPolicyName[]; |
| 54 |
52 protected: | 55 protected: |
53 virtual void StartWatchingInternal() = 0; | 56 virtual void StartWatchingInternal() = 0; |
54 virtual void StopWatchingInternal() = 0; | 57 virtual void StopWatchingInternal() = 0; |
55 virtual void Reload() = 0; | 58 virtual void Reload() = 0; |
56 | 59 |
57 // Used to check if the class is on the right thread. | 60 // Used to check if the class is on the right thread. |
58 bool OnPolicyWatcherThread() const; | 61 bool OnPolicyWatcherThread() const; |
59 | 62 |
60 // Takes the policy dictionary from the OS specific store and extracts the | 63 // Takes the policy dictionary from the OS specific store and extracts the |
61 // relevant policies. | 64 // relevant policies. |
62 void UpdatePolicies(const base::DictionaryValue* new_policy); | 65 void UpdatePolicies(const base::DictionaryValue* new_policy); |
63 | 66 |
64 // Used for time-based reloads in case something goes wrong with the | 67 // Used for time-based reloads in case something goes wrong with the |
65 // notification system. | 68 // notification system. |
66 void ScheduleFallbackReloadTask(); | 69 void ScheduleFallbackReloadTask(); |
67 void ScheduleReloadTask(const base::TimeDelta& delay); | 70 void ScheduleReloadTask(const base::TimeDelta& delay); |
68 | 71 |
69 // The names of policies with boolean values. | 72 // The names of policies with boolean values. |
70 static const char* const kBooleanPolicyNames[]; | 73 static const char* const kBooleanPolicyNames[]; |
71 static const int kBooleanPolicyNamesNum; | 74 static const int kBooleanPolicyNamesNum; |
72 | 75 |
| 76 // The names of policies with string values. |
| 77 static const char* const kStringPolicyNames[]; |
| 78 static const int kStringPolicyNamesNum; |
| 79 |
73 private: | 80 private: |
74 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 81 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
75 | 82 |
76 PolicyCallback policy_callback_; | 83 PolicyCallback policy_callback_; |
77 | 84 |
78 scoped_ptr<base::DictionaryValue> old_policies_; | 85 scoped_ptr<base::DictionaryValue> old_policies_; |
79 | 86 |
80 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. | 87 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. |
81 base::WeakPtrFactory<PolicyWatcher> weak_factory_; | 88 base::WeakPtrFactory<PolicyWatcher> weak_factory_; |
82 }; | 89 }; |
83 | 90 |
84 } // namespace policy_hack | 91 } // namespace policy_hack |
85 } // namespace remoting | 92 } // namespace remoting |
86 | 93 |
87 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ | 94 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ |
OLD | NEW |