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" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "remoting/base/encoder.h" | 12 #include "remoting/base/encoder.h" |
13 #include "remoting/host/access_verifier.h" | 13 #include "remoting/host/access_verifier.h" |
14 #include "remoting/host/capturer.h" | 14 #include "remoting/host/capturer.h" |
15 #include "remoting/host/client_session.h" | 15 #include "remoting/host/client_session.h" |
16 #include "remoting/host/desktop_environment.h" | 16 #include "remoting/host/desktop_environment.h" |
17 #include "remoting/host/host_status_observer.h" | 17 #include "remoting/host/host_status_observer.h" |
18 #include "remoting/host/ui_strings.h" | 18 #include "remoting/host/ui_strings.h" |
19 #include "remoting/jingle_glue/jingle_thread.h" | 19 #include "remoting/jingle_glue/jingle_thread.h" |
20 #include "remoting/jingle_glue/signal_strategy.h" | 20 #include "remoting/jingle_glue/signal_strategy.h" |
21 #include "remoting/protocol/session_manager.h" | 21 #include "remoting/protocol/session_manager.h" |
22 #include "remoting/protocol/connection_to_client.h" | 22 #include "remoting/protocol/connection_to_client.h" |
23 | 23 |
24 class Task; | 24 class Task; |
25 | 25 |
26 namespace remoting { | 26 namespace remoting { |
27 | 27 |
28 namespace protocol { | 28 namespace protocol { |
29 class ConnectionToClient; | |
30 class HostStub; | 29 class HostStub; |
31 class InputStub; | 30 class InputStub; |
32 class SessionConfig; | 31 class SessionConfig; |
33 class CandidateSessionConfig; | 32 class CandidateSessionConfig; |
34 } // namespace protocol | 33 } // namespace protocol |
35 | 34 |
36 class Capturer; | 35 class Capturer; |
37 class ChromotingHostContext; | 36 class ChromotingHostContext; |
38 class DesktopEnvironment; | 37 class DesktopEnvironment; |
39 class Encoder; | 38 class Encoder; |
(...skipping 17 matching lines...) Expand all Loading... |
57 // client. | 56 // client. |
58 // After we have done all the initialization we'll start the ScreenRecorder. | 57 // After we have done all the initialization we'll start the ScreenRecorder. |
59 // We'll then enter the running state of the host process. | 58 // We'll then enter the running state of the host process. |
60 // | 59 // |
61 // 3. When the user is disconnected, we will pause the ScreenRecorder | 60 // 3. When the user is disconnected, we will pause the ScreenRecorder |
62 // and try to terminate the threads we have created. This will allow | 61 // and try to terminate the threads we have created. This will allow |
63 // all pending tasks to complete. After all of that completed we | 62 // all pending tasks to complete. After all of that completed we |
64 // return to the idle state. We then go to step (2) if there a new | 63 // return to the idle state. We then go to step (2) if there a new |
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, | |
68 public ClientSession::EventHandler, | 66 public ClientSession::EventHandler, |
69 public SignalStrategy::StatusObserver, | 67 public SignalStrategy::StatusObserver, |
70 public protocol::SessionManager::Listener { | 68 public protocol::SessionManager::Listener { |
71 public: | 69 public: |
72 // Factory methods that must be used to create ChromotingHost | 70 // Factory methods that must be used to create ChromotingHost |
73 // instances. Returned instance takes ownership of | 71 // instances. Returned instance takes ownership of |
74 // |access_verifier|. It does NOT take ownership of |context|, | 72 // |access_verifier|. It does NOT take ownership of |context|, |
75 // and |environment|, but they should not be deleted until | 73 // and |environment|, but they should not be deleted until |
76 // returned host is destroyed. | 74 // returned host is destroyed. |
77 static ChromotingHost* Create(ChromotingHostContext* context, | 75 static ChromotingHost* Create(ChromotingHostContext* context, |
(...skipping 14 matching lines...) Expand all Loading... |
92 // called after shutdown is completed. | 90 // called after shutdown is completed. |
93 void Shutdown(const base::Closure& shutdown_task); | 91 void Shutdown(const base::Closure& shutdown_task); |
94 | 92 |
95 // Adds |observer| to the list of status observers. Doesn't take | 93 // Adds |observer| to the list of status observers. Doesn't take |
96 // ownership of |observer|, so |observer| must outlive this | 94 // ownership of |observer|, so |observer| must outlive this |
97 // object. All status observers must be added before the host is | 95 // object. All status observers must be added before the host is |
98 // started. | 96 // started. |
99 void AddStatusObserver(HostStatusObserver* observer); | 97 void AddStatusObserver(HostStatusObserver* observer); |
100 | 98 |
101 //////////////////////////////////////////////////////////////////////////// | 99 //////////////////////////////////////////////////////////////////////////// |
102 // protocol::ConnectionToClient::EventHandler implementation. | |
103 // TODO(sergeyu): Move this to ClientSession. | |
104 virtual void OnConnectionOpened(protocol::ConnectionToClient* client); | |
105 virtual void OnConnectionClosed(protocol::ConnectionToClient* client); | |
106 virtual void OnConnectionFailed(protocol::ConnectionToClient* client); | |
107 virtual void OnSequenceNumberUpdated(protocol::ConnectionToClient* client, | |
108 int64 sequence_number); | |
109 | |
110 //////////////////////////////////////////////////////////////////////////// | |
111 // SignalStrategy::StatusObserver implementation. | 100 // SignalStrategy::StatusObserver implementation. |
112 virtual void OnStateChange( | 101 virtual void OnStateChange( |
113 SignalStrategy::StatusObserver::State state) OVERRIDE; | 102 SignalStrategy::StatusObserver::State state) OVERRIDE; |
114 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; | 103 virtual void OnJidChange(const std::string& full_jid) OVERRIDE; |
115 | 104 |
116 //////////////////////////////////////////////////////////////////////////// | 105 //////////////////////////////////////////////////////////////////////////// |
117 // ClientSession::EventHandler implementation. | 106 // ClientSession::EventHandler implementation. |
118 virtual void OnAuthenticationComplete( | 107 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE; |
119 scoped_refptr<protocol::ConnectionToClient> client); | 108 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; |
| 109 virtual void OnSessionSequenceNumber(ClientSession* session, |
| 110 int64 sequence_number) OVERRIDE; |
120 | 111 |
121 // SessionManager::Listener implementation. | 112 // SessionManager::Listener implementation. |
122 virtual void OnSessionManagerInitialized() OVERRIDE; | 113 virtual void OnSessionManagerInitialized() OVERRIDE; |
123 virtual void OnIncomingSession( | 114 virtual void OnIncomingSession( |
124 protocol::Session* session, | 115 protocol::Session* session, |
125 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; | 116 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; |
126 | 117 |
127 void AddAuthenticatedClient( | |
128 scoped_refptr<protocol::ConnectionToClient> connection, | |
129 const protocol::SessionConfig& config, | |
130 const std::string& jid); | |
131 | |
132 // Sets desired configuration for the protocol. Ownership of the | 118 // Sets desired configuration for the protocol. Ownership of the |
133 // |config| is transferred to the object. Must be called before Start(). | 119 // |config| is transferred to the object. Must be called before Start(). |
134 void set_protocol_config(protocol::CandidateSessionConfig* config); | 120 void set_protocol_config(protocol::CandidateSessionConfig* config); |
135 | 121 |
136 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. | 122 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. |
137 void set_it2me(bool is_it2me) { | 123 void set_it2me(bool is_it2me) { |
138 is_it2me_ = is_it2me; | 124 is_it2me_ = is_it2me; |
139 } | 125 } |
140 void set_access_code(const std::string& access_code) { | 126 void set_access_code(const std::string& access_code) { |
141 access_code_ = access_code; | 127 access_code_ = access_code; |
(...skipping 29 matching lines...) Expand all Loading... |
171 // Takes ownership of |access_verifier|, and adds a reference to | 157 // Takes ownership of |access_verifier|, and adds a reference to |
172 // |config|. Caller keeps ownership of |context| and |environment|. | 158 // |config|. Caller keeps ownership of |context| and |environment|. |
173 ChromotingHost(ChromotingHostContext* context, | 159 ChromotingHost(ChromotingHostContext* context, |
174 MutableHostConfig* config, | 160 MutableHostConfig* config, |
175 DesktopEnvironment* environment, | 161 DesktopEnvironment* environment, |
176 AccessVerifier* access_verifier, | 162 AccessVerifier* access_verifier, |
177 bool allow_nat_traversal); | 163 bool allow_nat_traversal); |
178 virtual ~ChromotingHost(); | 164 virtual ~ChromotingHost(); |
179 | 165 |
180 // This method is called if a client is disconnected from the host. | 166 // This method is called if a client is disconnected from the host. |
181 void OnClientDisconnected(protocol::ConnectionToClient* client); | 167 void OnClientDisconnected(ClientSession* client); |
182 | 168 |
183 // Creates encoder for the specified configuration. | 169 // Creates encoder for the specified configuration. |
184 Encoder* CreateEncoder(const protocol::SessionConfig& config); | 170 Encoder* CreateEncoder(const protocol::SessionConfig& config); |
185 | 171 |
186 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 172 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
187 | 173 |
| 174 void AddAuthenticatedClient(ClientSession* client, |
| 175 const protocol::SessionConfig& config, |
| 176 const std::string& jid); |
| 177 |
188 int AuthenticatedClientsCount() const; | 178 int AuthenticatedClientsCount() const; |
189 | 179 |
190 void EnableCurtainMode(bool enable); | 180 void EnableCurtainMode(bool enable); |
191 | 181 |
192 void ProcessPreAuthentication( | |
193 const scoped_refptr<protocol::ConnectionToClient>& connection); | |
194 | |
195 void StopScreenRecorder(); | 182 void StopScreenRecorder(); |
196 void OnScreenRecorderStopped(); | 183 void OnScreenRecorderStopped(); |
197 | 184 |
198 // The following methods are called during shutdown. | 185 // The following methods are called during shutdown. |
199 void ShutdownNetwork(); | 186 void ShutdownNetwork(); |
200 void ShutdownRecorder(); | 187 void ShutdownRecorder(); |
201 void ShutdownFinish(); | 188 void ShutdownFinish(); |
202 | 189 |
203 // Parameters specified when the host was created. | 190 // Parameters specified when the host was created. |
204 ChromotingHostContext* context_; | 191 ChromotingHostContext* context_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 std::vector<base::Closure> shutdown_tasks_; | 237 std::vector<base::Closure> shutdown_tasks_; |
251 | 238 |
252 UiStrings ui_strings_; | 239 UiStrings ui_strings_; |
253 | 240 |
254 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 241 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
255 }; | 242 }; |
256 | 243 |
257 } // namespace remoting | 244 } // namespace remoting |
258 | 245 |
259 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 246 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |