OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_ | |
6 #define BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_ | |
7 | |
8 #include <map> | |
9 #include "base/macros.h" | |
10 #include "base/metrics/sparse_histogram.h" | |
11 #include "blimp/net/blimp_net_export.h" | |
12 | |
13 namespace blimp { | |
14 | |
15 // Collects network traffic statistics. Maintains a counter for number of | |
16 // completed commits, bytes sent and received over network and notifies its | |
17 // observers on the main thread. | |
18 // This class is supposed to live an entire session, created and destroyed along | |
19 // it. This class is thread-safe. | |
20 class BLIMP_NET_EXPORT BlimpConnectionStatistics { | |
21 public: | |
22 enum EventType { | |
23 BYTES_SENT = 0, | |
24 BYTES_RECEIVED = 1, | |
25 COMMIT = 2, | |
26 }; | |
27 | |
28 BlimpConnectionStatistics(); | |
29 | |
30 ~BlimpConnectionStatistics(); | |
31 | |
32 // Accumulates values for a metrics. | |
Kevin M
2016/05/24 22:56:40
a metric
| |
33 void Add(EventType type, int data); | |
34 | |
35 // Returns value for a metric. | |
36 int Get(EventType type); | |
37 | |
38 private: | |
39 // A histogram to hold the metrics. It will have one sample for each type of | |
40 // metric which will be accumulated on each subsequent call. | |
41 std::unique_ptr<base::HistogramBase> histogram_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(BlimpConnectionStatistics); | |
44 }; | |
45 | |
46 } // namespace blimp | |
47 | |
48 #endif // BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_ | |
OLD | NEW |