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

Unified Diff: remoting/host/process_stats_sender.h

Issue 2775983003: [Chromoting] Retrieve process resource usage (ProcessStats) and its tests (Closed)
Patch Set: Resolve review comments Created 3 years, 8 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
« no previous file with comments | « remoting/host/process_stats_agent.h ('k') | remoting/host/process_stats_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/process_stats_sender.h
diff --git a/remoting/host/process_stats_sender.h b/remoting/host/process_stats_sender.h
new file mode 100644
index 0000000000000000000000000000000000000000..0bd2e1be7eabe1eac130d9c4967ce81d2afb31f3
--- /dev/null
+++ b/remoting/host/process_stats_sender.h
@@ -0,0 +1,51 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_PROCESS_STATS_SENDER_H_
+#define REMOTING_HOST_PROCESS_STATS_SENDER_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/threading/thread_checker.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "remoting/proto/process_stats.pb.h"
+#include "remoting/protocol/process_stats_stub.h"
+
+namespace remoting {
+
+class ProcessStatsAgent;
+
+// A component to report process statistic data regularly, it starts immediately
+// after construction, and stops before destruction.
joedow 2017/04/26 23:48:02 s/before/after The class stops when the d'tor is
Hzj_jie 2017/04/27 02:21:34 Done.
+// All public functions, including constructor and destructor of the object of
+// ProcessStatsSender need to be executed in a same thread.
+class ProcessStatsSender final {
+ public:
+ // ProcessStatsSender reports statistic data to |host_stats_stub| once per
+ // |interval|.
+ // ProcessStatsSender does not take the ownership of |host_stats_stub|. It
+ // must outlive the ProcessStatsSender object.
+ ProcessStatsSender(protocol::ProcessStatsStub* host_stats_stub,
+ base::TimeDelta interval);
+
+ ~ProcessStatsSender();
+
+ // Add a new ProcessStatsAgent. Users should call this function at least once
+ // immediately after constructor in the same thread.
+ void AddProcessStatsAgent(std::unique_ptr<ProcessStatsAgent> agent);
+
+ private:
+ void ReportUsage();
+
+ protocol::ProcessStatsStub* const host_stats_stub_;
+ std::vector<std::unique_ptr<ProcessStatsAgent>> agents_;
+ base::RepeatingTimer timer_;
+ const base::ThreadChecker thread_checker_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_PROCESS_STATS_SENDER_H_
« no previous file with comments | « remoting/host/process_stats_agent.h ('k') | remoting/host/process_stats_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698