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 17 matching lines...) Expand all Loading... |
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: | 69 public: |
71 // Factory methods that must be used to create ChromotingHost instances. | 70 // Factory methods that must be used to create ChromotingHost instances. |
72 // Default capturer and input stub are used if it is not specified. | 71 // Default capturer and input stub are used if it is not specified. |
73 // Returned instance takes ownership of |access_verifier| and |environment|, | 72 // Returned instance takes ownership of |access_verifier| and |environment|, |
74 // and adds a reference to |config|. It does NOT take ownership of |context|. | 73 // and adds a reference to |config|. It does NOT take ownership of |context|. |
75 static ChromotingHost* Create(ChromotingHostContext* context, | 74 static ChromotingHost* Create(ChromotingHostContext* context, |
76 MutableHostConfig* config, | 75 MutableHostConfig* config, |
77 AccessVerifier* access_verifier, | 76 AccessVerifier* access_verifier); |
78 Logger* logger); | |
79 static ChromotingHost* Create(ChromotingHostContext* context, | 77 static ChromotingHost* Create(ChromotingHostContext* context, |
80 MutableHostConfig* config, | 78 MutableHostConfig* config, |
81 DesktopEnvironment* environment, | 79 DesktopEnvironment* environment, |
82 AccessVerifier* access_verifier, | 80 AccessVerifier* access_verifier); |
83 Logger* logger); | |
84 | 81 |
85 // Asynchronously start the host process. | 82 // Asynchronously start the host process. |
86 // | 83 // |
87 // 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 |
88 // network and start listening for incoming connections. | 85 // network and start listening for incoming connections. |
89 // | 86 // |
90 // 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. |
91 void Start(); | 88 void Start(); |
92 | 89 |
93 // Asynchronously shutdown the host process. |shutdown_task| is | 90 // Asynchronously shutdown the host process. |shutdown_task| is |
(...skipping 20 matching lines...) Expand all Loading... |
114 SignalStrategy::StatusObserver::State state) OVERRIDE; | 111 SignalStrategy::StatusObserver::State state) OVERRIDE; |
115 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; | 112 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; |
116 | 113 |
117 //////////////////////////////////////////////////////////////////////////// | 114 //////////////////////////////////////////////////////////////////////////// |
118 // ClientSession::EventHandler implementation. | 115 // ClientSession::EventHandler implementation. |
119 virtual void LocalLoginSucceeded( | 116 virtual void LocalLoginSucceeded( |
120 scoped_refptr<protocol::ConnectionToClient> client); | 117 scoped_refptr<protocol::ConnectionToClient> client); |
121 virtual void LocalLoginFailed( | 118 virtual void LocalLoginFailed( |
122 scoped_refptr<protocol::ConnectionToClient> client); | 119 scoped_refptr<protocol::ConnectionToClient> client); |
123 | 120 |
124 Logger* logger() { return logger_; } | |
125 | |
126 // Callback for ChromotingServer. | 121 // Callback for ChromotingServer. |
127 void OnNewClientSession( | 122 void OnNewClientSession( |
128 protocol::Session* session, | 123 protocol::Session* session, |
129 protocol::SessionManager::IncomingSessionResponse* response); | 124 protocol::SessionManager::IncomingSessionResponse* response); |
130 | 125 |
131 // Sets desired configuration for the protocol. Ownership of the | 126 // Sets desired configuration for the protocol. Ownership of the |
132 // |config| is transferred to the object. Must be called before Start(). | 127 // |config| is transferred to the object. Must be called before Start(). |
133 void set_protocol_config(protocol::CandidateSessionConfig* config); | 128 void set_protocol_config(protocol::CandidateSessionConfig* config); |
134 | 129 |
135 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. | 130 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. |
(...skipping 14 matching lines...) Expand all Loading... |
150 friend class ChromotingHostTest; | 145 friend class ChromotingHostTest; |
151 | 146 |
152 typedef std::vector<HostStatusObserver*> StatusObserverList; | 147 typedef std::vector<HostStatusObserver*> StatusObserverList; |
153 typedef std::vector<scoped_refptr<ClientSession> > ClientList; | 148 typedef std::vector<scoped_refptr<ClientSession> > ClientList; |
154 | 149 |
155 // Takes ownership of |access_verifier| and |environment|, and adds a | 150 // Takes ownership of |access_verifier| and |environment|, and adds a |
156 // reference to |config|. Does NOT take ownership of |context|. | 151 // reference to |config|. Does NOT take ownership of |context|. |
157 ChromotingHost(ChromotingHostContext* context, | 152 ChromotingHost(ChromotingHostContext* context, |
158 MutableHostConfig* config, | 153 MutableHostConfig* config, |
159 DesktopEnvironment* environment, | 154 DesktopEnvironment* environment, |
160 AccessVerifier* access_verifier, | 155 AccessVerifier* access_verifier); |
161 Logger* logger); | |
162 virtual ~ChromotingHost(); | 156 virtual ~ChromotingHost(); |
163 | 157 |
164 enum State { | 158 enum State { |
165 kInitial, | 159 kInitial, |
166 kStarted, | 160 kStarted, |
167 kStopping, | 161 kStopping, |
168 kStopped, | 162 kStopped, |
169 }; | 163 }; |
170 | 164 |
171 // This method is called if a client is disconnected from the host. | 165 // This method is called if a client is disconnected from the host. |
(...skipping 26 matching lines...) Expand all Loading... |
198 scoped_ptr<SignalStrategy> signal_strategy_; | 192 scoped_ptr<SignalStrategy> signal_strategy_; |
199 | 193 |
200 std::string local_jid_; | 194 std::string local_jid_; |
201 | 195 |
202 scoped_ptr<protocol::SessionManager> session_manager_; | 196 scoped_ptr<protocol::SessionManager> session_manager_; |
203 | 197 |
204 StatusObserverList status_observers_; | 198 StatusObserverList status_observers_; |
205 | 199 |
206 scoped_ptr<AccessVerifier> access_verifier_; | 200 scoped_ptr<AccessVerifier> access_verifier_; |
207 | 201 |
208 // Logger (owned by the HostNPScriptObject). | |
209 Logger* logger_; | |
210 | |
211 // The connections to remote clients. | 202 // The connections to remote clients. |
212 ClientList clients_; | 203 ClientList clients_; |
213 | 204 |
214 // Session manager for the host process. | 205 // Session manager for the host process. |
215 scoped_refptr<ScreenRecorder> recorder_; | 206 scoped_refptr<ScreenRecorder> recorder_; |
216 | 207 |
217 // Tracks the internal state of the host. | 208 // Tracks the internal state of the host. |
218 // This variable is written on the main thread of ChromotingHostContext | 209 // This variable is written on the main thread of ChromotingHostContext |
219 // and read by jingle thread. | 210 // and read by jingle thread. |
220 State state_; | 211 State state_; |
(...skipping 13 matching lines...) Expand all Loading... |
234 // Stores list of tasks that should be executed when we finish | 225 // Stores list of tasks that should be executed when we finish |
235 // shutdown. Used only while |state_| is set to kStopping. | 226 // shutdown. Used only while |state_| is set to kStopping. |
236 std::vector<Task*> shutdown_tasks_; | 227 std::vector<Task*> shutdown_tasks_; |
237 | 228 |
238 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 229 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
239 }; | 230 }; |
240 | 231 |
241 } // namespace remoting | 232 } // namespace remoting |
242 | 233 |
243 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 234 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |