OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 DBUS_DBUS_STATISTICS_H_ | |
6 #define DBUS_DBUS_STATISTICS_H_ | |
7 | |
8 #include <set> | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/time.h" | |
13 #include "dbus/dbus_export.h" | |
14 | |
15 namespace dbus { | |
16 namespace statistics { | |
17 | |
18 // Enum to specify what level of detail to show in GetAsString | |
19 enum ShowInString { | |
20 SHOW_SERVICE = 0, // Service totals only | |
21 SHOW_INTERFACE = 1, // Service + interface totals | |
22 SHOW_METHOD = 2, // Service + interface + method totals | |
23 }; | |
24 | |
25 // Enum to specify how to format the display in GetAsString | |
26 enum FormatString { | |
27 FORMAT_TOTALS = 0, // Raw totals only | |
28 FORMAT_PER_MINUTE = 1, // Per-minute only | |
29 FORMAT_ALL = 2 // Include all format details | |
30 }; | |
31 | |
32 // Initializes / shuts down dbus statistics gathering. Calling Initialize | |
33 // more than once will reset the statistics. | |
34 CHROME_DBUS_EXPORT void Initialize(); | |
35 CHROME_DBUS_EXPORT void Shutdown(); | |
36 | |
37 // Add sent/received calls to the statistcs gathering class. These methods | |
gauravsh
2012/11/12 21:41:58
NIT: statistics
stevenjb
2012/11/12 22:34:40
Done.
| |
38 // do nothing uless Initialize() was called. | |
gauravsh
2012/11/12 21:41:58
NIT: unless
stevenjb
2012/11/12 22:34:40
Done.
| |
39 CHROME_DBUS_EXPORT void AddSentMethodCall(const std::string& service, | |
40 const std::string& interface, | |
41 const std::string& method); | |
42 CHROME_DBUS_EXPORT void AddReceivedMethodCall(const std::string& service, | |
43 const std::string& interface, | |
44 const std::string& method); | |
45 // Track synchronous calls independently since we want to highlight | |
46 // (and remove) these. | |
47 CHROME_DBUS_EXPORT void AddBlockingSentMethodCall(const std::string& service, | |
48 const std::string& interface, | |
49 const std::string& method); | |
50 | |
51 // Output the calls into a formatted string. |show| determines what level | |
52 // of detail to show: one line per service, per interface, or per method. | |
53 // If |show_per_minute| is true include per minute stats. | |
54 // Example output for SHOW_METHOD, FORMAT_TOTALS: | |
55 // org.chromium.Mtpd.EnumerateStorage: Sent: 100 | |
56 // org.chromium.Mtpd.MTPStorageSignal: Received: 20 | |
57 // Example output for SHOW_INTEFACE, FORMAT_ALL: | |
58 // org.chromium.Mtpd: Sent: 100 (10/min) Received: 20 (2/min) | |
59 CHROME_DBUS_EXPORT std::string GetAsString(ShowInString show, | |
60 FormatString format); | |
61 | |
62 namespace testing { | |
63 // Sets |sent| to the number of sent calls, |received| to the number of | |
64 // received calls, and |blocking| to the number of sent blocking calls for | |
65 // service+interface+method. Used in unittests. | |
66 CHROME_DBUS_EXPORT bool GetCalls(const std::string& service, | |
67 const std::string& interface, | |
68 const std::string& method, | |
69 int* sent, | |
70 int* received, | |
71 int* blocking); | |
72 } // namespace testing | |
73 | |
74 } // namespace statistics | |
75 } // namespace dbus | |
76 | |
77 #endif // DBUS_DBUS_STATISTICS_H_ | |
OLD | NEW |