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