| 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(Task* shutdown_task); | 91 void Shutdown(Task* 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 OnSessionFailed(ClientSession* session) OVERRIDE; |
| 110 virtual void OnSessionSequenceNumber(ClientSession* session, |
| 111 int64 sequence_number) OVERRIDE; |
| 120 | 112 |
| 121 // SessionManager::Listener implementation. | 113 // SessionManager::Listener implementation. |
| 122 virtual void OnSessionManagerInitialized() OVERRIDE; | 114 virtual void OnSessionManagerInitialized() OVERRIDE; |
| 123 virtual void OnIncomingSession( | 115 virtual void OnIncomingSession( |
| 124 protocol::Session* session, | 116 protocol::Session* session, |
| 125 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; | 117 protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; |
| 126 | 118 |
| 127 void AddAuthenticatedClient( | 119 void AddAuthenticatedClient(ClientSession* client, |
| 128 scoped_refptr<protocol::ConnectionToClient> connection, | 120 const protocol::SessionConfig& config, |
| 129 const protocol::SessionConfig& config, | 121 const std::string& jid); |
| 130 const std::string& jid); | |
| 131 | 122 |
| 132 // Sets desired configuration for the protocol. Ownership of the | 123 // Sets desired configuration for the protocol. Ownership of the |
| 133 // |config| is transferred to the object. Must be called before Start(). | 124 // |config| is transferred to the object. Must be called before Start(). |
| 134 void set_protocol_config(protocol::CandidateSessionConfig* config); | 125 void set_protocol_config(protocol::CandidateSessionConfig* config); |
| 135 | 126 |
| 136 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. | 127 // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. |
| 137 void set_it2me(bool is_it2me) { | 128 void set_it2me(bool is_it2me) { |
| 138 is_it2me_ = is_it2me; | 129 is_it2me_ = is_it2me; |
| 139 } | 130 } |
| 140 void set_access_code(const std::string& access_code) { | 131 void set_access_code(const std::string& access_code) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 171 // Takes ownership of |access_verifier|, and adds a reference to | 162 // Takes ownership of |access_verifier|, and adds a reference to |
| 172 // |config|. Caller keeps ownership of |context| and |environment|. | 163 // |config|. Caller keeps ownership of |context| and |environment|. |
| 173 ChromotingHost(ChromotingHostContext* context, | 164 ChromotingHost(ChromotingHostContext* context, |
| 174 MutableHostConfig* config, | 165 MutableHostConfig* config, |
| 175 DesktopEnvironment* environment, | 166 DesktopEnvironment* environment, |
| 176 AccessVerifier* access_verifier, | 167 AccessVerifier* access_verifier, |
| 177 bool allow_nat_traversal); | 168 bool allow_nat_traversal); |
| 178 virtual ~ChromotingHost(); | 169 virtual ~ChromotingHost(); |
| 179 | 170 |
| 180 // This method is called if a client is disconnected from the host. | 171 // This method is called if a client is disconnected from the host. |
| 181 void OnClientDisconnected(protocol::ConnectionToClient* client); | 172 void OnClientDisconnected(ClientSession* client); |
| 182 | 173 |
| 183 // Creates encoder for the specified configuration. | 174 // Creates encoder for the specified configuration. |
| 184 Encoder* CreateEncoder(const protocol::SessionConfig& config); | 175 Encoder* CreateEncoder(const protocol::SessionConfig& config); |
| 185 | 176 |
| 186 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 177 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
| 187 | 178 |
| 188 int AuthenticatedClientsCount() const; | 179 int AuthenticatedClientsCount() const; |
| 189 | 180 |
| 190 void EnableCurtainMode(bool enable); | 181 void EnableCurtainMode(bool enable); |
| 191 | 182 |
| 192 void ProcessPreAuthentication( | |
| 193 const scoped_refptr<protocol::ConnectionToClient>& connection); | |
| 194 | |
| 195 void StopScreenRecorder(); | 183 void StopScreenRecorder(); |
| 196 void OnScreenRecorderStopped(); | 184 void OnScreenRecorderStopped(); |
| 197 | 185 |
| 198 // The following methods are called during shutdown. | 186 // The following methods are called during shutdown. |
| 199 void ShutdownNetwork(); | 187 void ShutdownNetwork(); |
| 200 void ShutdownRecorder(); | 188 void ShutdownRecorder(); |
| 201 void ShutdownFinish(); | 189 void ShutdownFinish(); |
| 202 | 190 |
| 203 // Parameters specified when the host was created. | 191 // Parameters specified when the host was created. |
| 204 ChromotingHostContext* context_; | 192 ChromotingHostContext* context_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 std::vector<Task*> shutdown_tasks_; | 238 std::vector<Task*> shutdown_tasks_; |
| 251 | 239 |
| 252 UiStrings ui_strings_; | 240 UiStrings ui_strings_; |
| 253 | 241 |
| 254 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 242 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 255 }; | 243 }; |
| 256 | 244 |
| 257 } // namespace remoting | 245 } // namespace remoting |
| 258 | 246 |
| 259 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 247 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |