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..546f28e60d643f62d6bbe06eb4391cefdbb4cdab |
--- /dev/null |
+++ b/remoting/host/process_stats_sender.h |
@@ -0,0 +1,50 @@ |
+// 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. |
+// 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 starts immediately and 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 stops in destruction. |
joedow
2017/04/26 16:44:06
I don't think this comment is needed (most classes
Hzj_jie
2017/04/26 20:47:19
I have moved the comments regarding to the time of
|
+ ~ProcessStatsSender(); |
+ |
+ void AddProcessStatsAgent(std::unique_ptr<ProcessStatsAgent> agent); |
+ |
+ private: |
+ void ReportUsage(); |
+ |
+ protocol::ProcessStatsStub* const host_stats_stub_; |
+ const base::TimeDelta interval_; |
Sergey Ulanov
2017/04/26 05:42:44
I don't think you need this field. The constructor
Hzj_jie
2017/04/26 20:47:19
Oh, yes, that's for the old Start() and Stop() des
|
+ std::vector<std::unique_ptr<ProcessStatsAgent>> agents_; |
+ base::RepeatingTimer timer_; |
+ const base::ThreadChecker thread_checker_; |
+}; |
+ |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_PROCESS_STATS_SENDER_H_ |