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_SETUP_DAEMON_CONTROLLER_H_ | 5 #ifndef REMOTING_HOST_SETUP_DAEMON_CONTROLLER_H_ |
6 #define REMOTING_HOST_SETUP_DAEMON_CONTROLLER_H_ | 6 #define REMOTING_HOST_SETUP_DAEMON_CONTROLLER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 // Placeholder state for platforms on which the daemon process is not | 30 // Placeholder state for platforms on which the daemon process is not |
31 // implemented. The web-app will not show the corresponding UI. This value | 31 // implemented. The web-app will not show the corresponding UI. This value |
32 // will eventually be deprecated or removed. | 32 // will eventually be deprecated or removed. |
33 STATE_NOT_IMPLEMENTED = -1, | 33 STATE_NOT_IMPLEMENTED = -1, |
34 // The daemon is not installed. This is functionally equivalent to | 34 // The daemon is not installed. This is functionally equivalent to |
35 // STATE_STOPPED, but the start method is expected to be significantly | 35 // STATE_STOPPED, but the start method is expected to be significantly |
36 // slower, and might involve user interaction. It might be appropriate to | 36 // slower, and might involve user interaction. It might be appropriate to |
37 // indicate this in the UI. | 37 // indicate this in the UI. |
38 STATE_NOT_INSTALLED = 0, | 38 STATE_NOT_INSTALLED = 0, |
39 // The daemon is being installed. | 39 // The daemon is being installed. |
40 STATE_INSTALLING = 1, | 40 STATE_INSTALLING = 1, |
Sergey Ulanov
2015/01/29 19:00:32
These 3 states above can be removed now.
weitao
2015/01/29 23:50:57
How about I clean this up in a subsequent CL which
Sergey Ulanov
2015/01/29 23:58:39
sgtm
| |
41 // The daemon is installed but not running. Call Start to start it. | 41 // The daemon is installed but not running. Call Start to start it. |
42 STATE_STOPPED = 2, | 42 STATE_STOPPED = 2, |
43 // The daemon process is starting. | 43 // The daemon process is starting. |
44 STATE_STARTING = 3, | 44 STATE_STARTING = 3, |
45 // The daemon process is running. Call Start again to change the PIN or | 45 // The daemon process is running. Call Start again to change the PIN or |
46 // Stop to stop it. | 46 // Stop to stop it. |
47 STATE_STARTED = 4, | 47 STATE_STARTED = 4, |
48 // The daemon process is stopping. | 48 // The daemon process is stopping. |
49 STATE_STOPPING = 5, | 49 STATE_STOPPING = 5, |
50 // The state cannot be determined. This could indicate that the plugin | 50 // The state cannot be determined. This could indicate that the plugin |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 virtual ~Delegate() {} | 114 virtual ~Delegate() {} |
115 | 115 |
116 // Return the "installed/running" state of the daemon process. This method | 116 // Return the "installed/running" state of the daemon process. This method |
117 // should avoid accessing any data members of the implementation. | 117 // should avoid accessing any data members of the implementation. |
118 virtual State GetState() = 0; | 118 virtual State GetState() = 0; |
119 | 119 |
120 // Queries current host configuration. Any values that might be security | 120 // Queries current host configuration. Any values that might be security |
121 // sensitive have been filtered out. | 121 // sensitive have been filtered out. |
122 virtual scoped_ptr<base::DictionaryValue> GetConfig() = 0; | 122 virtual scoped_ptr<base::DictionaryValue> GetConfig() = 0; |
123 | 123 |
124 // Download and install the host component. |done| is invoked on the | |
125 // calling thread when the operation is completed. | |
126 virtual void InstallHost(const CompletionCallback& done) = 0; | |
127 | |
128 // Starts the daemon process. This may require that the daemon be | 124 // Starts the daemon process. This may require that the daemon be |
129 // downloaded and installed. |done| is invoked on the calling thread when | 125 // downloaded and installed. |done| is invoked on the calling thread when |
130 // the operation is completed. | 126 // the operation is completed. |
131 virtual void SetConfigAndStart( | 127 virtual void SetConfigAndStart( |
132 scoped_ptr<base::DictionaryValue> config, | 128 scoped_ptr<base::DictionaryValue> config, |
133 bool consent, | 129 bool consent, |
134 const CompletionCallback& done) = 0; | 130 const CompletionCallback& done) = 0; |
135 | 131 |
136 // Updates current host configuration with the values specified in | 132 // Updates current host configuration with the values specified in |
137 // |config|. Any value in the existing configuration that isn't specified in | 133 // |config|. Any value in the existing configuration that isn't specified in |
(...skipping 30 matching lines...) Expand all Loading... | |
168 // webapp. In most cases it requires IO operations, so it may block | 164 // webapp. In most cases it requires IO operations, so it may block |
169 // the user interface. Replace it with asynchronous notifications, | 165 // the user interface. Replace it with asynchronous notifications, |
170 // e.g. with StartStateNotifications()/StopStateNotifications() methods. | 166 // e.g. with StartStateNotifications()/StopStateNotifications() methods. |
171 State GetState(); | 167 State GetState(); |
172 | 168 |
173 // Queries current host configuration. The |done| is called | 169 // Queries current host configuration. The |done| is called |
174 // after the configuration is read, and any values that might be security | 170 // after the configuration is read, and any values that might be security |
175 // sensitive have been filtered out. | 171 // sensitive have been filtered out. |
176 void GetConfig(const GetConfigCallback& done); | 172 void GetConfig(const GetConfigCallback& done); |
177 | 173 |
178 // Download and install the host component. |done| is called when the | |
179 // operation is finished or fails. | |
180 void InstallHost(const CompletionCallback& done); | |
181 | |
182 // Start the daemon process. This may require that the daemon be | 174 // Start the daemon process. This may require that the daemon be |
183 // downloaded and installed. |done| is called when the | 175 // downloaded and installed. |done| is called when the |
184 // operation is finished or fails. | 176 // operation is finished or fails. |
185 // | 177 // |
186 // TODO(sergeyu): This method writes config and starts the host - | 178 // TODO(sergeyu): This method writes config and starts the host - |
187 // these two steps are merged for simplicity. Consider splitting it | 179 // these two steps are merged for simplicity. Consider splitting it |
188 // into SetConfig() and Start() once we have basic host setup flow | 180 // into SetConfig() and Start() once we have basic host setup flow |
189 // working. | 181 // working. |
190 void SetConfigAndStart(scoped_ptr<base::DictionaryValue> config, | 182 void SetConfigAndStart(scoped_ptr<base::DictionaryValue> config, |
191 bool consent, | 183 bool consent, |
(...skipping 25 matching lines...) Expand all Loading... | |
217 | 209 |
218 // Get the user's consent to crash reporting. | 210 // Get the user's consent to crash reporting. |
219 void GetUsageStatsConsent(const GetUsageStatsConsentCallback& done); | 211 void GetUsageStatsConsent(const GetUsageStatsConsentCallback& done); |
220 | 212 |
221 private: | 213 private: |
222 friend class base::RefCountedThreadSafe<DaemonController>; | 214 friend class base::RefCountedThreadSafe<DaemonController>; |
223 virtual ~DaemonController(); | 215 virtual ~DaemonController(); |
224 | 216 |
225 // Blocking helper methods used to call the delegate. | 217 // Blocking helper methods used to call the delegate. |
226 void DoGetConfig(const GetConfigCallback& done); | 218 void DoGetConfig(const GetConfigCallback& done); |
227 void DoInstallHost(const CompletionCallback& done); | |
228 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config, | 219 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config, |
229 bool consent, | 220 bool consent, |
230 const CompletionCallback& done); | 221 const CompletionCallback& done); |
231 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config, | 222 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config, |
232 const CompletionCallback& done); | 223 const CompletionCallback& done); |
233 void DoStop(const CompletionCallback& done); | 224 void DoStop(const CompletionCallback& done); |
234 void DoSetWindow(void* window_handle, const base::Closure& done); | 225 void DoSetWindow(void* window_handle, const base::Closure& done); |
235 void DoGetVersion(const GetVersionCallback& done); | 226 void DoGetVersion(const GetVersionCallback& done); |
236 void DoGetUsageStatsConsent(const GetUsageStatsConsentCallback& done); | 227 void DoGetUsageStatsConsent(const GetUsageStatsConsentCallback& done); |
237 | 228 |
(...skipping 30 matching lines...) Expand all Loading... | |
268 scoped_ptr<Delegate> delegate_; | 259 scoped_ptr<Delegate> delegate_; |
269 | 260 |
270 std::queue<base::Closure> pending_requests_; | 261 std::queue<base::Closure> pending_requests_; |
271 | 262 |
272 DISALLOW_COPY_AND_ASSIGN(DaemonController); | 263 DISALLOW_COPY_AND_ASSIGN(DaemonController); |
273 }; | 264 }; |
274 | 265 |
275 } // namespace remoting | 266 } // namespace remoting |
276 | 267 |
277 #endif // REMOTING_HOST_SETUP_DAEMON_CONTROLLER_H_ | 268 #endif // REMOTING_HOST_SETUP_DAEMON_CONTROLLER_H_ |
OLD | NEW |