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_SENDER_H_ | |
6 #define REMOTING_HOST_PROCESS_STATS_SENDER_H_ | |
7 | |
8 #include <initializer_list> | |
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/proto/process_stats.pb.h" | |
15 #include "remoting/protocol/process_stats_stub.h" | |
16 | |
17 namespace remoting { | |
18 | |
19 class ProcessStatsAgent; | |
20 | |
21 // A component to report process statistic data regularly, it starts immediately | |
22 // after construction, and stops after destruction. | |
23 // All public functions, including constructor and destructor of the object of | |
24 // ProcessStatsSender need to be executed in a same thread. | |
25 class ProcessStatsSender final { | |
26 public: | |
27 // ProcessStatsSender reports statistic data to |host_stats_stub| once per | |
28 // |interval|. | |
29 // ProcessStatsSender does not take the ownership of both |host_stats_stub| | |
30 // and |agents|. They must outlive the ProcessStatsSender object. | |
31 ProcessStatsSender(protocol::ProcessStatsStub* host_stats_stub, | |
32 base::TimeDelta interval, | |
33 std::initializer_list<ProcessStatsAgent*> agents); | |
34 | |
35 ~ProcessStatsSender(); | |
36 private: | |
37 void ReportUsage(); | |
38 | |
39 protocol::ProcessStatsStub* const host_stats_stub_; | |
40 std::vector<ProcessStatsAgent*> agents_; | |
41 base::RepeatingTimer timer_; | |
42 const base::ThreadChecker thread_checker_; | |
43 }; | |
44 | |
45 } // namespace remoting | |
46 | |
47 #endif // REMOTING_HOST_PROCESS_STATS_SENDER_H_ | |
OLD | NEW |