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 // Also create a ScreenRecorder with appropriate Encoder and Capturer and |
dmac
2010/11/17 16:37:54
the english here is bad...
We will create a Conne
| |
48 // add the ConnectionToClient to this SessionManager for transporting the | 48 // add the ConnectionToClient to this ScreenRecorder for transporting the |
49 // screen captures. An InputStub is created and registered with the | 49 // 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 disconencted, we will pause the ScreenRecorder |
dmac
2010/11/17 16:37:54
disconnected
| |
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. | 132 // constructed this is set to NULL. |
dmac
2010/11/17 16:37:54
this comment makes no sense.
| |
133 scoped_ptr<Encoder> encoder_; | 133 scoped_ptr<Encoder> encoder_; |
134 | 134 |
135 // InputStub in the host executes input events received from the client. | 135 // InputStub in the host executes input events received from the client. |
136 scoped_ptr<protocol::InputStub> input_stub_; | 136 scoped_ptr<protocol::InputStub> input_stub_; |
137 | 137 |
138 // HostStub in the host executes control events received from the client. | 138 // HostStub in the host executes control events received from the client. |
139 scoped_ptr<protocol::HostStub> host_stub_; | 139 scoped_ptr<protocol::HostStub> host_stub_; |
140 | 140 |
141 // The libjingle client. This is used to connect to the talk network to | 141 // The libjingle client. This is used to connect to the talk network to |
142 // receive connection requests from chromoting client. | 142 // receive connection requests from chromoting client. |
143 scoped_refptr<JingleClient> jingle_client_; | 143 scoped_refptr<JingleClient> jingle_client_; |
144 | 144 |
145 scoped_refptr<protocol::SessionManager> session_manager_; | 145 scoped_refptr<protocol::SessionManager> session_manager_; |
146 | 146 |
147 // Objects that takes care of sending heartbeats to the chromoting bot. | 147 // Objects that takes care of sending heartbeats to the chromoting bot. |
148 scoped_refptr<HeartbeatSender> heartbeat_sender_; | 148 scoped_refptr<HeartbeatSender> heartbeat_sender_; |
149 | 149 |
150 AccessVerifier access_verifier_; | 150 AccessVerifier access_verifier_; |
151 | 151 |
152 // A ConnectionToClient manages the connectino to a remote client. | 152 // A ConnectionToClient manages the connectino to a remote client. |
153 // TODO(hclam): Expand this to a list of clients. | 153 // TODO(hclam): Expand this to a list of clients. |
154 scoped_refptr<protocol::ConnectionToClient> connection_; | 154 scoped_refptr<protocol::ConnectionToClient> connection_; |
155 | 155 |
156 // Session manager for the host process. | 156 // Session manager for the host process. |
157 scoped_refptr<SessionManager> session_; | 157 scoped_refptr<ScreenRecorder> recorder_; |
158 | 158 |
159 // This task gets executed when this object fails to connect to the | 159 // This task gets executed when this object fails to connect to the |
160 // talk network or Shutdown() is called. | 160 // talk network or Shutdown() is called. |
161 scoped_ptr<Task> shutdown_task_; | 161 scoped_ptr<Task> shutdown_task_; |
162 | 162 |
163 // Tracks the internal state of the host. | 163 // Tracks the internal state of the host. |
164 // This variable is written on the main thread of ChromotingHostContext | 164 // This variable is written on the main thread of ChromotingHostContext |
165 // and read by jingle thread. | 165 // and read by jingle thread. |
166 State state_; | 166 State state_; |
167 | 167 |
168 // Lock is to lock the access to |state_|. | 168 // Lock is to lock the access to |state_|. |
169 Lock lock_; | 169 Lock lock_; |
170 | 170 |
171 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 171 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
172 }; | 172 }; |
173 | 173 |
174 } // namespace remoting | 174 } // namespace remoting |
175 | 175 |
176 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 176 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |