OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_HOST_PROCESS_STATS_H_ |
| 6 #define REMOTING_HOST_PROCESS_STATS_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "base/time/time.h" |
| 13 #include "base/timer/timer.h" |
| 14 #include "remoting/host/process_stats_agent.h" |
| 15 #include "remoting/proto/process_stats.pb.h" |
| 16 #include "remoting/protocol/process_stats_stub.h" |
| 17 |
| 18 namespace remoting { |
| 19 namespace host { |
| 20 |
| 21 // A component to report process statistic data regularly. |
| 22 class ProcessStatsSender final { |
| 23 public: |
| 24 // ProcessStatsSender starts immediately, and reports the statistic data to |
| 25 // |host_stats_stub| once per |interval_|. |
| 26 // ProcessStatsSender does not take the ownership of |host_stats_stub|. It |
| 27 // must outlive the ProcessStatsSender object. |
| 28 ProcessStatsSender(protocol::ProcessStatsStub* host_stats_stub, |
| 29 base::TimeDelta interval); |
| 30 |
| 31 // ProcessStatsSender stops in destruction. The ProcessStatsSender object |
| 32 // needs to be destructed on the same thread as constructing. |
| 33 ~ProcessStatsSender(); |
| 34 |
| 35 void AddProcessStatsAgent(std::unique_ptr<ProcessStatsAgent> agent); |
| 36 |
| 37 private: |
| 38 void ReportUsage(); |
| 39 |
| 40 protocol::ProcessStatsStub* const host_stats_stub_; |
| 41 const base::TimeDelta interval_; |
| 42 std::vector<std::unique_ptr<ProcessStatsAgent>> agents_; |
| 43 base::RepeatingTimer timer_; |
| 44 base::ThreadChecker thread_checker_; |
| 45 }; |
| 46 |
| 47 } // namespace host |
| 48 } // namespace remoting |
| 49 |
| 50 #endif // REMOTING_HOST_PROCESS_STATS_H_ |
OLD | NEW |