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

Unified Diff: remoting/host/daemon_process.cc

Issue 2950993003: [Chromoting] Use ProcessStatsSender in DaemonProcess (daemon process) (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/daemon_process.cc
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
index 7e3142da453b9851d676f8eea3f9f72b192f4b40..2924c921685ccf3b86aeb6fd85e025d11f60cc4d 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()
@@ -180,6 +186,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 +294,8 @@ void DaemonProcess::Initialize() {
void DaemonProcess::Stop() {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
+ stats_sender_.reset();
+
if (!stopped_callback_.is_null()) {
base::ResetAndReturn(&stopped_callback_).Run();
}
@@ -365,4 +374,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(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,
+ { &current_process_stats_ }));
+ }
+}
+
+void DaemonProcess::StopProcessStatsReport() {
+ DCHECK(caller_task_runner()->BelongsToCurrentThread());
+ process_stats_request_count_--;
+ DCHECK(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

Powered by Google App Engine
This is Rietveld 408576698