Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: remoting/host/chromoting_host.cc

Issue 1545743002: Move ownership of Transport out of Session. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass_client
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/transport_context.h"
25 #include "remoting/protocol/webrtc_connection_to_client.h" 26 #include "remoting/protocol/webrtc_connection_to_client.h"
26 27
27 using remoting::protocol::ConnectionToClient; 28 using remoting::protocol::ConnectionToClient;
28 using remoting::protocol::InputStub; 29 using remoting::protocol::InputStub;
29 30
30 namespace remoting { 31 namespace remoting {
31 32
32 namespace { 33 namespace {
33 34
34 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { 35 const net::BackoffEntry::Policy kDefaultBackoffPolicy = {
(...skipping 20 matching lines...) Expand all
55 56
56 // Don't use initial delay unless the last request was an error. 57 // Don't use initial delay unless the last request was an error.
57 false, 58 false,
58 }; 59 };
59 60
60 } // namespace 61 } // namespace
61 62
62 ChromotingHost::ChromotingHost( 63 ChromotingHost::ChromotingHost(
63 DesktopEnvironmentFactory* desktop_environment_factory, 64 DesktopEnvironmentFactory* desktop_environment_factory,
64 scoped_ptr<protocol::SessionManager> session_manager, 65 scoped_ptr<protocol::SessionManager> session_manager,
66 scoped_refptr<protocol::TransportContext> transport_context,
65 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, 67 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
66 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 68 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
67 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, 69 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
68 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, 70 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner,
69 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 71 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
70 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) 72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
71 : desktop_environment_factory_(desktop_environment_factory), 73 : desktop_environment_factory_(desktop_environment_factory),
72 session_manager_(std::move(session_manager)), 74 session_manager_(std::move(session_manager)),
75 transport_context_(transport_context),
73 audio_task_runner_(audio_task_runner), 76 audio_task_runner_(audio_task_runner),
74 input_task_runner_(input_task_runner), 77 input_task_runner_(input_task_runner),
75 video_capture_task_runner_(video_capture_task_runner), 78 video_capture_task_runner_(video_capture_task_runner),
76 video_encode_task_runner_(video_encode_task_runner), 79 video_encode_task_runner_(video_encode_task_runner),
77 network_task_runner_(network_task_runner), 80 network_task_runner_(network_task_runner),
78 ui_task_runner_(ui_task_runner), 81 ui_task_runner_(ui_task_runner),
79 started_(false), 82 started_(false),
80 login_backoff_(&kDefaultBackoffPolicy), 83 login_backoff_(&kDefaultBackoffPolicy),
81 enable_curtaining_(false), 84 enable_curtaining_(false),
82 weak_factory_(this) { 85 weak_factory_(this) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 266
264 *response = protocol::SessionManager::ACCEPT; 267 *response = protocol::SessionManager::ACCEPT;
265 268
266 HOST_LOG << "Client connected: " << session->jid(); 269 HOST_LOG << "Client connected: " << session->jid();
267 270
268 // Create either IceConnectionToClient or WebrtcConnectionToClient. 271 // Create either IceConnectionToClient or WebrtcConnectionToClient.
269 // TODO(sergeyu): Move this logic to the protocol layer. 272 // TODO(sergeyu): Move this logic to the protocol layer.
270 scoped_ptr<protocol::ConnectionToClient> connection; 273 scoped_ptr<protocol::ConnectionToClient> connection;
271 if (session->config().protocol() == 274 if (session->config().protocol() ==
272 protocol::SessionConfig::Protocol::WEBRTC) { 275 protocol::SessionConfig::Protocol::WEBRTC) {
273 connection.reset( 276 connection.reset(new protocol::WebrtcConnectionToClient(
274 new protocol::WebrtcConnectionToClient(make_scoped_ptr(session))); 277 make_scoped_ptr(session), transport_context_));
275 } else { 278 } else {
276 connection.reset(new protocol::IceConnectionToClient( 279 connection.reset(new protocol::IceConnectionToClient(
277 make_scoped_ptr(session), video_encode_task_runner_)); 280 make_scoped_ptr(session), transport_context_,
281 video_encode_task_runner_));
278 } 282 }
279 283
280 // Create a ClientSession object. 284 // Create a ClientSession object.
281 ClientSession* client = new ClientSession( 285 ClientSession* client = new ClientSession(
282 this, audio_task_runner_, input_task_runner_, video_capture_task_runner_, 286 this, audio_task_runner_, input_task_runner_, video_capture_task_runner_,
283 video_encode_task_runner_, network_task_runner_, ui_task_runner_, 287 video_encode_task_runner_, network_task_runner_, ui_task_runner_,
284 std::move(connection), desktop_environment_factory_, 288 std::move(connection), desktop_environment_factory_,
285 max_session_duration_, pairing_registry_, extensions_.get()); 289 max_session_duration_, pairing_registry_, extensions_.get());
286 290
287 clients_.push_back(client); 291 clients_.push_back(client);
288 } 292 }
289 293
290 void ChromotingHost::DisconnectAllClients() { 294 void ChromotingHost::DisconnectAllClients() {
291 DCHECK(CalledOnValidThread()); 295 DCHECK(CalledOnValidThread());
292 296
293 while (!clients_.empty()) { 297 while (!clients_.empty()) {
294 size_t size = clients_.size(); 298 size_t size = clients_.size();
295 clients_.front()->DisconnectSession(protocol::OK); 299 clients_.front()->DisconnectSession(protocol::OK);
296 CHECK_EQ(clients_.size(), size - 1); 300 CHECK_EQ(clients_.size(), size - 1);
297 } 301 }
298 } 302 }
299 303
300 } // namespace remoting 304 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698