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. | |
Wez
2016/06/07 00:30:13
I can't find anything in SparseHistogram that actu
| |
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 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. Histograms are | |
41 // intentionally leaked at the process termination. | |
Kevin M
2016/05/26 23:15:30
???
Why do we leak them? Is there another task th
Wez
2016/06/07 00:30:12
Did this ever get answered?
| |
42 base::HistogramBase* histogram_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(BlimpConnectionStatistics); | |
45 }; | |
46 | |
47 } // namespace blimp | |
48 | |
49 #endif // BLIMP_NET_BLIMP_CONNECTION_STATISTICS_H_ | |
OLD | NEW |