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

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

Issue 2080723008: [Chromoting] Use device::PowerSaveBlocker to block screen saver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 6 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 <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 "base/memory/ptr_util.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "jingle/glue/thread_wrapper.h" 17 #include "jingle/glue/thread_wrapper.h"
18 #include "remoting/base/auto_thread_task_runner.h"
18 #include "remoting/base/constants.h" 19 #include "remoting/base/constants.h"
19 #include "remoting/base/logging.h" 20 #include "remoting/base/logging.h"
20 #include "remoting/host/chromoting_host_context.h" 21 #include "remoting/host/chromoting_host_context.h"
21 #include "remoting/host/desktop_environment.h" 22 #include "remoting/host/desktop_environment.h"
22 #include "remoting/host/host_config.h" 23 #include "remoting/host/host_config.h"
23 #include "remoting/host/input_injector.h" 24 #include "remoting/host/input_injector.h"
24 #include "remoting/protocol/client_stub.h" 25 #include "remoting/protocol/client_stub.h"
25 #include "remoting/protocol/host_stub.h" 26 #include "remoting/protocol/host_stub.h"
26 #include "remoting/protocol/ice_connection_to_client.h" 27 #include "remoting/protocol/ice_connection_to_client.h"
27 #include "remoting/protocol/input_stub.h" 28 #include "remoting/protocol/input_stub.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Don't use initial delay unless the last request was an error. 61 // Don't use initial delay unless the last request was an error.
61 false, 62 false,
62 }; 63 };
63 64
64 } // namespace 65 } // namespace
65 66
66 ChromotingHost::ChromotingHost( 67 ChromotingHost::ChromotingHost(
67 DesktopEnvironmentFactory* desktop_environment_factory, 68 DesktopEnvironmentFactory* desktop_environment_factory,
68 std::unique_ptr<protocol::SessionManager> session_manager, 69 std::unique_ptr<protocol::SessionManager> session_manager,
69 scoped_refptr<protocol::TransportContext> transport_context, 70 scoped_refptr<protocol::TransportContext> transport_context,
70 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, 71 const ChromotingHostContext& context)
71 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner)
72 : desktop_environment_factory_(desktop_environment_factory), 72 : desktop_environment_factory_(desktop_environment_factory),
73 session_manager_(std::move(session_manager)), 73 session_manager_(std::move(session_manager)),
74 transport_context_(transport_context), 74 transport_context_(transport_context),
75 audio_task_runner_(audio_task_runner), 75 context_(context.Copy()),
76 video_encode_task_runner_(video_encode_task_runner),
77 started_(false), 76 started_(false),
78 login_backoff_(&kDefaultBackoffPolicy), 77 login_backoff_(&kDefaultBackoffPolicy),
79 enable_curtaining_(false), 78 enable_curtaining_(false),
80 weak_factory_(this) { 79 weak_factory_(this) {
81 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 80 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
82 } 81 }
83 82
84 ChromotingHost::~ChromotingHost() { 83 ChromotingHost::~ChromotingHost() {
85 DCHECK(CalledOnValidThread()); 84 DCHECK(CalledOnValidThread());
86 85
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 260
262 HOST_LOG << "Client connected: " << session->jid(); 261 HOST_LOG << "Client connected: " << session->jid();
263 262
264 // Create either IceConnectionToClient or WebrtcConnectionToClient. 263 // Create either IceConnectionToClient or WebrtcConnectionToClient.
265 // TODO(sergeyu): Move this logic to the protocol layer. 264 // TODO(sergeyu): Move this logic to the protocol layer.
266 std::unique_ptr<protocol::ConnectionToClient> connection; 265 std::unique_ptr<protocol::ConnectionToClient> connection;
267 if (session->config().protocol() == 266 if (session->config().protocol() ==
268 protocol::SessionConfig::Protocol::WEBRTC) { 267 protocol::SessionConfig::Protocol::WEBRTC) {
269 connection.reset(new protocol::WebrtcConnectionToClient( 268 connection.reset(new protocol::WebrtcConnectionToClient(
270 base::WrapUnique(session), transport_context_, 269 base::WrapUnique(session), transport_context_,
271 video_encode_task_runner_)); 270 context_->video_encode_task_runner()));
272 } else { 271 } else {
273 connection.reset(new protocol::IceConnectionToClient( 272 connection.reset(new protocol::IceConnectionToClient(
274 base::WrapUnique(session), transport_context_, 273 base::WrapUnique(session), transport_context_,
275 video_encode_task_runner_)); 274 context_->video_encode_task_runner()));
276 } 275 }
277 276
278 // Create a ClientSession object. 277 // Create a ClientSession object.
279 ClientSession* client = 278 ClientSession* client =
280 new ClientSession(this, audio_task_runner_, std::move(connection), 279 new ClientSession(*context_, this, std::move(connection),
281 desktop_environment_factory_, max_session_duration_, 280 desktop_environment_factory_, max_session_duration_,
282 pairing_registry_, extensions_.get()); 281 pairing_registry_, extensions_.get());
283 282
284 clients_.push_back(client); 283 clients_.push_back(client);
285 } 284 }
286 285
287 void ChromotingHost::DisconnectAllClients() { 286 void ChromotingHost::DisconnectAllClients() {
288 DCHECK(CalledOnValidThread()); 287 DCHECK(CalledOnValidThread());
289 288
290 while (!clients_.empty()) { 289 while (!clients_.empty()) {
291 size_t size = clients_.size(); 290 size_t size = clients_.size();
292 clients_.front()->DisconnectSession(protocol::OK); 291 clients_.front()->DisconnectSession(protocol::OK);
293 CHECK_EQ(clients_.size(), size - 1); 292 CHECK_EQ(clients_.size(), size - 1);
294 } 293 }
295 } 294 }
296 295
297 } // namespace remoting 296 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698