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 18 matching lines...) Expand all Loading... |
29 class HostStub; | 29 class HostStub; |
30 class InputStub; | 30 class InputStub; |
31 class SessionConfig; | 31 class SessionConfig; |
32 class CandidateSessionConfig; | 32 class CandidateSessionConfig; |
33 } // namespace protocol | 33 } // namespace protocol |
34 | 34 |
35 class Capturer; | 35 class Capturer; |
36 class ChromotingHostContext; | 36 class ChromotingHostContext; |
37 class DesktopEnvironment; | 37 class DesktopEnvironment; |
38 class Encoder; | 38 class Encoder; |
39 class Logger; | |
40 class MutableHostConfig; | 39 class MutableHostConfig; |
41 class ScreenRecorder; | 40 class ScreenRecorder; |
42 | 41 |
43 // A class to implement the functionality of a host process. | 42 // A class to implement the functionality of a host process. |
44 // | 43 // |
45 // Here's the work flow of this class: | 44 // Here's the work flow of this class: |
46 // 1. We should load the saved GAIA ID token or if this is the first | 45 // 1. We should load the saved GAIA ID token or if this is the first |
47 // time the host process runs we should prompt user for the | 46 // time the host process runs we should prompt user for the |
48 // credential. We will use this token or credentials to authenicate | 47 // credential. We will use this token or credentials to authenicate |
49 // and register the host. | 48 // and register the host. |
(...skipping 15 matching lines...) Expand all Loading... |
65 // incoming connection. | 64 // incoming connection. |
66 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 65 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
67 public protocol::ConnectionToClient::EventHandler, | 66 public protocol::ConnectionToClient::EventHandler, |
68 public ClientSession::EventHandler, | 67 public ClientSession::EventHandler, |
69 public SignalStrategy::StatusObserver, | 68 public SignalStrategy::StatusObserver, |
70 public protocol::SessionManager::Listener { | 69 public protocol::SessionManager::Listener { |
71 public: | 70 public: |
72 // Factory methods that must be used to create ChromotingHost | 71 // Factory methods that must be used to create ChromotingHost |
73 // instances. Returned instance takes ownership of | 72 // instances. Returned instance takes ownership of |
74 // |access_verifier|. It does NOT take ownership of |context|, | 73 // |access_verifier|. It does NOT take ownership of |context|, |
75 // |environment| and |logger|, but they should not be deleted until | 74 // and |environment|, but they should not be deleted until |
76 // returned host is destroyed. | 75 // returned host is destroyed. |
77 static ChromotingHost* Create(ChromotingHostContext* context, | 76 static ChromotingHost* Create(ChromotingHostContext* context, |
78 MutableHostConfig* config, | 77 MutableHostConfig* config, |
79 DesktopEnvironment* environment, | 78 DesktopEnvironment* environment, |
80 AccessVerifier* access_verifier, | 79 AccessVerifier* access_verifier, |
81 Logger* logger, | |
82 bool allow_nat_traversal); | 80 bool allow_nat_traversal); |
83 | 81 |
84 // Asynchronously start the host process. | 82 // Asynchronously start the host process. |
85 // | 83 // |
86 // After this is invoked, the host process will connect to the talk | 84 // After this is invoked, the host process will connect to the talk |
87 // network and start listening for incoming connections. | 85 // network and start listening for incoming connections. |
88 // | 86 // |
89 // This method can only be called once during the lifetime of this object. | 87 // This method can only be called once during the lifetime of this object. |
90 void Start(); | 88 void Start(); |
91 | 89 |
(...skipping 21 matching lines...) Expand all Loading... |
113 SignalStrategy::StatusObserver::State state) OVERRIDE; | 111 SignalStrategy::StatusObserver::State state) OVERRIDE; |
114 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; | 112 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; |
115 | 113 |
116 //////////////////////////////////////////////////////////////////////////// | 114 //////////////////////////////////////////////////////////////////////////// |
117 // ClientSession::EventHandler implementation. | 115 // ClientSession::EventHandler implementation. |
118 virtual void LocalLoginSucceeded( | 116 virtual void LocalLoginSucceeded( |
119 scoped_refptr<protocol::ConnectionToClient> client); | 117 scoped_refptr<protocol::ConnectionToClient> client); |
120 virtual void LocalLoginFailed( | 118 virtual void LocalLoginFailed( |
121 scoped_refptr<protocol::ConnectionToClient> client); | 119 scoped_refptr<protocol::ConnectionToClient> client); |
122 | 120 |
123 Logger* logger() { return logger_; } | |
124 | |
125 // SessionManager::Listener implementation. | 121 // SessionManager::Listener implementation. |
126 virtual void OnSessionManagerInitialized() OVERRIDE; | 122 virtual void OnSessionManagerInitialized() OVERRIDE; |
127 virtual void OnIncomingSession( | 123 virtual void OnIncomingSession( |
128 protocol::Session* session, | 124 protocol::Session* session, |
129 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; | 125 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; |
130 | 126 |
131 // Sets desired configuration for the protocol. Ownership of the | 127 // Sets desired configuration for the protocol. Ownership of the |
132 // |config| is transferred to the object. Must be called before Start(). | 128 // |config| is transferred to the object. Must be called before Start(). |
133 void set_protocol_config(protocol::CandidateSessionConfig* config); | 129 void set_protocol_config(protocol::CandidateSessionConfig* config); |
134 | 130 |
(...skipping 26 matching lines...) Expand all Loading... |
161 kStopping, | 157 kStopping, |
162 kStopped, | 158 kStopped, |
163 }; | 159 }; |
164 | 160 |
165 // Takes ownership of |access_verifier|, and adds a reference to | 161 // Takes ownership of |access_verifier|, and adds a reference to |
166 // |config|. Caller keeps ownership of |context| and |environment|. | 162 // |config|. Caller keeps ownership of |context| and |environment|. |
167 ChromotingHost(ChromotingHostContext* context, | 163 ChromotingHost(ChromotingHostContext* context, |
168 MutableHostConfig* config, | 164 MutableHostConfig* config, |
169 DesktopEnvironment* environment, | 165 DesktopEnvironment* environment, |
170 AccessVerifier* access_verifier, | 166 AccessVerifier* access_verifier, |
171 Logger* logger, | |
172 bool allow_nat_traversal); | 167 bool allow_nat_traversal); |
173 virtual ~ChromotingHost(); | 168 virtual ~ChromotingHost(); |
174 | 169 |
175 // This method is called if a client is disconnected from the host. | 170 // This method is called if a client is disconnected from the host. |
176 void OnClientDisconnected(protocol::ConnectionToClient* client); | 171 void OnClientDisconnected(protocol::ConnectionToClient* client); |
177 | 172 |
178 // Creates encoder for the specified configuration. | 173 // Creates encoder for the specified configuration. |
179 Encoder* CreateEncoder(const protocol::SessionConfig* config); | 174 Encoder* CreateEncoder(const protocol::SessionConfig* config); |
180 | 175 |
181 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 176 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
182 | 177 |
183 int AuthenticatedClientsCount() const; | 178 int AuthenticatedClientsCount() const; |
184 | 179 |
185 void EnableCurtainMode(bool enable); | 180 void EnableCurtainMode(bool enable); |
186 | 181 |
187 void ProcessPreAuthentication( | 182 void ProcessPreAuthentication( |
188 const scoped_refptr<protocol::ConnectionToClient>& connection); | 183 const scoped_refptr<protocol::ConnectionToClient>& connection); |
189 | 184 |
190 // The following methods are called during shutdown. | 185 // The following methods are called during shutdown. |
191 void ShutdownNetwork(); | 186 void ShutdownNetwork(); |
192 void ShutdownRecorder(); | 187 void ShutdownRecorder(); |
193 void ShutdownFinish(); | 188 void ShutdownFinish(); |
194 | 189 |
195 // Parameters specified when the host was created. | 190 // Parameters specified when the host was created. |
196 ChromotingHostContext* context_; | 191 ChromotingHostContext* context_; |
197 DesktopEnvironment* desktop_environment_; | 192 DesktopEnvironment* desktop_environment_; |
198 scoped_refptr<MutableHostConfig> config_; | 193 scoped_refptr<MutableHostConfig> config_; |
199 scoped_ptr<AccessVerifier> access_verifier_; | 194 scoped_ptr<AccessVerifier> access_verifier_; |
200 Logger* logger_; | |
201 bool allow_nat_traversal_; | 195 bool allow_nat_traversal_; |
202 | 196 |
203 // Connection objects. | 197 // Connection objects. |
204 scoped_ptr<SignalStrategy> signal_strategy_; | 198 scoped_ptr<SignalStrategy> signal_strategy_; |
205 std::string local_jid_; | 199 std::string local_jid_; |
206 scoped_ptr<protocol::SessionManager> session_manager_; | 200 scoped_ptr<protocol::SessionManager> session_manager_; |
207 | 201 |
208 StatusObserverList status_observers_; | 202 StatusObserverList status_observers_; |
209 | 203 |
210 // The connections to remote clients. | 204 // The connections to remote clients. |
(...skipping 24 matching lines...) Expand all Loading... |
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 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 233 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
240 }; | 234 }; |
241 | 235 |
242 } // namespace remoting | 236 } // namespace remoting |
243 | 237 |
244 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 238 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |