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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "jingle/glue/thread_wrapper.h" | 13 #include "jingle/glue/thread_wrapper.h" |
14 #include "remoting/base/constants.h" | 14 #include "remoting/base/constants.h" |
15 #include "remoting/base/logging.h" | 15 #include "remoting/base/logging.h" |
16 #include "remoting/host/chromoting_host_context.h" | 16 #include "remoting/host/chromoting_host_context.h" |
17 #include "remoting/host/desktop_environment.h" | 17 #include "remoting/host/desktop_environment.h" |
18 #include "remoting/host/host_config.h" | 18 #include "remoting/host/host_config.h" |
19 #include "remoting/host/input_injector.h" | 19 #include "remoting/host/input_injector.h" |
20 #include "remoting/host/video_frame_recorder.h" | 20 #include "remoting/host/video_frame_recorder.h" |
21 #include "remoting/protocol/client_stub.h" | 21 #include "remoting/protocol/client_stub.h" |
22 #include "remoting/protocol/host_stub.h" | 22 #include "remoting/protocol/host_stub.h" |
23 #include "remoting/protocol/ice_connection_to_client.h" | 23 #include "remoting/protocol/ice_connection_to_client.h" |
24 #include "remoting/protocol/input_stub.h" | 24 #include "remoting/protocol/input_stub.h" |
| 25 #include "remoting/protocol/webrtc_connection_to_client.h" |
25 | 26 |
26 using remoting::protocol::ConnectionToClient; | 27 using remoting::protocol::ConnectionToClient; |
27 using remoting::protocol::InputStub; | 28 using remoting::protocol::InputStub; |
28 | 29 |
29 namespace remoting { | 30 namespace remoting { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { | 34 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { |
34 // Number of initial errors (in sequence) to ignore before applying | 35 // Number of initial errors (in sequence) to ignore before applying |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 LOG(WARNING) << "Rejecting connection due to" | 267 LOG(WARNING) << "Rejecting connection due to" |
267 " an overload of failed login attempts."; | 268 " an overload of failed login attempts."; |
268 *response = protocol::SessionManager::OVERLOAD; | 269 *response = protocol::SessionManager::OVERLOAD; |
269 return; | 270 return; |
270 } | 271 } |
271 | 272 |
272 *response = protocol::SessionManager::ACCEPT; | 273 *response = protocol::SessionManager::ACCEPT; |
273 | 274 |
274 HOST_LOG << "Client connected: " << session->jid(); | 275 HOST_LOG << "Client connected: " << session->jid(); |
275 | 276 |
276 // Create a client object. | 277 // Create either IceConnectionToClient or WebrtcConnectionToClient. |
277 scoped_ptr<protocol::ConnectionToClient> connection( | 278 // TODO(sergeyu): Move this logic to the protocol layer. |
278 new protocol::IceConnectionToClient(make_scoped_ptr(session), | 279 scoped_ptr<protocol::ConnectionToClient> connection; |
279 video_encode_task_runner_)); | 280 if (session->config().protocol() == |
| 281 protocol::SessionConfig::Protocol::WEBRTC) { |
| 282 connection.reset( |
| 283 new protocol::WebrtcConnectionToClient(make_scoped_ptr(session))); |
| 284 } else { |
| 285 connection.reset(new protocol::IceConnectionToClient( |
| 286 make_scoped_ptr(session), video_encode_task_runner_)); |
| 287 } |
| 288 |
| 289 // Create a ClientSession object. |
280 ClientSession* client = new ClientSession( | 290 ClientSession* client = new ClientSession( |
281 this, | 291 this, audio_task_runner_, input_task_runner_, video_capture_task_runner_, |
282 audio_task_runner_, | 292 video_encode_task_runner_, network_task_runner_, ui_task_runner_, |
283 input_task_runner_, | 293 connection.Pass(), desktop_environment_factory_, max_session_duration_, |
284 video_capture_task_runner_, | 294 pairing_registry_, extensions_.get()); |
285 video_encode_task_runner_, | |
286 network_task_runner_, | |
287 ui_task_runner_, | |
288 connection.Pass(), | |
289 desktop_environment_factory_, | |
290 max_session_duration_, | |
291 pairing_registry_, | |
292 extensions_.get()); | |
293 | 295 |
294 clients_.push_back(client); | 296 clients_.push_back(client); |
295 } | 297 } |
296 | 298 |
297 void ChromotingHost::DisconnectAllClients() { | 299 void ChromotingHost::DisconnectAllClients() { |
298 DCHECK(CalledOnValidThread()); | 300 DCHECK(CalledOnValidThread()); |
299 | 301 |
300 while (!clients_.empty()) { | 302 while (!clients_.empty()) { |
301 size_t size = clients_.size(); | 303 size_t size = clients_.size(); |
302 clients_.front()->DisconnectSession(protocol::OK); | 304 clients_.front()->DisconnectSession(protocol::OK); |
303 CHECK_EQ(clients_.size(), size - 1); | 305 CHECK_EQ(clients_.size(), size - 1); |
304 } | 306 } |
305 } | 307 } |
306 | 308 |
307 } // namespace remoting | 309 } // namespace remoting |
OLD | NEW |