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

Unified Diff: remoting/base/process_stats.h

Issue 2775983003: [Chromoting] Retrieve process resource usage (ProcessStats) and its tests (Closed)
Patch Set: Resolve review comments Created 3 years, 9 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/base/process_stats.h
diff --git a/remoting/base/process_stats.h b/remoting/base/process_stats.h
new file mode 100644
index 0000000000000000000000000000000000000000..68f74686d39d362f3e87c11326f915bf6e4ec282
--- /dev/null
+++ b/remoting/base/process_stats.h
@@ -0,0 +1,48 @@
+// 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_BASE_PROCESS_STATS_H_
+#define REMOTING_BASE_PROCESS_STATS_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "remoting/base/process_stats_agent.h"
+#include "remoting/base/process_stats_stub.h"
+#include "remoting/proto/process_stats.pb.h"
Sergey Ulanov 2017/04/03 23:50:21 base shouldn't depend on proto.
Hzj_jie 2017/04/05 20:52:16 These files have been moved to host.
+
+namespace remoting {
+
+// A component to report process statistic data regularly.
+class ProcessStats final {
Sergey Ulanov 2017/04/03 23:50:21 Maybe ProcessStatsSender?
Hzj_jie 2017/04/05 20:52:16 Done.
+ public:
+ // ProcessStats does not take the ownership of |host_stats_stub|. It needs to
+ // be outlived this instance.
Sergey Ulanov 2017/04/03 23:50:21 s/It needs to be outlived this instance./It must o
Hzj_jie 2017/04/05 20:52:16 Done.
+ ProcessStats(ProcessStatsStub* host_stats_stub, base::TimeDelta interval);
+
+ // Needs to be destructed on the same thread as constructing.
+ ~ProcessStats();
+
+ void AddProcessStatsAgent(std::unique_ptr<ProcessStatsAgent> agent);
+
+ // ProcessStats starts immediately, and reports the statistic data to
+ // |host_stats_stub| once per |interval_|.
+ void Start();
+
+ void Stop();
Sergey Ulanov 2017/04/03 23:50:21 Do we need this methods? Would it be better just d
Hzj_jie 2017/04/05 20:52:16 Emmm, indeed I believe this class should start imm
+
+ private:
+ void ReportUsage();
+
+ ProcessStatsStub* const host_stats_stub_;
+ const base::TimeDelta interval_;
+ std::vector<std::unique_ptr<ProcessStatsAgent>> agents_;
+ base::RepeatingTimer timer_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_BASE_PROCESS_STATS_H_

Powered by Google App Engine
This is Rietveld 408576698