| 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> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // 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. |
| 61 false, | 61 false, |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 ChromotingHost::ChromotingHost( | 66 ChromotingHost::ChromotingHost( |
| 67 DesktopEnvironmentFactory* desktop_environment_factory, | 67 DesktopEnvironmentFactory* desktop_environment_factory, |
| 68 scoped_ptr<protocol::SessionManager> session_manager, | 68 scoped_ptr<protocol::SessionManager> session_manager, |
| 69 scoped_refptr<protocol::TransportContext> transport_context, | 69 scoped_refptr<protocol::TransportContext> ice_transport_context, |
| 70 scoped_refptr<protocol::TransportContext> webrtc_transport_context, |
| 70 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 71 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 71 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) | 72 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner) |
| 72 : desktop_environment_factory_(desktop_environment_factory), | 73 : desktop_environment_factory_(desktop_environment_factory), |
| 73 session_manager_(std::move(session_manager)), | 74 session_manager_(std::move(session_manager)), |
| 74 transport_context_(transport_context), | 75 ice_transport_context_(ice_transport_context), |
| 76 webrtc_transport_context_(webrtc_transport_context), |
| 75 audio_task_runner_(audio_task_runner), | 77 audio_task_runner_(audio_task_runner), |
| 76 video_encode_task_runner_(video_encode_task_runner), | 78 video_encode_task_runner_(video_encode_task_runner), |
| 77 started_(false), | 79 started_(false), |
| 78 login_backoff_(&kDefaultBackoffPolicy), | 80 login_backoff_(&kDefaultBackoffPolicy), |
| 79 enable_curtaining_(false), | 81 enable_curtaining_(false), |
| 80 weak_factory_(this) { | 82 weak_factory_(this) { |
| 81 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 83 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 ChromotingHost::~ChromotingHost() { | 86 ChromotingHost::~ChromotingHost() { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 *response = protocol::SessionManager::ACCEPT; | 262 *response = protocol::SessionManager::ACCEPT; |
| 261 | 263 |
| 262 HOST_LOG << "Client connected: " << session->jid(); | 264 HOST_LOG << "Client connected: " << session->jid(); |
| 263 | 265 |
| 264 // Create either IceConnectionToClient or WebrtcConnectionToClient. | 266 // Create either IceConnectionToClient or WebrtcConnectionToClient. |
| 265 // TODO(sergeyu): Move this logic to the protocol layer. | 267 // TODO(sergeyu): Move this logic to the protocol layer. |
| 266 scoped_ptr<protocol::ConnectionToClient> connection; | 268 scoped_ptr<protocol::ConnectionToClient> connection; |
| 267 if (session->config().protocol() == | 269 if (session->config().protocol() == |
| 268 protocol::SessionConfig::Protocol::WEBRTC) { | 270 protocol::SessionConfig::Protocol::WEBRTC) { |
| 269 connection.reset(new protocol::WebrtcConnectionToClient( | 271 connection.reset(new protocol::WebrtcConnectionToClient( |
| 270 make_scoped_ptr(session), transport_context_)); | 272 make_scoped_ptr(session), webrtc_transport_context_)); |
| 271 } else { | 273 } else { |
| 272 connection.reset(new protocol::IceConnectionToClient( | 274 connection.reset(new protocol::IceConnectionToClient( |
| 273 make_scoped_ptr(session), transport_context_, | 275 make_scoped_ptr(session), ice_transport_context_, |
| 274 video_encode_task_runner_)); | 276 video_encode_task_runner_)); |
| 275 } | 277 } |
| 276 | 278 |
| 277 // Create a ClientSession object. | 279 // Create a ClientSession object. |
| 278 ClientSession* client = | 280 ClientSession* client = |
| 279 new ClientSession(this, audio_task_runner_, std::move(connection), | 281 new ClientSession(this, audio_task_runner_, std::move(connection), |
| 280 desktop_environment_factory_, max_session_duration_, | 282 desktop_environment_factory_, max_session_duration_, |
| 281 pairing_registry_, extensions_.get()); | 283 pairing_registry_, extensions_.get()); |
| 282 | 284 |
| 283 clients_.push_back(client); | 285 clients_.push_back(client); |
| 284 } | 286 } |
| 285 | 287 |
| 286 void ChromotingHost::DisconnectAllClients() { | 288 void ChromotingHost::DisconnectAllClients() { |
| 287 DCHECK(CalledOnValidThread()); | 289 DCHECK(CalledOnValidThread()); |
| 288 | 290 |
| 289 while (!clients_.empty()) { | 291 while (!clients_.empty()) { |
| 290 size_t size = clients_.size(); | 292 size_t size = clients_.size(); |
| 291 clients_.front()->DisconnectSession(protocol::OK); | 293 clients_.front()->DisconnectSession(protocol::OK); |
| 292 CHECK_EQ(clients_.size(), size - 1); | 294 CHECK_EQ(clients_.size(), size - 1); |
| 293 } | 295 } |
| 294 } | 296 } |
| 295 | 297 |
| 296 } // namespace remoting | 298 } // namespace remoting |
| OLD | NEW |