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" |
11 #include "remoting/base/encoder.h" | 11 #include "remoting/base/encoder.h" |
12 #include "remoting/host/access_verifier.h" | 12 #include "remoting/host/access_verifier.h" |
13 #include "remoting/host/capturer.h" | 13 #include "remoting/host/capturer.h" |
14 #include "remoting/host/event_executor.h" | |
15 #include "remoting/host/heartbeat_sender.h" | 14 #include "remoting/host/heartbeat_sender.h" |
16 #include "remoting/jingle_glue/jingle_client.h" | 15 #include "remoting/jingle_glue/jingle_client.h" |
17 #include "remoting/jingle_glue/jingle_thread.h" | 16 #include "remoting/jingle_glue/jingle_thread.h" |
17 #include "remoting/protocol/input_stub.h" | |
18 #include "remoting/protocol/session_manager.h" | 18 #include "remoting/protocol/session_manager.h" |
19 #include "remoting/protocol/connection_to_client.h" | 19 #include "remoting/protocol/connection_to_client.h" |
20 | 20 |
21 class Task; | 21 class Task; |
22 | 22 |
23 namespace remoting { | 23 namespace remoting { |
24 | 24 |
25 namespace protocol { | 25 namespace protocol { |
26 class ConnectionToClient; | 26 class ConnectionToClient; |
27 class SessionConfig; | 27 class SessionConfig; |
28 } // namespace protocol | 28 } // namespace protocol |
29 | 29 |
30 class Capturer; | 30 class Capturer; |
31 class ChromotingHostContext; | 31 class ChromotingHostContext; |
32 class Encoder; | 32 class Encoder; |
33 class EventExecutor; | |
34 class MutableHostConfig; | 33 class MutableHostConfig; |
35 class SessionManager; | 34 class SessionManager; |
36 | 35 |
37 // A class to implement the functionality of a host process. | 36 // A class to implement the functionality of a host process. |
38 // | 37 // |
39 // Here's the work flow of this class: | 38 // Here's the work flow of this class: |
40 // 1. We should load the saved GAIA ID token or if this is the first | 39 // 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 | 40 // time the host process runs we should prompt user for the |
42 // credential. We will use this token or credentials to authenicate | 41 // credential. We will use this token or credentials to authenicate |
43 // and register the host. | 42 // and register the host. |
44 // | 43 // |
45 // 2. We listen for incoming connection using libjingle. We will create | 44 // 2. We listen for incoming connection using libjingle. We will create |
46 // a ConnectionToClient object that wraps around linjingle for transport. | 45 // a ConnectionToClient object that wraps around linjingle for transport. |
47 // Also create a SessionManager with appropriate Encoder and Capturer and | 46 // Also create a SessionManager with appropriate Encoder and Capturer and |
48 // add the ConnectionToClient to this SessionManager for transporting the | 47 // add the ConnectionToClient to this SessionManager for transporting the |
49 // screen captures. A EventExecutor is created and registered with the | 48 // screen captures. An InputStub is created and registered with the |
50 // ConnectionToClient to receive mouse / keyboard events from the remote | 49 // ConnectionToClient to receive mouse / keyboard events from the remote |
51 // client. | 50 // client. |
52 // This is also the right time to create multiple threads to host | 51 // This is also the right time to create multiple threads to host |
53 // the above objects. After we have done all the initialization | 52 // the above objects. After we have done all the initialization |
54 // we'll start the SessionManager. We'll then enter the running state | 53 // we'll start the SessionManager. We'll then enter the running state |
55 // of the host process. | 54 // of the host process. |
56 // | 55 // |
57 // 3. When the user is disconencted, we will pause the SessionManager | 56 // 3. When the user is disconencted, we will pause the SessionManager |
58 // and try to terminate the threads we have created. This will allow | 57 // and try to terminate the threads we have created. This will allow |
59 // all pending tasks to complete. After all of that completed we | 58 // 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 | 59 // return to the idle state. We then go to step (2) if there a new |
61 // incoming connection. | 60 // incoming connection. |
62 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 61 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
63 public protocol::ConnectionToClient::EventHandler, | 62 public protocol::ConnectionToClient::EventHandler, |
64 public JingleClient::Callback { | 63 public JingleClient::Callback { |
65 public: | 64 public: |
66 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, | 65 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, |
67 Capturer* capturer, EventExecutor* executor); | 66 Capturer* capturer, protocol::InputStub* input_stub); |
awong
2010/11/10 19:36:54
I feel like the ChromotingHost should actually kee
Sergey Ulanov
2010/11/10 20:14:21
How EventExecutor would be different from InputStu
Alpha Left Google
2010/11/12 20:08:01
Getting rid of EventExecutor and shift to use Inpu
| |
68 virtual ~ChromotingHost(); | 67 virtual ~ChromotingHost(); |
69 | 68 |
70 // Asynchronously start the host process. | 69 // Asynchronously start the host process. |
71 // | 70 // |
72 // After this is invoked, the host process will connect to the talk | 71 // After this is invoked, the host process will connect to the talk |
73 // network and start listening for incoming connections. | 72 // network and start listening for incoming connections. |
74 // | 73 // |
75 // |shutdown_task| is called if Start() has failed ot Shutdown() is called | 74 // |shutdown_task| is called if Start() has failed ot Shutdown() is called |
76 // and all related operations are completed. | 75 // and all related operations are completed. |
77 // | 76 // |
78 // This method can only be called once during the lifetime of this object. | 77 // This method can only be called once during the lifetime of this object. |
79 void Start(Task* shutdown_task); | 78 void Start(Task* shutdown_task); |
80 | 79 |
81 // Asynchronously shutdown the host process. | 80 // Asynchronously shutdown the host process. |
82 void Shutdown(); | 81 void Shutdown(); |
83 | 82 |
84 // This method is called if a client is connected to this object. | 83 // This method is called if a client is connected to this object. |
85 void OnClientConnected(protocol::ConnectionToClient* client); | 84 void OnClientConnected(protocol::ConnectionToClient* client); |
86 | 85 |
87 // This method is called if a client is disconnected from the host. | 86 // This method is called if a client is disconnected from the host. |
88 void OnClientDisconnected(protocol::ConnectionToClient* client); | 87 void OnClientDisconnected(protocol::ConnectionToClient* client); |
89 | 88 |
90 //////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////// |
91 // protocol::ConnectionToClient::EventHandler implementations | 90 // protocol::ConnectionToClient::EventHandler implementations |
92 virtual void HandleMessage(protocol::ConnectionToClient* client, | |
93 ChromotingClientMessage* message); | |
94 virtual void OnConnectionOpened(protocol::ConnectionToClient* client); | 91 virtual void OnConnectionOpened(protocol::ConnectionToClient* client); |
95 virtual void OnConnectionClosed(protocol::ConnectionToClient* client); | 92 virtual void OnConnectionClosed(protocol::ConnectionToClient* client); |
96 virtual void OnConnectionFailed(protocol::ConnectionToClient* client); | 93 virtual void OnConnectionFailed(protocol::ConnectionToClient* client); |
97 | 94 |
98 //////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////// |
99 // JingleClient::Callback implementations | 96 // JingleClient::Callback implementations |
100 virtual void OnStateChange(JingleClient* client, JingleClient::State state); | 97 virtual void OnStateChange(JingleClient* client, JingleClient::State state); |
101 | 98 |
102 // Callback for ChromotingServer. | 99 // Callback for ChromotingServer. |
103 void OnNewClientSession( | 100 void OnNewClientSession( |
(...skipping 22 matching lines...) Expand all Loading... | |
126 | 123 |
127 scoped_refptr<MutableHostConfig> config_; | 124 scoped_refptr<MutableHostConfig> config_; |
128 | 125 |
129 // Capturer to be used by SessionManager. Once the SessionManager is | 126 // Capturer to be used by SessionManager. Once the SessionManager is |
130 // constructed this is set to NULL. | 127 // constructed this is set to NULL. |
131 scoped_ptr<Capturer> capturer_; | 128 scoped_ptr<Capturer> capturer_; |
132 | 129 |
133 // constructed this is set to NULL. | 130 // constructed this is set to NULL. |
134 scoped_ptr<Encoder> encoder_; | 131 scoped_ptr<Encoder> encoder_; |
135 | 132 |
136 // EventExecutor executes input events received from the client. | 133 // InputStub in the host executes input events received from the client. |
137 scoped_ptr<EventExecutor> executor_; | 134 scoped_ptr<protocol::InputStub> input_stub_; |
Sergey Ulanov
2010/11/10 20:14:21
event_executor_?
Alpha Left Google
2010/11/12 20:08:01
It will be merged with capturer so reference them
| |
138 | 135 |
139 // The libjingle client. This is used to connect to the talk network to | 136 // The libjingle client. This is used to connect to the talk network to |
140 // receive connection requests from chromoting client. | 137 // receive connection requests from chromoting client. |
141 scoped_refptr<JingleClient> jingle_client_; | 138 scoped_refptr<JingleClient> jingle_client_; |
142 | 139 |
143 scoped_refptr<protocol::SessionManager> session_manager_; | 140 scoped_refptr<protocol::SessionManager> session_manager_; |
144 | 141 |
145 // Objects that takes care of sending heartbeats to the chromoting bot. | 142 // Objects that takes care of sending heartbeats to the chromoting bot. |
146 scoped_refptr<HeartbeatSender> heartbeat_sender_; | 143 scoped_refptr<HeartbeatSender> heartbeat_sender_; |
147 | 144 |
(...skipping 17 matching lines...) Expand all Loading... | |
165 | 162 |
166 // Lock is to lock the access to |state_|. | 163 // Lock is to lock the access to |state_|. |
167 Lock lock_; | 164 Lock lock_; |
168 | 165 |
169 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 166 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
170 }; | 167 }; |
171 | 168 |
172 } // namespace remoting | 169 } // namespace remoting |
173 | 170 |
174 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 171 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |