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_DAEMON_CONTROLLER_H_ | 5 #ifndef REMOTING_HOST_DAEMON_CONTROLLER_H_ |
6 #define REMOTING_HOST_DAEMON_CONTROLLER_H_ | 6 #define REMOTING_HOST_DAEMON_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 typedef base::Callback<void (scoped_ptr<base::DictionaryValue> config)> | 72 typedef base::Callback<void (scoped_ptr<base::DictionaryValue> config)> |
73 GetConfigCallback; | 73 GetConfigCallback; |
74 | 74 |
75 // Callback used for asynchronous operations, e.g. when | 75 // Callback used for asynchronous operations, e.g. when |
76 // starting/stopping the service. | 76 // starting/stopping the service. |
77 typedef base::Callback<void (AsyncResult result)> CompletionCallback; | 77 typedef base::Callback<void (AsyncResult result)> CompletionCallback; |
78 | 78 |
79 // Callback type for GetVersion(). | 79 // Callback type for GetVersion(). |
80 typedef base::Callback<void (const std::string&)> GetVersionCallback; | 80 typedef base::Callback<void (const std::string&)> GetVersionCallback; |
81 | 81 |
| 82 // Callback type for GetUsageStatsConsent(). |supported| indicates whether |
| 83 // crash dump reporting is supported by the host. |allowed| indicates if |
| 84 // crash dump reporting is allowed by the user. |set_by_policy| carries |
| 85 // information whether the crash dump reporting is controlled by policy. |
| 86 typedef base::Callback<void ( |
| 87 bool supported, |
| 88 bool allowed, |
| 89 bool set_by_policy)> GetUsageStatsConsentCallback; |
| 90 |
82 virtual ~DaemonController() {} | 91 virtual ~DaemonController() {} |
83 | 92 |
84 // Return the "installed/running" state of the daemon process. | 93 // Return the "installed/running" state of the daemon process. |
85 // | 94 // |
86 // TODO(sergeyu): This method is called synchronously from the | 95 // TODO(sergeyu): This method is called synchronously from the |
87 // webapp. In most cases it requires IO operations, so it may block | 96 // webapp. In most cases it requires IO operations, so it may block |
88 // the user interface. Replace it with asynchronous notifications, | 97 // the user interface. Replace it with asynchronous notifications, |
89 // e.g. with StartStateNotifications()/StopStateNotifications() methods. | 98 // e.g. with StartStateNotifications()/StopStateNotifications() methods. |
90 virtual State GetState() = 0; | 99 virtual State GetState() = 0; |
91 | 100 |
92 // Queries current host configuration. The |callback| is called | 101 // Queries current host configuration. The |callback| is called |
93 // after the configuration is read, and any values that might be security | 102 // after the configuration is read, and any values that might be security |
94 // sensitive have been filtered out. | 103 // sensitive have been filtered out. |
95 virtual void GetConfig(const GetConfigCallback& callback) = 0; | 104 virtual void GetConfig(const GetConfigCallback& callback) = 0; |
96 | 105 |
97 // Start the daemon process. This may require that the daemon be | 106 // Start the daemon process. This may require that the daemon be |
98 // downloaded and installed. |done_callback| is called when the | 107 // downloaded and installed. |done_callback| is called when the |
99 // operation is finished or fails. | 108 // operation is finished or fails. |
100 // | 109 // |
101 // TODO(sergeyu): This method writes config and starts the host - | 110 // TODO(sergeyu): This method writes config and starts the host - |
102 // these two steps are merged for simplicity. Consider splitting it | 111 // these two steps are merged for simplicity. Consider splitting it |
103 // into SetConfig() and Start() once we have basic host setup flow | 112 // into SetConfig() and Start() once we have basic host setup flow |
104 // working. | 113 // working. |
105 virtual void SetConfigAndStart(scoped_ptr<base::DictionaryValue> config, | 114 virtual void SetConfigAndStart(scoped_ptr<base::DictionaryValue> config, |
106 const CompletionCallback& done_callback) = 0; | 115 bool consent, |
| 116 const CompletionCallback& done) = 0; |
107 | 117 |
108 // Updates current host configuration with the values specified in | 118 // Updates current host configuration with the values specified in |
109 // |config|. Changes must take effect before the call completes. | 119 // |config|. Changes must take effect before the call completes. |
110 // Any value in the existing configuration that isn't specified in |config| | 120 // Any value in the existing configuration that isn't specified in |config| |
111 // is preserved. |config| must not contain host_id or xmpp_login values, | 121 // is preserved. |config| must not contain host_id or xmpp_login values, |
112 // because implementations of this method cannot change them. | 122 // because implementations of this method cannot change them. |
113 virtual void UpdateConfig(scoped_ptr<base::DictionaryValue> config, | 123 virtual void UpdateConfig(scoped_ptr<base::DictionaryValue> config, |
114 const CompletionCallback& done_callback) = 0; | 124 const CompletionCallback& done_callback) = 0; |
115 | 125 |
116 // Stop the daemon process. It is permitted to call Stop while the daemon | 126 // Stop the daemon process. It is permitted to call Stop while the daemon |
117 // process is being installed, in which case the installation should be | 127 // process is being installed, in which case the installation should be |
118 // aborted if possible; if not then it is sufficient to ensure that the | 128 // aborted if possible; if not then it is sufficient to ensure that the |
119 // daemon process is not started automatically upon successful installation. | 129 // daemon process is not started automatically upon successful installation. |
120 // As with Start, Stop may return before the operation is complete--poll | 130 // As with Start, Stop may return before the operation is complete--poll |
121 // GetState until the state is STATE_STOPPED. | 131 // GetState until the state is STATE_STOPPED. |
122 virtual void Stop(const CompletionCallback& done_callback) = 0; | 132 virtual void Stop(const CompletionCallback& done_callback) = 0; |
123 | 133 |
124 // Caches the native handle of the plugin window so it can be used to focus | 134 // Caches the native handle of the plugin window so it can be used to focus |
125 // elevation prompts properly. | 135 // elevation prompts properly. |
126 virtual void SetWindow(void* window_handle) = 0; | 136 virtual void SetWindow(void* window_handle) = 0; |
127 | 137 |
128 // Get the version of the daemon as a dotted decimal string of the form | 138 // Get the version of the daemon as a dotted decimal string of the form |
129 // major.minor.build.patch, if it is installed, or "" otherwise. | 139 // major.minor.build.patch, if it is installed, or "" otherwise. |
130 virtual void GetVersion(const GetVersionCallback& done_callback) = 0; | 140 virtual void GetVersion(const GetVersionCallback& done_callback) = 0; |
131 | 141 |
| 142 // Get the user's consent to crash reporting. |
| 143 virtual void GetUsageStatsConsent( |
| 144 const GetUsageStatsConsentCallback& done) = 0; |
| 145 |
132 static scoped_ptr<DaemonController> Create(); | 146 static scoped_ptr<DaemonController> Create(); |
133 }; | 147 }; |
134 | 148 |
135 } // namespace remoting | 149 } // namespace remoting |
136 | 150 |
137 #endif // REMOTING_HOST_DAEMON_CONTROLLER_H_ | 151 #endif // REMOTING_HOST_DAEMON_CONTROLLER_H_ |
OLD | NEW |