| 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/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 14 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 15 #include "net/base/backoff_entry.h" | 16 #include "net/base/backoff_entry.h" |
| 16 #include "remoting/host/client_session.h" | 17 #include "remoting/host/client_session.h" |
| 17 #include "remoting/host/host_key_pair.h" | 18 #include "remoting/host/host_key_pair.h" |
| 19 #include "remoting/host/host_status_monitor.h" |
| 18 #include "remoting/host/host_status_observer.h" | 20 #include "remoting/host/host_status_observer.h" |
| 19 #include "remoting/host/mouse_move_observer.h" | 21 #include "remoting/host/mouse_move_observer.h" |
| 20 #include "remoting/protocol/authenticator.h" | 22 #include "remoting/protocol/authenticator.h" |
| 21 #include "remoting/protocol/session_manager.h" | 23 #include "remoting/protocol/session_manager.h" |
| 22 #include "remoting/protocol/connection_to_client.h" | 24 #include "remoting/protocol/connection_to_client.h" |
| 23 #include "third_party/skia/include/core/SkSize.h" | 25 #include "third_party/skia/include/core/SkSize.h" |
| 24 | 26 |
| 25 namespace base { | 27 namespace base { |
| 26 class SingleThreadTaskRunner; | 28 class SingleThreadTaskRunner; |
| 27 } // namespace base | 29 } // namespace base |
| (...skipping 27 matching lines...) Expand all Loading... |
| 55 // We'll then enter the running state of the host process. | 57 // We'll then enter the running state of the host process. |
| 56 // | 58 // |
| 57 // 3. When the user is disconnected, we will pause the ScreenRecorder | 59 // 3. When the user is disconnected, we will pause the ScreenRecorder |
| 58 // and try to terminate the threads we have created. This will allow | 60 // and try to terminate the threads we have created. This will allow |
| 59 // all pending tasks to complete. After all of that completed we | 61 // all pending tasks to complete. After all of that completed we |
| 60 // return to the idle state. We then go to step (2) if there a new | 62 // return to the idle state. We then go to step (2) if there a new |
| 61 // incoming connection. | 63 // incoming connection. |
| 62 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 64 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| 63 public ClientSession::EventHandler, | 65 public ClientSession::EventHandler, |
| 64 public protocol::SessionManager::Listener, | 66 public protocol::SessionManager::Listener, |
| 67 public HostStatusMonitor, |
| 65 public MouseMoveObserver { | 68 public MouseMoveObserver { |
| 66 public: | 69 public: |
| 67 // The caller must ensure that |signal_strategy| and | 70 // The caller must ensure that |signal_strategy| and |
| 68 // |desktop_environment_factory| remain valid at least until the | 71 // |desktop_environment_factory| remain valid at least until the |
| 69 // |shutdown_task| supplied to Shutdown() has been notified. | 72 // |shutdown_task| supplied to Shutdown() has been notified. |
| 70 ChromotingHost( | 73 ChromotingHost( |
| 71 SignalStrategy* signal_strategy, | 74 SignalStrategy* signal_strategy, |
| 72 DesktopEnvironmentFactory* desktop_environment_factory, | 75 DesktopEnvironmentFactory* desktop_environment_factory, |
| 73 scoped_ptr<protocol::SessionManager> session_manager, | 76 scoped_ptr<protocol::SessionManager> session_manager, |
| 74 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 77 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 75 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 78 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 76 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, | 79 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
| 77 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, | 80 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, |
| 78 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 81 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 79 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 82 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 80 | 83 |
| 81 // Asynchronously start the host process. | 84 // Asynchronously start the host process. |
| 82 // | 85 // |
| 83 // After this is invoked, the host process will connect to the talk | 86 // After this is invoked, the host process will connect to the talk |
| 84 // network and start listening for incoming connections. | 87 // network and start listening for incoming connections. |
| 85 // | 88 // |
| 86 // This method can only be called once during the lifetime of this object. | 89 // This method can only be called once during the lifetime of this object. |
| 87 void Start(const std::string& xmpp_login); | 90 void Start(const std::string& xmpp_login); |
| 88 | 91 |
| 89 // Asynchronously shutdown the host process. |shutdown_task| is | 92 // Asynchronously shutdown the host process. |shutdown_task| is |
| 90 // called after shutdown is completed. | 93 // called after shutdown is completed. |
| 91 void Shutdown(const base::Closure& shutdown_task); | 94 void Shutdown(const base::Closure& shutdown_task); |
| 92 | 95 |
| 93 // Add/Remove |observer| to/from the list of status observers. Both | 96 // HostStatusMonitor interface. |
| 94 // methods can be called on the network thread only. | 97 virtual void AddStatusObserver(HostStatusObserver* observer) OVERRIDE; |
| 95 void AddStatusObserver(HostStatusObserver* observer); | 98 virtual void RemoveStatusObserver(HostStatusObserver* observer) OVERRIDE; |
| 96 void RemoveStatusObserver(HostStatusObserver* observer); | |
| 97 | 99 |
| 98 // This method may be called only from | 100 // This method may be called only from |
| 99 // HostStatusObserver::OnClientAuthenticated() to reject the new | 101 // HostStatusObserver::OnClientAuthenticated() to reject the new |
| 100 // client. | 102 // client. |
| 101 void RejectAuthenticatingClient(); | 103 void RejectAuthenticatingClient(); |
| 102 | 104 |
| 103 // Sets the authenticator factory to use for incoming | 105 // Sets the authenticator factory to use for incoming |
| 104 // connections. Incoming connections are rejected until | 106 // connections. Incoming connections are rejected until |
| 105 // authenticator factory is set. Must be called on the network | 107 // authenticator factory is set. Must be called on the network |
| 106 // thread after the host is started. Must not be called more than | 108 // thread after the host is started. Must not be called more than |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Pause or unpause the session. While the session is paused, remote input | 146 // Pause or unpause the session. While the session is paused, remote input |
| 145 // is ignored. Can be called from any thread. | 147 // is ignored. Can be called from any thread. |
| 146 void PauseSession(bool pause); | 148 void PauseSession(bool pause); |
| 147 | 149 |
| 148 // Disconnects all active clients. Clients are disconnected | 150 // Disconnects all active clients. Clients are disconnected |
| 149 // asynchronously when this method is called on a thread other than | 151 // asynchronously when this method is called on a thread other than |
| 150 // the network thread. Potentically this may cause disconnection of | 152 // the network thread. Potentically this may cause disconnection of |
| 151 // clients that were not connected when this method is called. | 153 // clients that were not connected when this method is called. |
| 152 void DisconnectAllClients(); | 154 void DisconnectAllClients(); |
| 153 | 155 |
| 156 base::WeakPtr<ChromotingHost> AsWeakPtr() { |
| 157 return weak_factory_.GetWeakPtr(); |
| 158 } |
| 159 |
| 154 private: | 160 private: |
| 155 friend class base::RefCountedThreadSafe<ChromotingHost>; | 161 friend class base::RefCountedThreadSafe<ChromotingHost>; |
| 156 friend class ChromotingHostTest; | 162 friend class ChromotingHostTest; |
| 157 | 163 |
| 158 typedef std::vector<scoped_refptr<ClientSession> > ClientList; | 164 typedef std::vector<scoped_refptr<ClientSession> > ClientList; |
| 159 | 165 |
| 160 enum State { | 166 enum State { |
| 161 kInitial, | 167 kInitial, |
| 162 kStarted, | 168 kStarted, |
| 163 kStopping, | 169 kStopping, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 bool authenticating_client_; | 210 bool authenticating_client_; |
| 205 bool reject_authenticating_client_; | 211 bool reject_authenticating_client_; |
| 206 | 212 |
| 207 // Stores list of tasks that should be executed when we finish | 213 // Stores list of tasks that should be executed when we finish |
| 208 // shutdown. Used only while |state_| is set to kStopping. | 214 // shutdown. Used only while |state_| is set to kStopping. |
| 209 std::vector<base::Closure> shutdown_tasks_; | 215 std::vector<base::Closure> shutdown_tasks_; |
| 210 | 216 |
| 211 // The maximum duration of any session. | 217 // The maximum duration of any session. |
| 212 base::TimeDelta max_session_duration_; | 218 base::TimeDelta max_session_duration_; |
| 213 | 219 |
| 220 base::WeakPtrFactory<ChromotingHost> weak_factory_; |
| 221 |
| 214 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 222 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 215 }; | 223 }; |
| 216 | 224 |
| 217 } // namespace remoting | 225 } // namespace remoting |
| 218 | 226 |
| 219 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 227 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |