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

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
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..f1f718988f97f01ba50f2b952ed9da05531fd565
--- /dev/null
+++ b/remoting/host/process_stats_sender.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_HOST_PROCESS_STATS_H_
joedow 2017/04/24 17:16:09 fix the macro guard (REMOTING_HOST_PROCESS_STATS_S
Hzj_jie 2017/04/25 00:17:54 Done.
+#define REMOTING_HOST_PROCESS_STATS_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/threading/thread_checker.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "remoting/host/process_stats_agent.h"
joedow 2017/04/24 17:16:09 ProcessStatsAgent can be forward decalared
Hzj_jie 2017/04/25 00:17:53 Done.
+#include "remoting/proto/process_stats.pb.h"
+#include "remoting/protocol/process_stats_stub.h"
+
+namespace remoting {
+
+// A component to report process statistic data regularly.
+class ProcessStatsSender final {
+ public:
+ // ProcessStatsSender starts immediately, and reports the statistic data to
joedow 2017/04/24 17:16:09 nit: remove comma and 'the'
Hzj_jie 2017/04/25 00:17:53 Done.
+ // |host_stats_stub| once per |interval_|.
joedow 2017/04/24 17:16:09 s/interval_/interval
Hzj_jie 2017/04/25 00:17:53 Done.
+ // 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 stops in destruction. The ProcessStatsSender object
+ // needs to be destructed on the same thread as constructing.
joedow 2017/04/24 17:16:09 You might want to move the thread requirements int
Hzj_jie 2017/04/25 00:17:54 Done.
+ ~ProcessStatsSender();
+
+ void AddProcessStatsAgent(std::unique_ptr<ProcessStatsAgent> agent);
+
+ private:
joedow 2017/04/24 17:16:09 Do you want a private c'tor here?
Hzj_jie 2017/04/25 00:17:53 Sorry, I do not follow. Why?
joedow 2017/04/25 15:57:28 To prevent someone from creating a uninitialized i
Hzj_jie 2017/04/25 22:19:19 Ah, that seems not necessary. An explicit construc
+ void ReportUsage();
+
+ protocol::ProcessStatsStub* const host_stats_stub_;
+ const base::TimeDelta interval_;
+ std::vector<std::unique_ptr<ProcessStatsAgent>> agents_;
+ base::RepeatingTimer timer_;
+ base::ThreadChecker thread_checker_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_PROCESS_STATS_H_

Powered by Google App Engine
This is Rietveld 408576698