OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMOTING_HOST_H_ | 5 #ifndef REMOTING_CHROMOTING_HOST_H_ |
6 #define REMOTING_CHROMOTING_HOST_H_ | 6 #define REMOTING_CHROMOTING_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 | 156 |
157 // Takes ownership of |access_verifier|, and adds a reference to | 157 // Takes ownership of |access_verifier|, and adds a reference to |
158 // |config|. Caller keeps ownership of |context| and |environment|. | 158 // |config|. Caller keeps ownership of |context| and |environment|. |
159 ChromotingHost(ChromotingHostContext* context, | 159 ChromotingHost(ChromotingHostContext* context, |
160 MutableHostConfig* config, | 160 MutableHostConfig* config, |
161 DesktopEnvironment* environment, | 161 DesktopEnvironment* environment, |
162 AccessVerifier* access_verifier, | 162 AccessVerifier* access_verifier, |
163 bool allow_nat_traversal); | 163 bool allow_nat_traversal); |
164 virtual ~ChromotingHost(); | 164 virtual ~ChromotingHost(); |
165 | 165 |
166 // This method is called if a client is disconnected from the host. | |
167 void OnClientDisconnected(ClientSession* client); | |
168 | |
169 // Creates encoder for the specified configuration. | 166 // Creates encoder for the specified configuration. |
170 Encoder* CreateEncoder(const protocol::SessionConfig& config); | 167 Encoder* CreateEncoder(const protocol::SessionConfig& config); |
171 | 168 |
172 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 169 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
173 | 170 |
174 void AddAuthenticatedClient(ClientSession* client, | 171 void AddAuthenticatedClient(ClientSession* client, |
175 const protocol::SessionConfig& config, | 172 const protocol::SessionConfig& config, |
176 const std::string& jid); | 173 const std::string& jid); |
177 | 174 |
178 int AuthenticatedClientsCount() const; | 175 int AuthenticatedClientsCount() const; |
179 | 176 |
180 void EnableCurtainMode(bool enable); | 177 void EnableCurtainMode(bool enable); |
181 | 178 |
182 void StopScreenRecorder(); | 179 void StopScreenRecorder(); |
183 void OnScreenRecorderStopped(); | 180 void OnScreenRecorderStopped(); |
184 | 181 |
185 // The following methods are called during shutdown. | 182 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. |
186 void ShutdownNetwork(); | |
187 void ShutdownRecorder(); | |
188 void ShutdownFinish(); | 183 void ShutdownFinish(); |
189 | 184 |
185 // Unless specified otherwise all members of this class must be | |
186 // used on the network thread only. | |
187 | |
190 // Parameters specified when the host was created. | 188 // Parameters specified when the host was created. |
191 ChromotingHostContext* context_; | 189 ChromotingHostContext* context_; |
192 DesktopEnvironment* desktop_environment_; | 190 DesktopEnvironment* desktop_environment_; |
193 scoped_refptr<MutableHostConfig> config_; | 191 scoped_refptr<MutableHostConfig> config_; |
194 scoped_ptr<AccessVerifier> access_verifier_; | 192 scoped_ptr<AccessVerifier> access_verifier_; |
195 bool allow_nat_traversal_; | 193 bool allow_nat_traversal_; |
196 | 194 |
197 // Connection objects. | 195 // Connection objects. |
198 scoped_ptr<SignalStrategy> signal_strategy_; | 196 scoped_ptr<SignalStrategy> signal_strategy_; |
199 std::string local_jid_; | 197 std::string local_jid_; |
200 scoped_ptr<protocol::SessionManager> session_manager_; | 198 scoped_ptr<protocol::SessionManager> session_manager_; |
201 | 199 |
200 // StatusObserverList is thread-safe and can be used on any thread. | |
202 StatusObserverList status_observers_; | 201 StatusObserverList status_observers_; |
203 | 202 |
204 // The connections to remote clients. | 203 // The connections to remote clients. |
205 ClientList clients_; | 204 ClientList clients_; |
206 | 205 |
207 // Session manager for the host process. | 206 // Session manager for the host process. |
208 scoped_refptr<ScreenRecorder> recorder_; | 207 scoped_refptr<ScreenRecorder> recorder_; |
209 | 208 |
210 // Tracks the internal state of the host. | |
211 // This variable is written on the main thread of ChromotingHostContext | |
212 // and read by jingle thread. | |
213 State state_; | |
214 | |
215 // Number of screen recorders that are currently being | 209 // Number of screen recorders that are currently being |
216 // stopped. Normally set to 0 or 1, but in some cases it may be | 210 // stopped. Normally set to 0 or 1, but in some cases it may be |
217 // greater than 1, particularly if when second client can connect | 211 // greater than 1, particularly if when second client can connect |
218 // immidiately after previous one disconnected. | 212 // immidiately after previous one disconnected. |
Wez
2011/11/09 23:18:45
typo: immidiately
Sergey Ulanov
2011/11/10 21:06:14
Done.
| |
219 int stopping_recorders_; | 213 int stopping_recorders_; |
220 | 214 |
221 // Lock is to lock the access to |state_|. | 215 // Tracks the internal state of the host. |
222 base::Lock lock_; | 216 State state_; |
223 | 217 |
224 // Configuration of the protocol. | 218 // Configuration of the protocol. |
225 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; | 219 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; |
226 | 220 |
227 bool is_curtained_; | |
228 | |
229 // Whether or not the host is running in "IT2Me" mode, in which connections | |
230 // are pre-authenticated, and hence the local login challenge can be bypassed. | |
231 bool is_it2me_; | |
232 | |
233 std::string access_code_; | |
234 | |
235 // Stores list of tasks that should be executed when we finish | 221 // Stores list of tasks that should be executed when we finish |
236 // shutdown. Used only while |state_| is set to kStopping. | 222 // shutdown. Used only while |state_| is set to kStopping. |
237 std::vector<Task*> shutdown_tasks_; | 223 std::vector<Task*> shutdown_tasks_; |
238 | 224 |
225 // TODO(sergeyu): The following members do not belong to | |
226 // ChromotingHost and should be moved elsewhere. | |
227 bool is_curtained_; | |
228 bool is_it2me_; | |
229 std::string access_code_; | |
239 UiStrings ui_strings_; | 230 UiStrings ui_strings_; |
240 | 231 |
241 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 232 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
242 }; | 233 }; |
243 | 234 |
244 } // namespace remoting | 235 } // namespace remoting |
245 | 236 |
246 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 237 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |