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/client_connection.h" | 14 #include "remoting/host/client_connection.h" |
15 #include "remoting/host/event_executor.h" | 15 #include "remoting/host/event_executor.h" |
16 #include "remoting/host/heartbeat_sender.h" | 16 #include "remoting/host/heartbeat_sender.h" |
17 #include "remoting/jingle_glue/jingle_client.h" | 17 #include "remoting/jingle_glue/jingle_client.h" |
18 #include "remoting/jingle_glue/jingle_thread.h" | 18 #include "remoting/jingle_glue/jingle_thread.h" |
19 #include "remoting/protocol/chromotocol_server.h" | 19 #include "remoting/protocol/chromotocol_server.h" |
20 | 20 |
21 class Task; | 21 class Task; |
22 | 22 |
23 namespace remoting { | 23 namespace remoting { |
24 | 24 |
25 class Capturer; | 25 class Capturer; |
26 class ChromotingHostContext; | 26 class ChromotingHostContext; |
| 27 class ChromotocolConfig; |
27 class Encoder; | 28 class Encoder; |
28 class EventExecutor; | 29 class EventExecutor; |
29 class MutableHostConfig; | 30 class MutableHostConfig; |
30 class SessionManager; | 31 class SessionManager; |
31 | 32 |
32 // A class to implement the functionality of a host process. | 33 // A class to implement the functionality of a host process. |
33 // | 34 // |
34 // Here's the work flow of this class: | 35 // Here's the work flow of this class: |
35 // 1. We should load the saved GAIA ID token or if this is the first | 36 // 1. We should load the saved GAIA ID token or if this is the first |
36 // time the host process runs we should prompt user for the | 37 // time the host process runs we should prompt user for the |
(...skipping 15 matching lines...) Expand all Loading... |
52 // 3. When the user is disconencted, we will pause the SessionManager | 53 // 3. When the user is disconencted, we will pause the SessionManager |
53 // and try to terminate the threads we have created. This will allow | 54 // and try to terminate the threads we have created. This will allow |
54 // all pending tasks to complete. After all of that completed we | 55 // all pending tasks to complete. After all of that completed we |
55 // return to the idle state. We then go to step (2) if there a new | 56 // return to the idle state. We then go to step (2) if there a new |
56 // incoming connection. | 57 // incoming connection. |
57 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 58 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
58 public ClientConnection::EventHandler, | 59 public ClientConnection::EventHandler, |
59 public JingleClient::Callback { | 60 public JingleClient::Callback { |
60 public: | 61 public: |
61 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, | 62 ChromotingHost(ChromotingHostContext* context, MutableHostConfig* config, |
62 Capturer* capturer, Encoder* encoder, EventExecutor* executor); | 63 Capturer* capturer, EventExecutor* executor); |
63 virtual ~ChromotingHost(); | 64 virtual ~ChromotingHost(); |
64 | 65 |
65 // Asynchronously start the host process. | 66 // Asynchronously start the host process. |
66 // | 67 // |
67 // After this is invoked, the host process will connect to the talk | 68 // After this is invoked, the host process will connect to the talk |
68 // network and start listening for incoming connections. | 69 // network and start listening for incoming connections. |
69 // | 70 // |
70 // |shutdown_task| is called if Start() has failed ot Shutdown() is called | 71 // |shutdown_task| is called if Start() has failed ot Shutdown() is called |
71 // and all related operations are completed. | 72 // and all related operations are completed. |
72 // | 73 // |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 kStopped, | 107 kStopped, |
107 }; | 108 }; |
108 | 109 |
109 // This method connects to the talk network and start listening for incoming | 110 // This method connects to the talk network and start listening for incoming |
110 // connections. | 111 // connections. |
111 void DoStart(Task* shutdown_task); | 112 void DoStart(Task* shutdown_task); |
112 | 113 |
113 // Callback for ChromotocolServer::Close(). | 114 // Callback for ChromotocolServer::Close(). |
114 void OnServerClosed(); | 115 void OnServerClosed(); |
115 | 116 |
| 117 // Creates encoder for the specified configuration. |
| 118 Encoder* CreateEncoder(const ChromotocolConfig* config); |
| 119 |
116 // The context that the chromoting host runs on. | 120 // The context that the chromoting host runs on. |
117 ChromotingHostContext* context_; | 121 ChromotingHostContext* context_; |
118 | 122 |
119 scoped_refptr<MutableHostConfig> config_; | 123 scoped_refptr<MutableHostConfig> config_; |
120 | 124 |
121 // Capturer to be used by SessionManager. Once the SessionManager is | 125 // Capturer to be used by SessionManager. Once the SessionManager is |
122 // constructed this is set to NULL. | 126 // constructed this is set to NULL. |
123 scoped_ptr<Capturer> capturer_; | 127 scoped_ptr<Capturer> capturer_; |
124 | 128 |
125 // Encoder to be used by the SessionManager. Once the SessionManager is | |
126 // constructed this is set to NULL. | 129 // constructed this is set to NULL. |
127 scoped_ptr<Encoder> encoder_; | 130 scoped_ptr<Encoder> encoder_; |
128 | 131 |
129 // EventExecutor executes input events received from the client. | 132 // EventExecutor executes input events received from the client. |
130 scoped_ptr<EventExecutor> executor_; | 133 scoped_ptr<EventExecutor> executor_; |
131 | 134 |
132 // The libjingle client. This is used to connect to the talk network to | 135 // The libjingle client. This is used to connect to the talk network to |
133 // receive connection requests from chromoting client. | 136 // receive connection requests from chromoting client. |
134 scoped_refptr<JingleClient> jingle_client_; | 137 scoped_refptr<JingleClient> jingle_client_; |
135 | 138 |
(...skipping 22 matching lines...) Expand all Loading... |
158 | 161 |
159 // Lock is to lock the access to |state_|. | 162 // Lock is to lock the access to |state_|. |
160 Lock lock_; | 163 Lock lock_; |
161 | 164 |
162 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 165 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
163 }; | 166 }; |
164 | 167 |
165 } // namespace remoting | 168 } // namespace remoting |
166 | 169 |
167 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 170 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |