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 <list> | |
9 #include <memory> | 8 #include <memory> |
10 #include <string> | 9 #include <string> |
| 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "net/base/backoff_entry.h" | 19 #include "net/base/backoff_entry.h" |
20 #include "remoting/host/client_session.h" | 20 #include "remoting/host/client_session.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // | 59 // |
60 // 3. When the user is disconnected, we will pause the ScreenRecorder | 60 // 3. When the user is disconnected, we will pause the ScreenRecorder |
61 // and try to terminate the threads we have created. This will allow | 61 // and try to terminate the threads we have created. This will allow |
62 // all pending tasks to complete. After all of that completed we | 62 // all pending tasks to complete. After all of that completed we |
63 // return to the idle state. We then go to step (2) if there a new | 63 // return to the idle state. We then go to step (2) if there a new |
64 // incoming connection. | 64 // incoming connection. |
65 class ChromotingHost : public base::NonThreadSafe, | 65 class ChromotingHost : public base::NonThreadSafe, |
66 public ClientSession::EventHandler, | 66 public ClientSession::EventHandler, |
67 public HostStatusMonitor { | 67 public HostStatusMonitor { |
68 public: | 68 public: |
| 69 typedef std::vector<std::unique_ptr<ClientSession>> ClientSessions; |
| 70 |
69 // |desktop_environment_factory| must outlive this object. | 71 // |desktop_environment_factory| must outlive this object. |
70 ChromotingHost( | 72 ChromotingHost( |
71 DesktopEnvironmentFactory* desktop_environment_factory, | 73 DesktopEnvironmentFactory* desktop_environment_factory, |
72 std::unique_ptr<protocol::SessionManager> session_manager, | 74 std::unique_ptr<protocol::SessionManager> session_manager, |
73 scoped_refptr<protocol::TransportContext> transport_context, | 75 scoped_refptr<protocol::TransportContext> transport_context, |
74 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 76 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
75 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner); | 77 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner); |
76 ~ChromotingHost() override; | 78 ~ChromotingHost() override; |
77 | 79 |
78 // Asynchronously starts the host. | 80 // Asynchronously starts the host. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // The host uses a pairing registry to generate and store pairing information | 128 // The host uses a pairing registry to generate and store pairing information |
127 // for clients for PIN-less authentication. | 129 // for clients for PIN-less authentication. |
128 scoped_refptr<protocol::PairingRegistry> pairing_registry() const { | 130 scoped_refptr<protocol::PairingRegistry> pairing_registry() const { |
129 return pairing_registry_; | 131 return pairing_registry_; |
130 } | 132 } |
131 void set_pairing_registry( | 133 void set_pairing_registry( |
132 scoped_refptr<protocol::PairingRegistry> pairing_registry) { | 134 scoped_refptr<protocol::PairingRegistry> pairing_registry) { |
133 pairing_registry_ = pairing_registry; | 135 pairing_registry_ = pairing_registry; |
134 } | 136 } |
135 | 137 |
| 138 const ClientSessions& client_sessions_for_tests() { return clients_; } |
| 139 |
136 base::WeakPtr<ChromotingHost> AsWeakPtr() { | 140 base::WeakPtr<ChromotingHost> AsWeakPtr() { |
137 return weak_factory_.GetWeakPtr(); | 141 return weak_factory_.GetWeakPtr(); |
138 } | 142 } |
139 | 143 |
140 private: | 144 private: |
141 friend class ChromotingHostTest; | 145 friend class ChromotingHostTest; |
142 | 146 |
143 typedef std::list<ClientSession*> ClientList; | |
144 typedef ScopedVector<HostExtension> HostExtensionList; | 147 typedef ScopedVector<HostExtension> HostExtensionList; |
145 | 148 |
146 // Immediately disconnects all active clients. Host-internal components may | 149 // Immediately disconnects all active clients. Host-internal components may |
147 // shutdown asynchronously, but the caller is guaranteed not to receive | 150 // shutdown asynchronously, but the caller is guaranteed not to receive |
148 // callbacks for disconnected clients after this call returns. | 151 // callbacks for disconnected clients after this call returns. |
149 void DisconnectAllClients(); | 152 void DisconnectAllClients(); |
150 | 153 |
151 // Unless specified otherwise all members of this class must be | 154 // Unless specified otherwise all members of this class must be |
152 // used on the network thread only. | 155 // used on the network thread only. |
153 | 156 |
154 // Parameters specified when the host was created. | 157 // Parameters specified when the host was created. |
155 DesktopEnvironmentFactory* desktop_environment_factory_; | 158 DesktopEnvironmentFactory* desktop_environment_factory_; |
156 std::unique_ptr<protocol::SessionManager> session_manager_; | 159 std::unique_ptr<protocol::SessionManager> session_manager_; |
157 scoped_refptr<protocol::TransportContext> transport_context_; | 160 scoped_refptr<protocol::TransportContext> transport_context_; |
158 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; | 161 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; |
159 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_; | 162 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_; |
160 | 163 |
161 // Must be used on the network thread only. | 164 // Must be used on the network thread only. |
162 base::ObserverList<HostStatusObserver> status_observers_; | 165 base::ObserverList<HostStatusObserver> status_observers_; |
163 | 166 |
164 // The connections to remote clients. | 167 // The connections to remote clients. |
165 ClientList clients_; | 168 ClientSessions clients_; |
166 | 169 |
167 // True if the host has been started. | 170 // True if the host has been started. |
168 bool started_; | 171 bool started_; |
169 | 172 |
170 // Login backoff state. | 173 // Login backoff state. |
171 net::BackoffEntry login_backoff_; | 174 net::BackoffEntry login_backoff_; |
172 | 175 |
173 // True if the curtain mode is enabled. | 176 // True if the curtain mode is enabled. |
174 bool enable_curtaining_; | 177 bool enable_curtaining_; |
175 | 178 |
176 // The maximum duration of any session. | 179 // The maximum duration of any session. |
177 base::TimeDelta max_session_duration_; | 180 base::TimeDelta max_session_duration_; |
178 | 181 |
179 // The pairing registry for PIN-less authentication. | 182 // The pairing registry for PIN-less authentication. |
180 scoped_refptr<protocol::PairingRegistry> pairing_registry_; | 183 scoped_refptr<protocol::PairingRegistry> pairing_registry_; |
181 | 184 |
182 // List of host extensions. | 185 // List of host extensions. |
183 HostExtensionList extensions_; | 186 HostExtensionList extensions_; |
184 | 187 |
185 base::WeakPtrFactory<ChromotingHost> weak_factory_; | 188 base::WeakPtrFactory<ChromotingHost> weak_factory_; |
186 | 189 |
187 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 190 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
188 }; | 191 }; |
189 | 192 |
190 } // namespace remoting | 193 } // namespace remoting |
191 | 194 |
192 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 195 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |