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 #include "remoting/host/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/memory/ptr_util.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "jingle/glue/thread_wrapper.h" | 17 #include "jingle/glue/thread_wrapper.h" |
17 #include "remoting/base/constants.h" | 18 #include "remoting/base/constants.h" |
18 #include "remoting/base/logging.h" | 19 #include "remoting/base/logging.h" |
19 #include "remoting/host/chromoting_host_context.h" | 20 #include "remoting/host/chromoting_host_context.h" |
20 #include "remoting/host/desktop_environment.h" | 21 #include "remoting/host/desktop_environment.h" |
21 #include "remoting/host/host_config.h" | 22 #include "remoting/host/host_config.h" |
22 #include "remoting/host/input_injector.h" | 23 #include "remoting/host/input_injector.h" |
23 #include "remoting/protocol/client_stub.h" | 24 #include "remoting/protocol/client_stub.h" |
24 #include "remoting/protocol/host_stub.h" | 25 #include "remoting/protocol/host_stub.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 -1, | 58 -1, |
58 | 59 |
59 // Don't use initial delay unless the last request was an error. | 60 // Don't use initial delay unless the last request was an error. |
60 false, | 61 false, |
61 }; | 62 }; |
62 | 63 |
63 } // namespace | 64 } // namespace |
64 | 65 |
65 ChromotingHost::ChromotingHost( | 66 ChromotingHost::ChromotingHost( |
66 DesktopEnvironmentFactory* desktop_environment_factory, | 67 DesktopEnvironmentFactory* desktop_environment_factory, |
67 scoped_ptr<protocol::SessionManager> session_manager, | 68 std::unique_ptr<protocol::SessionManager> session_manager, |
68 scoped_refptr<protocol::TransportContext> transport_context, | 69 scoped_refptr<protocol::TransportContext> transport_context, |
69 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 70 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
70 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) | 71 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) |
71 : desktop_environment_factory_(desktop_environment_factory), | 72 : desktop_environment_factory_(desktop_environment_factory), |
72 session_manager_(std::move(session_manager)), | 73 session_manager_(std::move(session_manager)), |
73 transport_context_(transport_context), | 74 transport_context_(transport_context), |
74 audio_task_runner_(audio_task_runner), | 75 audio_task_runner_(audio_task_runner), |
75 video_encode_task_runner_(video_encode_task_runner), | 76 video_encode_task_runner_(video_encode_task_runner), |
76 started_(false), | 77 started_(false), |
77 login_backoff_(&kDefaultBackoffPolicy), | 78 login_backoff_(&kDefaultBackoffPolicy), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { | 114 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { |
114 DCHECK(CalledOnValidThread()); | 115 DCHECK(CalledOnValidThread()); |
115 status_observers_.AddObserver(observer); | 116 status_observers_.AddObserver(observer); |
116 } | 117 } |
117 | 118 |
118 void ChromotingHost::RemoveStatusObserver(HostStatusObserver* observer) { | 119 void ChromotingHost::RemoveStatusObserver(HostStatusObserver* observer) { |
119 DCHECK(CalledOnValidThread()); | 120 DCHECK(CalledOnValidThread()); |
120 status_observers_.RemoveObserver(observer); | 121 status_observers_.RemoveObserver(observer); |
121 } | 122 } |
122 | 123 |
123 void ChromotingHost::AddExtension(scoped_ptr<HostExtension> extension) { | 124 void ChromotingHost::AddExtension(std::unique_ptr<HostExtension> extension) { |
124 extensions_.push_back(extension.release()); | 125 extensions_.push_back(extension.release()); |
125 } | 126 } |
126 | 127 |
127 void ChromotingHost::SetAuthenticatorFactory( | 128 void ChromotingHost::SetAuthenticatorFactory( |
128 scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory) { | 129 std::unique_ptr<protocol::AuthenticatorFactory> authenticator_factory) { |
129 DCHECK(CalledOnValidThread()); | 130 DCHECK(CalledOnValidThread()); |
130 session_manager_->set_authenticator_factory(std::move(authenticator_factory)); | 131 session_manager_->set_authenticator_factory(std::move(authenticator_factory)); |
131 } | 132 } |
132 | 133 |
133 void ChromotingHost::SetEnableCurtaining(bool enable) { | 134 void ChromotingHost::SetEnableCurtaining(bool enable) { |
134 DCHECK(CalledOnValidThread()); | 135 DCHECK(CalledOnValidThread()); |
135 | 136 |
136 if (enable_curtaining_ == enable) | 137 if (enable_curtaining_ == enable) |
137 return; | 138 return; |
138 | 139 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 *response = protocol::SessionManager::OVERLOAD; | 256 *response = protocol::SessionManager::OVERLOAD; |
256 return; | 257 return; |
257 } | 258 } |
258 | 259 |
259 *response = protocol::SessionManager::ACCEPT; | 260 *response = protocol::SessionManager::ACCEPT; |
260 | 261 |
261 HOST_LOG << "Client connected: " << session->jid(); | 262 HOST_LOG << "Client connected: " << session->jid(); |
262 | 263 |
263 // Create either IceConnectionToClient or WebrtcConnectionToClient. | 264 // Create either IceConnectionToClient or WebrtcConnectionToClient. |
264 // TODO(sergeyu): Move this logic to the protocol layer. | 265 // TODO(sergeyu): Move this logic to the protocol layer. |
265 scoped_ptr<protocol::ConnectionToClient> connection; | 266 std::unique_ptr<protocol::ConnectionToClient> connection; |
266 if (session->config().protocol() == | 267 if (session->config().protocol() == |
267 protocol::SessionConfig::Protocol::WEBRTC) { | 268 protocol::SessionConfig::Protocol::WEBRTC) { |
268 connection.reset(new protocol::WebrtcConnectionToClient( | 269 connection.reset(new protocol::WebrtcConnectionToClient( |
269 make_scoped_ptr(session), transport_context_)); | 270 base::WrapUnique(session), transport_context_)); |
270 } else { | 271 } else { |
271 connection.reset(new protocol::IceConnectionToClient( | 272 connection.reset(new protocol::IceConnectionToClient( |
272 make_scoped_ptr(session), transport_context_, | 273 base::WrapUnique(session), transport_context_, |
273 video_encode_task_runner_)); | 274 video_encode_task_runner_)); |
274 } | 275 } |
275 | 276 |
276 // Create a ClientSession object. | 277 // Create a ClientSession object. |
277 ClientSession* client = | 278 ClientSession* client = |
278 new ClientSession(this, audio_task_runner_, std::move(connection), | 279 new ClientSession(this, audio_task_runner_, std::move(connection), |
279 desktop_environment_factory_, max_session_duration_, | 280 desktop_environment_factory_, max_session_duration_, |
280 pairing_registry_, extensions_.get()); | 281 pairing_registry_, extensions_.get()); |
281 | 282 |
282 clients_.push_back(client); | 283 clients_.push_back(client); |
283 } | 284 } |
284 | 285 |
285 void ChromotingHost::DisconnectAllClients() { | 286 void ChromotingHost::DisconnectAllClients() { |
286 DCHECK(CalledOnValidThread()); | 287 DCHECK(CalledOnValidThread()); |
287 | 288 |
288 while (!clients_.empty()) { | 289 while (!clients_.empty()) { |
289 size_t size = clients_.size(); | 290 size_t size = clients_.size(); |
290 clients_.front()->DisconnectSession(protocol::OK); | 291 clients_.front()->DisconnectSession(protocol::OK); |
291 CHECK_EQ(clients_.size(), size - 1); | 292 CHECK_EQ(clients_.size(), size - 1); |
292 } | 293 } |
293 } | 294 } |
294 | 295 |
295 } // namespace remoting | 296 } // namespace remoting |
OLD | NEW |