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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; | 108 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; |
109 virtual void OnSessionSequenceNumber(ClientSession* session, | 109 virtual void OnSessionSequenceNumber(ClientSession* session, |
110 int64 sequence_number) OVERRIDE; | 110 int64 sequence_number) OVERRIDE; |
111 | 111 |
112 // SessionManager::Listener implementation. | 112 // SessionManager::Listener implementation. |
113 virtual void OnSessionManagerInitialized() OVERRIDE; | 113 virtual void OnSessionManagerInitialized() OVERRIDE; |
114 virtual void OnIncomingSession( | 114 virtual void OnIncomingSession( |
115 protocol::Session* session, | 115 protocol::Session* session, |
116 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; | 116 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; |
117 | 117 |
118 void AddAuthenticatedClient(ClientSession* client, | |
119 const protocol::SessionConfig& config, | |
120 const std::string& jid); | |
121 | |
122 // Sets desired configuration for the protocol. Ownership of the | 118 // Sets desired configuration for the protocol. Ownership of the |
123 // |config| is transferred to the object. Must be called before Start(). | 119 // |config| is transferred to the object. Must be called before Start(). |
124 void set_protocol_config(protocol::CandidateSessionConfig* config); | 120 void set_protocol_config(protocol::CandidateSessionConfig* config); |
125 | 121 |
126 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. | 122 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. |
127 void set_it2me(bool is_it2me) { | 123 void set_it2me(bool is_it2me) { |
128 is_it2me_ = is_it2me; | 124 is_it2me_ = is_it2me; |
129 } | 125 } |
130 void set_access_code(const std::string& access_code) { | 126 void set_access_code(const std::string& access_code) { |
131 access_code_ = access_code; | 127 access_code_ = access_code; |
(...skipping 28 matching lines...) Expand all Loading... | |
160 | 156 |
161 // Takes ownership of |access_verifier|, and adds a reference to | 157 // Takes ownership of |access_verifier|, and adds a reference to |
162 // |config|. Caller keeps ownership of |context| and |environment|. | 158 // |config|. Caller keeps ownership of |context| and |environment|. |
163 ChromotingHost(ChromotingHostContext* context, | 159 ChromotingHost(ChromotingHostContext* context, |
164 MutableHostConfig* config, | 160 MutableHostConfig* config, |
165 DesktopEnvironment* environment, | 161 DesktopEnvironment* environment, |
166 AccessVerifier* access_verifier, | 162 AccessVerifier* access_verifier, |
167 bool allow_nat_traversal); | 163 bool allow_nat_traversal); |
168 virtual ~ChromotingHost(); | 164 virtual ~ChromotingHost(); |
169 | 165 |
170 // This method is called if a client is disconnected from the host. | |
171 void OnClientDisconnected(ClientSession* client); | |
172 | |
173 // Creates encoder for the specified configuration. | 166 // Creates encoder for the specified configuration. |
174 Encoder* CreateEncoder(const protocol::SessionConfig& config); | 167 Encoder* CreateEncoder(const protocol::SessionConfig& config); |
175 | 168 |
176 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 169 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
177 | 170 |
178 int AuthenticatedClientsCount() const; | 171 int AuthenticatedClientsCount() const; |
179 | 172 |
180 void EnableCurtainMode(bool enable); | 173 void EnableCurtainMode(bool enable); |
181 | 174 |
182 void StopScreenRecorder(); | 175 void StopScreenRecorder(); |
183 void OnScreenRecorderStopped(); | 176 void OnScreenRecorderStopped(); |
184 | 177 |
185 // The following methods are called during shutdown. | 178 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. |
186 void ShutdownNetwork(); | |
187 void ShutdownRecorder(); | |
188 void ShutdownFinish(); | 179 void ShutdownFinish(); |
189 | 180 |
190 // Parameters specified when the host was created. | 181 // Parameters specified when the host was created. |
191 ChromotingHostContext* context_; | 182 ChromotingHostContext* context_; |
192 DesktopEnvironment* desktop_environment_; | 183 DesktopEnvironment* desktop_environment_; |
193 scoped_refptr<MutableHostConfig> config_; | 184 scoped_refptr<MutableHostConfig> config_; |
194 scoped_ptr<AccessVerifier> access_verifier_; | 185 scoped_ptr<AccessVerifier> access_verifier_; |
195 bool allow_nat_traversal_; | 186 bool allow_nat_traversal_; |
196 | 187 |
197 // Connection objects. | 188 // Connection objects. |
198 scoped_ptr<SignalStrategy> signal_strategy_; | 189 scoped_ptr<SignalStrategy> signal_strategy_; |
199 std::string local_jid_; | 190 std::string local_jid_; |
200 scoped_ptr<protocol::SessionManager> session_manager_; | 191 scoped_ptr<protocol::SessionManager> session_manager_; |
201 | 192 |
202 StatusObserverList status_observers_; | 193 StatusObserverList status_observers_; |
203 | 194 |
204 // The connections to remote clients. | 195 // The connections to remote clients. Must be used only on the |
196 // network thread. | |
205 ClientList clients_; | 197 ClientList clients_; |
206 | 198 |
207 // Session manager for the host process. | 199 // Session manager for the host process. Must be used only on the |
200 // network thread. | |
Wez
2011/11/09 02:32:22
nit: Consider bundling all the members which are n
Sergey Ulanov
2011/11/09 21:24:00
Done. Practically all members of this class are us
| |
208 scoped_refptr<ScreenRecorder> recorder_; | 201 scoped_refptr<ScreenRecorder> recorder_; |
209 | 202 |
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 | 203 // Number of screen recorders that are currently being |
216 // stopped. Normally set to 0 or 1, but in some cases it may be | 204 // 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 | 205 // greater than 1, particularly if when second client can connect |
218 // immidiately after previous one disconnected. | 206 // immidiately after previous one disconnected. Must be used only on |
207 // the network thread. | |
219 int stopping_recorders_; | 208 int stopping_recorders_; |
220 | 209 |
210 // Tracks the internal state of the host. | |
211 // This variable is written on the main thread of ChromotingHostContext | |
212 // and read on the network thread. | |
213 State state_; | |
214 | |
221 // Lock is to lock the access to |state_|. | 215 // Lock is to lock the access to |state_|. |
222 base::Lock lock_; | 216 base::Lock lock_; |
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_; | 221 bool is_curtained_; |
228 | 222 |
229 // Whether or not the host is running in "IT2Me" mode, in which connections | 223 // 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. | 224 // are pre-authenticated, and hence the local login challenge can be bypassed. |
231 bool is_it2me_; | 225 bool is_it2me_; |
232 | 226 |
233 std::string access_code_; | 227 std::string access_code_; |
234 | 228 |
235 // Stores list of tasks that should be executed when we finish | 229 // Stores list of tasks that should be executed when we finish |
236 // shutdown. Used only while |state_| is set to kStopping. | 230 // shutdown. Used only while |state_| is set to kStopping. |
237 std::vector<Task*> shutdown_tasks_; | 231 std::vector<Task*> shutdown_tasks_; |
238 | 232 |
239 UiStrings ui_strings_; | 233 UiStrings ui_strings_; |
240 | 234 |
241 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 235 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
242 }; | 236 }; |
243 | 237 |
244 } // namespace remoting | 238 } // namespace remoting |
245 | 239 |
246 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 240 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |