Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/thread.h" | 10 #include "base/thread.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 class ConnectionToClient; | 25 class ConnectionToClient; |
| 26 class HostStub; | 26 class HostStub; |
| 27 class InputStub; | 27 class InputStub; |
| 28 class SessionConfig; | 28 class SessionConfig; |
| 29 } // namespace protocol | 29 } // namespace protocol |
| 30 | 30 |
| 31 class Capturer; | 31 class Capturer; |
| 32 class ChromotingHostContext; | 32 class ChromotingHostContext; |
| 33 class Encoder; | 33 class Encoder; |
| 34 class MutableHostConfig; | 34 class MutableHostConfig; |
| 35 class SessionManager; | 35 class ScreenRecorder; |
| 36 | 36 |
| 37 // A class to implement the functionality of a host process. | 37 // A class to implement the functionality of a host process. |
| 38 // | 38 // |
| 39 // Here's the work flow of this class: | 39 // Here's the work flow of this class: |
| 40 // 1. We should load the saved GAIA ID token or if this is the first | 40 // 1. We should load the saved GAIA ID token or if this is the first |
| 41 // time the host process runs we should prompt user for the | 41 // time the host process runs we should prompt user for the |
| 42 // credential. We will use this token or credentials to authenicate | 42 // credential. We will use this token or credentials to authenicate |
| 43 // and register the host. | 43 // and register the host. |
| 44 // | 44 // |
| 45 // 2. We listen for incoming connection using libjingle. We will create | 45 // 2. We listen for incoming connection using libjingle. We will create |
| 46 // a ConnectionToClient object that wraps around linjingle for transport. | 46 // a ConnectionToClient object that wraps around linjingle for transport. |
| 47 // Also create a SessionManager with appropriate Encoder and Capturer and | 47 // A ScreenRecorder is created with Encoder and Capturer. |
|
dmac
2010/11/19 23:24:24
with an Encoder and a Capturer.
| |
| 48 // add the ConnectionToClient to this SessionManager for transporting the | 48 // ConnectionToClient is added to this SCreenRecorder for transporting |
|
dmac
2010/11/19 23:24:24
A ConnectionToClient is added to the ScreenRecorde
| |
| 49 // screen captures. An InputStub is created and registered with the | 49 // the screen captures. An InputStub is created and registered with the |
| 50 // ConnectionToClient to receive mouse / keyboard events from the remote | 50 // ConnectionToClient to receive mouse / keyboard events from the remote |
| 51 // client. | 51 // client. |
| 52 // This is also the right time to create multiple threads to host | 52 // This is also the right time to create multiple threads to host |
| 53 // the above objects. After we have done all the initialization | 53 // the above objects. After we have done all the initialization |
| 54 // we'll start the SessionManager. We'll then enter the running state | 54 // we'll start the ScreenRecorder. We'll then enter the running state |
| 55 // of the host process. | 55 // of the host process. |
| 56 // | 56 // |
| 57 // 3. When the user is disconencted, we will pause the SessionManager | 57 // 3. When the user is disconnected, we will pause the ScreenRecorder |
| 58 // and try to terminate the threads we have created. This will allow | 58 // and try to terminate the threads we have created. This will allow |
| 59 // all pending tasks to complete. After all of that completed we | 59 // 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 | 60 // return to the idle state. We then go to step (2) if there a new |
| 61 // incoming connection. | 61 // incoming connection. |
| 62 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 62 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| 63 public protocol::ConnectionToClient::EventHandler, | 63 public protocol::ConnectionToClient::EventHandler, |
| 64 public JingleClient::Callback { | 64 public JingleClient::Callback { |
| 65 public: | 65 public: |
| 66 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config); | 66 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config); |
| 67 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, | 67 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 void OnServerClosed(); | 118 void OnServerClosed(); |
| 119 | 119 |
| 120 // Creates encoder for the specified configuration. | 120 // Creates encoder for the specified configuration. |
| 121 Encoder* CreateEncoder(const protocol::SessionConfig* config); | 121 Encoder* CreateEncoder(const protocol::SessionConfig* config); |
| 122 | 122 |
| 123 // The context that the chromoting host runs on. | 123 // The context that the chromoting host runs on. |
| 124 ChromotingHostContext* context_; | 124 ChromotingHostContext* context_; |
| 125 | 125 |
| 126 scoped_refptr<MutableHostConfig> config_; | 126 scoped_refptr<MutableHostConfig> config_; |
| 127 | 127 |
| 128 // Capturer to be used by SessionManager. Once the SessionManager is | 128 // Capturer to be used by ScreenRecorder. Once the ScreenRecorder is |
| 129 // constructed this is set to NULL. | 129 // constructed this is set to NULL. |
| 130 scoped_ptr<Capturer> capturer_; | 130 scoped_ptr<Capturer> capturer_; |
| 131 | 131 |
| 132 // constructed this is set to NULL. | |
| 133 scoped_ptr<Encoder> encoder_; | |
| 134 | |
| 135 // InputStub in the host executes input events received from the client. | 132 // InputStub in the host executes input events received from the client. |
| 136 scoped_ptr<protocol::InputStub> input_stub_; | 133 scoped_ptr<protocol::InputStub> input_stub_; |
| 137 | 134 |
| 138 // HostStub in the host executes control events received from the client. | 135 // HostStub in the host executes control events received from the client. |
| 139 scoped_ptr<protocol::HostStub> host_stub_; | 136 scoped_ptr<protocol::HostStub> host_stub_; |
| 140 | 137 |
| 141 // The libjingle client. This is used to connect to the talk network to | 138 // The libjingle client. This is used to connect to the talk network to |
| 142 // receive connection requests from chromoting client. | 139 // receive connection requests from chromoting client. |
| 143 scoped_refptr<JingleClient> jingle_client_; | 140 scoped_refptr<JingleClient> jingle_client_; |
| 144 | 141 |
| 145 scoped_refptr<protocol::SessionManager> session_manager_; | 142 scoped_refptr<protocol::SessionManager> session_manager_; |
| 146 | 143 |
| 147 // Objects that takes care of sending heartbeats to the chromoting bot. | 144 // Objects that takes care of sending heartbeats to the chromoting bot. |
| 148 scoped_refptr<HeartbeatSender> heartbeat_sender_; | 145 scoped_refptr<HeartbeatSender> heartbeat_sender_; |
| 149 | 146 |
| 150 AccessVerifier access_verifier_; | 147 AccessVerifier access_verifier_; |
| 151 | 148 |
| 152 // A ConnectionToClient manages the connectino to a remote client. | 149 // A ConnectionToClient manages the connectino to a remote client. |
| 153 // TODO(hclam): Expand this to a list of clients. | 150 // TODO(hclam): Expand this to a list of clients. |
| 154 scoped_refptr<protocol::ConnectionToClient> connection_; | 151 scoped_refptr<protocol::ConnectionToClient> connection_; |
| 155 | 152 |
| 156 // Session manager for the host process. | 153 // Session manager for the host process. |
| 157 scoped_refptr<SessionManager> session_; | 154 scoped_refptr<ScreenRecorder> recorder_; |
| 158 | 155 |
| 159 // This task gets executed when this object fails to connect to the | 156 // This task gets executed when this object fails to connect to the |
| 160 // talk network or Shutdown() is called. | 157 // talk network or Shutdown() is called. |
| 161 scoped_ptr<Task> shutdown_task_; | 158 scoped_ptr<Task> shutdown_task_; |
| 162 | 159 |
| 163 // Tracks the internal state of the host. | 160 // Tracks the internal state of the host. |
| 164 // This variable is written on the main thread of ChromotingHostContext | 161 // This variable is written on the main thread of ChromotingHostContext |
| 165 // and read by jingle thread. | 162 // and read by jingle thread. |
| 166 State state_; | 163 State state_; |
| 167 | 164 |
| 168 // Lock is to lock the access to |state_|. | 165 // Lock is to lock the access to |state_|. |
| 169 Lock lock_; | 166 Lock lock_; |
| 170 | 167 |
| 171 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 168 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 172 }; | 169 }; |
| 173 | 170 |
| 174 } // namespace remoting | 171 } // namespace remoting |
| 175 | 172 |
| 176 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 173 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |