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