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

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

Issue 2858813002: [Chromoting] Use ProcessStatsSender in host process
Patch Set: Created 3 years, 7 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
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/client_session.h" 5 #include "remoting/host/client_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/optional.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "remoting/base/capabilities.h" 16 #include "remoting/base/capabilities.h"
16 #include "remoting/base/constants.h" 17 #include "remoting/base/constants.h"
17 #include "remoting/base/logging.h" 18 #include "remoting/base/logging.h"
18 #include "remoting/host/audio_capturer.h" 19 #include "remoting/host/audio_capturer.h"
19 #include "remoting/host/desktop_environment.h" 20 #include "remoting/host/desktop_environment.h"
20 #include "remoting/host/host_extension_session.h" 21 #include "remoting/host/host_extension_session.h"
21 #include "remoting/host/input_injector.h" 22 #include "remoting/host/input_injector.h"
22 #include "remoting/host/mouse_shape_pump.h" 23 #include "remoting/host/mouse_shape_pump.h"
24 #include "remoting/host/process_stats_sender.h"
23 #include "remoting/host/screen_controls.h" 25 #include "remoting/host/screen_controls.h"
24 #include "remoting/host/screen_resolution.h" 26 #include "remoting/host/screen_resolution.h"
25 #include "remoting/proto/control.pb.h" 27 #include "remoting/proto/control.pb.h"
26 #include "remoting/proto/event.pb.h" 28 #include "remoting/proto/event.pb.h"
27 #include "remoting/protocol/audio_stream.h" 29 #include "remoting/protocol/audio_stream.h"
28 #include "remoting/protocol/client_stub.h" 30 #include "remoting/protocol/client_stub.h"
29 #include "remoting/protocol/clipboard_thread_proxy.h" 31 #include "remoting/protocol/clipboard_thread_proxy.h"
30 #include "remoting/protocol/pairing_registry.h" 32 #include "remoting/protocol/pairing_registry.h"
31 #include "remoting/protocol/session.h" 33 #include "remoting/protocol/session.h"
32 #include "remoting/protocol/session_config.h" 34 #include "remoting/protocol/session_config.h"
(...skipping 27 matching lines...) Expand all
60 mouse_clamping_filter_(&remote_input_filter_), 62 mouse_clamping_filter_(&remote_input_filter_),
61 disable_input_filter_(&mouse_clamping_filter_), 63 disable_input_filter_(&mouse_clamping_filter_),
62 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), 64 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()),
63 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), 65 client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
64 max_duration_(max_duration), 66 max_duration_(max_duration),
65 pairing_registry_(pairing_registry), 67 pairing_registry_(pairing_registry),
66 // Note that |lossless_video_color_| defaults to true, but actually only 68 // Note that |lossless_video_color_| defaults to true, but actually only
67 // controls VP9 video stream color quality. 69 // controls VP9 video stream color quality.
68 lossless_video_color_(!base::CommandLine::ForCurrentProcess()->HasSwitch( 70 lossless_video_color_(!base::CommandLine::ForCurrentProcess()->HasSwitch(
69 kDisableI444SwitchName)), 71 kDisableI444SwitchName)),
72 current_process_stats_agent_("Network Process"),
70 weak_factory_(this) { 73 weak_factory_(this) {
71 connection_->session()->AddPlugin(&host_experiment_session_plugin_); 74 connection_->session()->AddPlugin(&host_experiment_session_plugin_);
72 connection_->SetEventHandler(this); 75 connection_->SetEventHandler(this);
73 76
74 // Create a manager for the configured extensions, if any. 77 // Create a manager for the configured extensions, if any.
75 extension_manager_.reset(new HostExtensionSessionManager(extensions, this)); 78 extension_manager_.reset(new HostExtensionSessionManager(extensions, this));
76 79
77 #if defined(OS_WIN) 80 #if defined(OS_WIN)
78 // LocalInputMonitorWin filters out an echo of the injected input before it 81 // LocalInputMonitorWin filters out an echo of the injected input before it
79 // reaches |remote_input_filter_|. 82 // reaches |remote_input_filter_|.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 max_duration_timer_.Start( 239 max_duration_timer_.Start(
237 FROM_HERE, max_duration_, 240 FROM_HERE, max_duration_,
238 base::Bind(&ClientSession::DisconnectSession, base::Unretained(this), 241 base::Bind(&ClientSession::DisconnectSession, base::Unretained(this),
239 protocol::MAX_SESSION_LENGTH)); 242 protocol::MAX_SESSION_LENGTH));
240 } 243 }
241 244
242 // Notify EventHandler. 245 // Notify EventHandler.
243 event_handler_->OnSessionAuthenticated(this); 246 event_handler_->OnSessionAuthenticated(this);
244 247
245 DesktopEnvironmentOptions options = desktop_environment_options_; 248 DesktopEnvironmentOptions options = desktop_environment_options_;
246 options.ApplyHostSessionOptions(HostSessionOptions( 249 const HostSessionOptions session_options(
247 host_experiment_session_plugin_.configuration())); 250 host_experiment_session_plugin_.configuration());
251 options.ApplyHostSessionOptions(session_options);
248 // Create the desktop environment. Drop the connection if it could not be 252 // Create the desktop environment. Drop the connection if it could not be
249 // created for any reason (for instance the curtain could not initialize). 253 // created for any reason (for instance the curtain could not initialize).
250 desktop_environment_ = 254 desktop_environment_ =
251 desktop_environment_factory_->Create(weak_factory_.GetWeakPtr(), options); 255 desktop_environment_factory_->Create(weak_factory_.GetWeakPtr(), options);
252 if (!desktop_environment_) { 256 if (!desktop_environment_) {
253 DisconnectSession(protocol::HOST_CONFIGURATION_ERROR); 257 DisconnectSession(protocol::HOST_CONFIGURATION_ERROR);
254 return; 258 return;
255 } 259 }
256 260
257 // Connect host stub. 261 // Connect host stub.
258 connection_->set_host_stub(this); 262 connection_->set_host_stub(this);
259 263
264 if (connection_->stats_stub()) {
265 base::Optional<int> track_process_stats_interval =
266 session_options.GetInt("Track-Process-Stats-Interval");
267 // Track-Process-Stats-Interval-Ms is for testing only, usually we should
268 // not set the interval as small as one second or less.
269 base::Optional<int> track_process_stats_interval_ms =
270 session_options.GetInt("Track-Process-Stats-Interval-Ms");
271 base::TimeDelta interval;
272 if (track_process_stats_interval && *track_process_stats_interval > 0) {
273 interval = base::TimeDelta::FromSeconds(*track_process_stats_interval);
274 } else if (track_process_stats_interval_ms &&
275 *track_process_stats_interval_ms > 0) {
276 interval = base::TimeDelta::FromMilliseconds(
277 *track_process_stats_interval_ms);
278 }
279 if (interval > base::TimeDelta()) {
280 // TODO(zijiehe): Add ForwardProcessStatsAgent from DesktopEnvironment.
281 stats_sender_.reset(new ProcessStatsSender(
282 connection_->stats_stub(),
283 interval,
284 { &current_process_stats_agent_ }));
285 }
286 }
287
260 // Collate the set of capabilities to offer the client, if it supports them. 288 // Collate the set of capabilities to offer the client, if it supports them.
261 host_capabilities_ = desktop_environment_->GetCapabilities(); 289 host_capabilities_ = desktop_environment_->GetCapabilities();
262 if (!host_capabilities_.empty()) 290 if (!host_capabilities_.empty())
263 host_capabilities_.append(" "); 291 host_capabilities_.append(" ");
264 host_capabilities_.append(extension_manager_->GetCapabilities()); 292 host_capabilities_.append(extension_manager_->GetCapabilities());
265 293
266 // Create the object that controls the screen resolution. 294 // Create the object that controls the screen resolution.
267 screen_controls_ = desktop_environment_->CreateScreenControls(); 295 screen_controls_ = desktop_environment_->CreateScreenControls();
268 296
269 // Create the event executor. 297 // Create the event executor.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 381
354 // Stop components access the client, audio or video stubs, which are no 382 // Stop components access the client, audio or video stubs, which are no
355 // longer valid once ConnectionToClient calls OnConnectionClosed(). 383 // longer valid once ConnectionToClient calls OnConnectionClosed().
356 audio_stream_.reset(); 384 audio_stream_.reset();
357 video_stream_.reset(); 385 video_stream_.reset();
358 mouse_shape_pump_.reset(); 386 mouse_shape_pump_.reset();
359 client_clipboard_factory_.InvalidateWeakPtrs(); 387 client_clipboard_factory_.InvalidateWeakPtrs();
360 input_injector_.reset(); 388 input_injector_.reset();
361 screen_controls_.reset(); 389 screen_controls_.reset();
362 desktop_environment_.reset(); 390 desktop_environment_.reset();
391 stats_sender_.reset();
363 392
364 // Notify the ChromotingHost that this client is disconnected. 393 // Notify the ChromotingHost that this client is disconnected.
365 event_handler_->OnSessionClosed(this); 394 event_handler_->OnSessionClosed(this);
366 } 395 }
367 396
368 void ClientSession::OnRouteChange( 397 void ClientSession::OnRouteChange(
369 const std::string& channel_name, 398 const std::string& channel_name,
370 const protocol::TransportRoute& route) { 399 const protocol::TransportRoute& route) {
371 DCHECK(CalledOnValidThread()); 400 DCHECK(CalledOnValidThread());
372 event_handler_->OnSessionRouteChange(this, channel_name, route); 401 event_handler_->OnSessionRouteChange(this, channel_name, route);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 connection_->client_stub()->SetVideoLayout(layout); 495 connection_->client_stub()->SetVideoLayout(layout);
467 } else { 496 } else {
468 pending_video_layout_message_.reset(new protocol::VideoLayout(layout)); 497 pending_video_layout_message_.reset(new protocol::VideoLayout(layout));
469 } 498 }
470 break; 499 break;
471 } 500 }
472 } 501 }
473 } 502 }
474 503
475 } // namespace remoting 504 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698