Index: remoting/host/daemon_process.cc |
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc |
index 7e3142da453b9851d676f8eea3f9f72b192f4b40..cc7ec8e4e3812f44a2e29632711c4a18fed604c7 100644 |
--- a/remoting/host/daemon_process.cc |
+++ b/remoting/host/daemon_process.cc |
@@ -16,6 +16,7 @@ |
#include "base/location.h" |
#include "base/single_thread_task_runner.h" |
#include "remoting/base/auto_thread_task_runner.h" |
+#include "remoting/base/constants.h" |
#include "remoting/host/branding.h" |
#include "remoting/host/chromoting_messages.h" |
#include "remoting/host/config_file_watcher.h" |
@@ -23,6 +24,7 @@ |
#include "remoting/host/host_event_logger.h" |
#include "remoting/host/host_exit_codes.h" |
#include "remoting/host/host_status_observer.h" |
+#include "remoting/host/process_stats_sender.h" |
#include "remoting/host/screen_resolution.h" |
#include "remoting/protocol/transport.h" |
@@ -120,6 +122,10 @@ bool DaemonProcess::OnMessageReceived(const IPC::Message& message) { |
OnHostStarted) |
IPC_MESSAGE_HANDLER(ChromotingNetworkDaemonMsg_HostShutdown, |
OnHostShutdown) |
+ IPC_MESSAGE_HANDLER(ChromotingNetworkToAnyMsg_StartProcessStatsReport, |
+ StartProcessStatsReport) |
+ IPC_MESSAGE_HANDLER(ChromotingNetworkToAnyMsg_StopProcessStatsReport, |
+ StopProcessStatsReport) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
@@ -139,6 +145,11 @@ void DaemonProcess::OnPermanentError(int exit_code) { |
Stop(); |
} |
+void DaemonProcess::OnWorkerProcessStopped() { |
+ process_stats_request_count_ = 0; |
+ stats_sender_.reset(); |
+} |
+ |
void DaemonProcess::CloseDesktopSession(int terminal_id) { |
DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
@@ -180,6 +191,7 @@ DaemonProcess::DaemonProcess( |
io_task_runner_(io_task_runner), |
next_terminal_id_(0), |
stopped_callback_(stopped_callback), |
+ current_process_stats_("DaemonProcess"), |
weak_factory_(this) { |
DCHECK(caller_task_runner->BelongsToCurrentThread()); |
// TODO(sammc): On OSX, mojo::edk::SetMachPortProvider() should be called with |
@@ -287,6 +299,8 @@ void DaemonProcess::Initialize() { |
void DaemonProcess::Stop() { |
DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
+ OnWorkerProcessStopped(); |
+ |
if (!stopped_callback_.is_null()) { |
base::ResetAndReturn(&stopped_callback_).Run(); |
} |
@@ -365,4 +379,37 @@ void DaemonProcess::DeleteAllDesktopSessions() { |
} |
} |
+void DaemonProcess::StartProcessStatsReport(base::TimeDelta interval) { |
+ DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
+ if (interval <= base::TimeDelta::FromSeconds(0)) { |
+ interval = kDefaultProcessStatsInterval; |
+ } |
+ |
+ process_stats_request_count_++; |
+ DCHECK_GT(process_stats_request_count_, 0); |
+ if (process_stats_request_count_ == 1 || |
+ stats_sender_->interval() > interval) { |
+ DCHECK_EQ(process_stats_request_count_ == 1, !stats_sender_); |
+ stats_sender_.reset(new ProcessStatsSender( |
+ this, |
+ interval, |
+ { ¤t_process_stats_ })); |
+ } |
+} |
+ |
+void DaemonProcess::StopProcessStatsReport() { |
+ DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
+ process_stats_request_count_--; |
+ DCHECK_GE(process_stats_request_count_, 0); |
+ if (process_stats_request_count_ == 0) { |
+ DCHECK(stats_sender_); |
+ stats_sender_.reset(); |
+ } |
+} |
+ |
+void DaemonProcess::OnProcessStats( |
+ const protocol::AggregatedProcessResourceUsage& usage) { |
+ SendToNetwork(new ChromotingAnyToNetworkMsg_ReportProcessStats(usage)); |
+} |
+ |
} // namespace remoting |