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..b629d53089a1b004f878790d0977cfc20cdcd361 |
--- /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_H_ |
+#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" |
+#include "remoting/proto/process_stats.pb.h" |
+#include "remoting/protocol/process_stats_stub.h" |
+ |
+namespace remoting { |
+namespace host { |
+ |
+// A component to report process statistic data regularly. |
+class ProcessStatsSender final { |
+ public: |
+ // ProcessStatsSender starts immediately, and reports the 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. The ProcessStatsSender object |
+ // needs to be destructed on the same thread as constructing. |
+ ~ProcessStatsSender(); |
+ |
+ void AddProcessStatsAgent(std::unique_ptr<ProcessStatsAgent> agent); |
+ |
+ private: |
+ 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 host |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_PROCESS_STATS_H_ |