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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Signals policy error to the registered |PolicyErrorCallback|. | 108 // Signals policy error to the registered |PolicyErrorCallback|. |
109 void SignalPolicyError(); | 109 void SignalPolicyError(); |
110 | 110 |
111 // Called whenever a transient error occurs during reading of policy files. | 111 // Called whenever a transient error occurs during reading of policy files. |
112 // This will increment a counter, and will trigger a call to | 112 // This will increment a counter, and will trigger a call to |
113 // SignalPolicyError() only after a threshold count is reached. | 113 // SignalPolicyError() only after a threshold count is reached. |
114 // The counter is reset whenever policy has been successfully read. | 114 // The counter is reset whenever policy has been successfully read. |
115 void SignalTransientPolicyError(); | 115 void SignalTransientPolicyError(); |
116 | 116 |
| 117 friend class PolicyWatcherTest; |
| 118 |
117 // Returns a DictionaryValue containing the default values for each policy. | 119 // Returns a DictionaryValue containing the default values for each policy. |
118 const base::DictionaryValue& Defaults() const; | 120 const base::DictionaryValue& Defaults() const; |
119 | 121 |
120 private: | 122 private: |
121 void StopWatchingOnPolicyWatcherThread(); | 123 void StopWatchingOnPolicyWatcherThread(); |
122 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 124 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
123 | 125 |
124 PolicyUpdatedCallback policy_updated_callback_; | 126 PolicyUpdatedCallback policy_updated_callback_; |
125 PolicyErrorCallback policy_error_callback_; | 127 PolicyErrorCallback policy_error_callback_; |
126 int transient_policy_error_retry_counter_; | 128 int transient_policy_error_retry_counter_; |
127 | 129 |
128 scoped_ptr<base::DictionaryValue> old_policies_; | 130 scoped_ptr<base::DictionaryValue> old_policies_; |
129 scoped_ptr<base::DictionaryValue> default_values_; | 131 scoped_ptr<base::DictionaryValue> default_values_; |
130 scoped_ptr<base::DictionaryValue> bad_type_values_; | 132 scoped_ptr<base::DictionaryValue> bad_type_values_; |
131 | 133 |
132 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. | 134 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. |
133 base::WeakPtrFactory<PolicyWatcher> weak_factory_; | 135 base::WeakPtrFactory<PolicyWatcher> weak_factory_; |
134 }; | 136 }; |
135 | 137 |
136 } // namespace policy_hack | 138 } // namespace policy_hack |
137 } // namespace remoting | 139 } // namespace remoting |
138 | 140 |
139 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ | 141 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ |
OLD | NEW |