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 "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "jingle/glue/thread_wrapper.h" | 16 #include "jingle/glue/thread_wrapper.h" |
17 #include "remoting/base/constants.h" | 17 #include "remoting/base/constants.h" |
18 #include "remoting/base/logging.h" | 18 #include "remoting/base/logging.h" |
19 #include "remoting/host/chromoting_host_context.h" | 19 #include "remoting/host/chromoting_host_context.h" |
20 #include "remoting/host/desktop_environment.h" | 20 #include "remoting/host/desktop_environment.h" |
21 #include "remoting/host/host_config.h" | 21 #include "remoting/host/host_config.h" |
22 #include "remoting/host/input_injector.h" | 22 #include "remoting/host/input_injector.h" |
23 #include "remoting/host/video_frame_recorder.h" | 23 #include "remoting/host/video_frame_recorder.h" |
24 #include "remoting/protocol/client_stub.h" | 24 #include "remoting/protocol/client_stub.h" |
25 #include "remoting/protocol/host_stub.h" | 25 #include "remoting/protocol/host_stub.h" |
26 #include "remoting/protocol/ice_connection_to_client.h" | 26 #include "remoting/protocol/ice_connection_to_client.h" |
27 #include "remoting/protocol/input_stub.h" | 27 #include "remoting/protocol/input_stub.h" |
| 28 #include "remoting/protocol/transport_context.h" |
28 #include "remoting/protocol/webrtc_connection_to_client.h" | 29 #include "remoting/protocol/webrtc_connection_to_client.h" |
29 | 30 |
30 using remoting::protocol::ConnectionToClient; | 31 using remoting::protocol::ConnectionToClient; |
31 using remoting::protocol::InputStub; | 32 using remoting::protocol::InputStub; |
32 | 33 |
33 namespace remoting { | 34 namespace remoting { |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { | 38 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { |
(...skipping 20 matching lines...) Expand all Loading... |
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 scoped_ptr<protocol::SessionManager> session_manager, |
| 69 scoped_refptr<protocol::TransportContext> transport_context, |
68 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 70 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
69 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 71 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
70 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, | 72 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
71 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, | 73 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, |
72 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 74 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
73 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 75 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
74 : desktop_environment_factory_(desktop_environment_factory), | 76 : desktop_environment_factory_(desktop_environment_factory), |
75 session_manager_(std::move(session_manager)), | 77 session_manager_(std::move(session_manager)), |
| 78 transport_context_(transport_context), |
76 audio_task_runner_(audio_task_runner), | 79 audio_task_runner_(audio_task_runner), |
77 input_task_runner_(input_task_runner), | 80 input_task_runner_(input_task_runner), |
78 video_capture_task_runner_(video_capture_task_runner), | 81 video_capture_task_runner_(video_capture_task_runner), |
79 video_encode_task_runner_(video_encode_task_runner), | 82 video_encode_task_runner_(video_encode_task_runner), |
80 network_task_runner_(network_task_runner), | 83 network_task_runner_(network_task_runner), |
81 ui_task_runner_(ui_task_runner), | 84 ui_task_runner_(ui_task_runner), |
82 started_(false), | 85 started_(false), |
83 login_backoff_(&kDefaultBackoffPolicy), | 86 login_backoff_(&kDefaultBackoffPolicy), |
84 enable_curtaining_(false), | 87 enable_curtaining_(false), |
85 weak_factory_(this) { | 88 weak_factory_(this) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 269 |
267 *response = protocol::SessionManager::ACCEPT; | 270 *response = protocol::SessionManager::ACCEPT; |
268 | 271 |
269 HOST_LOG << "Client connected: " << session->jid(); | 272 HOST_LOG << "Client connected: " << session->jid(); |
270 | 273 |
271 // Create either IceConnectionToClient or WebrtcConnectionToClient. | 274 // Create either IceConnectionToClient or WebrtcConnectionToClient. |
272 // TODO(sergeyu): Move this logic to the protocol layer. | 275 // TODO(sergeyu): Move this logic to the protocol layer. |
273 scoped_ptr<protocol::ConnectionToClient> connection; | 276 scoped_ptr<protocol::ConnectionToClient> connection; |
274 if (session->config().protocol() == | 277 if (session->config().protocol() == |
275 protocol::SessionConfig::Protocol::WEBRTC) { | 278 protocol::SessionConfig::Protocol::WEBRTC) { |
276 connection.reset( | 279 connection.reset(new protocol::WebrtcConnectionToClient( |
277 new protocol::WebrtcConnectionToClient(make_scoped_ptr(session))); | 280 make_scoped_ptr(session), transport_context_)); |
278 } else { | 281 } else { |
279 connection.reset(new protocol::IceConnectionToClient( | 282 connection.reset(new protocol::IceConnectionToClient( |
280 make_scoped_ptr(session), video_encode_task_runner_)); | 283 make_scoped_ptr(session), transport_context_, |
| 284 video_encode_task_runner_)); |
281 } | 285 } |
282 | 286 |
283 // Create a ClientSession object. | 287 // Create a ClientSession object. |
284 ClientSession* client = new ClientSession( | 288 ClientSession* client = new ClientSession( |
285 this, audio_task_runner_, input_task_runner_, video_capture_task_runner_, | 289 this, audio_task_runner_, input_task_runner_, video_capture_task_runner_, |
286 video_encode_task_runner_, network_task_runner_, ui_task_runner_, | 290 video_encode_task_runner_, network_task_runner_, ui_task_runner_, |
287 std::move(connection), desktop_environment_factory_, | 291 std::move(connection), desktop_environment_factory_, |
288 max_session_duration_, pairing_registry_, extensions_.get()); | 292 max_session_duration_, pairing_registry_, extensions_.get()); |
289 | 293 |
290 clients_.push_back(client); | 294 clients_.push_back(client); |
291 } | 295 } |
292 | 296 |
293 void ChromotingHost::DisconnectAllClients() { | 297 void ChromotingHost::DisconnectAllClients() { |
294 DCHECK(CalledOnValidThread()); | 298 DCHECK(CalledOnValidThread()); |
295 | 299 |
296 while (!clients_.empty()) { | 300 while (!clients_.empty()) { |
297 size_t size = clients_.size(); | 301 size_t size = clients_.size(); |
298 clients_.front()->DisconnectSession(protocol::OK); | 302 clients_.front()->DisconnectSession(protocol::OK); |
299 CHECK_EQ(clients_.size(), size - 1); | 303 CHECK_EQ(clients_.size(), size - 1); |
300 } | 304 } |
301 } | 305 } |
302 | 306 |
303 } // namespace remoting | 307 } // namespace remoting |
OLD | NEW |