| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HOST_CHROMOTING_HOST_H_ | 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_ |
| 6 #define REMOTING_HOST_CHROMOTING_HOST_H_ | 6 #define REMOTING_HOST_CHROMOTING_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 14 #include "net/base/backoff_entry.h" | 15 #include "net/base/backoff_entry.h" |
| 15 #include "remoting/host/client_session.h" | 16 #include "remoting/host/client_session.h" |
| 16 #include "remoting/host/host_key_pair.h" | 17 #include "remoting/host/host_key_pair.h" |
| 17 #include "remoting/host/host_status_observer.h" | 18 #include "remoting/host/host_status_observer.h" |
| 18 #include "remoting/host/mouse_move_observer.h" | 19 #include "remoting/host/mouse_move_observer.h" |
| 19 #include "remoting/host/ui_strings.h" | 20 #include "remoting/host/ui_strings.h" |
| 20 #include "remoting/protocol/authenticator.h" | 21 #include "remoting/protocol/authenticator.h" |
| 21 #include "remoting/protocol/session_manager.h" | 22 #include "remoting/protocol/session_manager.h" |
| 22 #include "remoting/protocol/connection_to_client.h" | 23 #include "remoting/protocol/connection_to_client.h" |
| 23 #include "third_party/skia/include/core/SkSize.h" | 24 #include "third_party/skia/include/core/SkSize.h" |
| 24 | 25 |
| 26 namespace base { |
| 27 class SingleThreadTaskRunner; |
| 28 } // namespace base |
| 29 |
| 25 namespace remoting { | 30 namespace remoting { |
| 26 | 31 |
| 27 namespace protocol { | 32 namespace protocol { |
| 28 class InputStub; | 33 class InputStub; |
| 29 class SessionConfig; | 34 class SessionConfig; |
| 30 class CandidateSessionConfig; | 35 class CandidateSessionConfig; |
| 31 } // namespace protocol | 36 } // namespace protocol |
| 32 | 37 |
| 33 class ChromotingHostContext; | |
| 34 class DesktopEnvironmentFactory; | 38 class DesktopEnvironmentFactory; |
| 35 | 39 |
| 36 // A class to implement the functionality of a host process. | 40 // A class to implement the functionality of a host process. |
| 37 // | 41 // |
| 38 // Here's the work flow of this class: | 42 // Here's the work flow of this class: |
| 39 // 1. We should load the saved GAIA ID token or if this is the first | 43 // 1. We should load the saved GAIA ID token or if this is the first |
| 40 // time the host process runs we should prompt user for the | 44 // time the host process runs we should prompt user for the |
| 41 // credential. We will use this token or credentials to authenicate | 45 // credential. We will use this token or credentials to authenicate |
| 42 // and register the host. | 46 // and register the host. |
| 43 // | 47 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 // 3. When the user is disconnected, we will pause the ScreenRecorder | 58 // 3. When the user is disconnected, we will pause the ScreenRecorder |
| 55 // and try to terminate the threads we have created. This will allow | 59 // and try to terminate the threads we have created. This will allow |
| 56 // all pending tasks to complete. After all of that completed we | 60 // all pending tasks to complete. After all of that completed we |
| 57 // return to the idle state. We then go to step (2) if there a new | 61 // return to the idle state. We then go to step (2) if there a new |
| 58 // incoming connection. | 62 // incoming connection. |
| 59 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 63 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| 60 public ClientSession::EventHandler, | 64 public ClientSession::EventHandler, |
| 61 public protocol::SessionManager::Listener, | 65 public protocol::SessionManager::Listener, |
| 62 public MouseMoveObserver { | 66 public MouseMoveObserver { |
| 63 public: | 67 public: |
| 64 // The caller must ensure that |context|, |signal_strategy| and | 68 // The caller must ensure that |signal_strategy| and |
| 65 // |environment| out-live the host. | 69 // |desktop_environment_factory| remain valid at least until the |
| 70 // |shutdown_task| supplied to Shutdown() has been notified. |
| 66 ChromotingHost( | 71 ChromotingHost( |
| 67 ChromotingHostContext* context, | |
| 68 SignalStrategy* signal_strategy, | 72 SignalStrategy* signal_strategy, |
| 69 DesktopEnvironmentFactory* desktop_environment_factory, | 73 DesktopEnvironmentFactory* desktop_environment_factory, |
| 70 scoped_ptr<protocol::SessionManager> session_manager); | 74 scoped_ptr<protocol::SessionManager> session_manager, |
| 75 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 76 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 77 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); |
| 71 | 78 |
| 72 // Asynchronously start the host process. | 79 // Asynchronously start the host process. |
| 73 // | 80 // |
| 74 // After this is invoked, the host process will connect to the talk | 81 // After this is invoked, the host process will connect to the talk |
| 75 // network and start listening for incoming connections. | 82 // network and start listening for incoming connections. |
| 76 // | 83 // |
| 77 // This method can only be called once during the lifetime of this object. | 84 // This method can only be called once during the lifetime of this object. |
| 78 void Start(const std::string& xmpp_login); | 85 void Start(const std::string& xmpp_login); |
| 79 | 86 |
| 80 // Asynchronously shutdown the host process. |shutdown_task| is | 87 // Asynchronously shutdown the host process. |shutdown_task| is |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // Called when a client session is stopped completely. | 171 // Called when a client session is stopped completely. |
| 165 void OnClientStopped(); | 172 void OnClientStopped(); |
| 166 | 173 |
| 167 // Called from Shutdown() to finish shutdown. | 174 // Called from Shutdown() to finish shutdown. |
| 168 void ShutdownFinish(); | 175 void ShutdownFinish(); |
| 169 | 176 |
| 170 // Unless specified otherwise all members of this class must be | 177 // Unless specified otherwise all members of this class must be |
| 171 // used on the network thread only. | 178 // used on the network thread only. |
| 172 | 179 |
| 173 // Parameters specified when the host was created. | 180 // Parameters specified when the host was created. |
| 174 ChromotingHostContext* context_; | |
| 175 DesktopEnvironmentFactory* desktop_environment_factory_; | 181 DesktopEnvironmentFactory* desktop_environment_factory_; |
| 176 scoped_ptr<protocol::SessionManager> session_manager_; | 182 scoped_ptr<protocol::SessionManager> session_manager_; |
| 183 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 184 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
| 185 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 177 | 186 |
| 178 // Connection objects. | 187 // Connection objects. |
| 179 SignalStrategy* signal_strategy_; | 188 SignalStrategy* signal_strategy_; |
| 180 | 189 |
| 181 // Must be used on the network thread only. | 190 // Must be used on the network thread only. |
| 182 ObserverList<HostStatusObserver> status_observers_; | 191 ObserverList<HostStatusObserver> status_observers_; |
| 183 | 192 |
| 184 // The connections to remote clients. | 193 // The connections to remote clients. |
| 185 ClientList clients_; | 194 ClientList clients_; |
| 186 | 195 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 212 | 221 |
| 213 // The maximum duration of any session. | 222 // The maximum duration of any session. |
| 214 base::TimeDelta max_session_duration_; | 223 base::TimeDelta max_session_duration_; |
| 215 | 224 |
| 216 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 225 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 217 }; | 226 }; |
| 218 | 227 |
| 219 } // namespace remoting | 228 } // namespace remoting |
| 220 | 229 |
| 221 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 230 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |