diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 21:03:29 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 21:03:29 +0000 |
commit | 3ebd384a5bbbac045e7ae7e07f8c8d9934dd7c69 (patch) | |
tree | 176514ecc364a5aa376aca2fc60e2440d5817384 /dbus/dbus_statistics.h | |
parent | 42774e4a2cffae20a5ab38ed43ed79ef9376e2fd (diff) | |
download | chromium_src-3ebd384a5bbbac045e7ae7e07f8c8d9934dd7c69.zip chromium_src-3ebd384a5bbbac045e7ae7e07f8c8d9934dd7c69.tar.gz chromium_src-3ebd384a5bbbac045e7ae7e07f8c8d9934dd7c69.tar.bz2 |
Add DBusStatistics and DBusLogSource to log and show dbus stats
The intention of this is to provide low overhead detailed logging to ensure that dbus call counts remain reasonable as we migrate NetworkLibrary and other systtems from src/chrome to src/chromeos.
We already have UMA stats which provide high level numbers that we can watch, but this will make detailed debugging available for advanced users and in feedback reports.
BUG=159635
For chrome/chrome_browser_chromeos.gypi:
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11363173
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/dbus_statistics.h')
-rw-r--r-- | dbus/dbus_statistics.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/dbus/dbus_statistics.h b/dbus/dbus_statistics.h new file mode 100644 index 0000000..2bd9fd9 --- /dev/null +++ b/dbus/dbus_statistics.h @@ -0,0 +1,74 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DBUS_DBUS_STATISTICS_H_ +#define DBUS_DBUS_STATISTICS_H_ + +#include <string> + +#include "dbus/dbus_export.h" + +namespace dbus { +namespace statistics { + +// Enum to specify what level of detail to show in GetAsString +enum ShowInString { + SHOW_SERVICE = 0, // Service totals only + SHOW_INTERFACE = 1, // Service + interface totals + SHOW_METHOD = 2, // Service + interface + method totals +}; + +// Enum to specify how to format the display in GetAsString +enum FormatString { + FORMAT_TOTALS = 0, // Raw totals only + FORMAT_PER_MINUTE = 1, // Per-minute only + FORMAT_ALL = 2 // Include all format details +}; + +// Initializes / shuts down dbus statistics gathering. Calling Initialize +// more than once will reset the statistics. +CHROME_DBUS_EXPORT void Initialize(); +CHROME_DBUS_EXPORT void Shutdown(); + +// Add sent/received calls to the statistics gathering class. These methods +// do nothing unless Initialize() was called. +CHROME_DBUS_EXPORT void AddSentMethodCall(const std::string& service, + const std::string& interface, + const std::string& method); +CHROME_DBUS_EXPORT void AddReceivedSignal(const std::string& service, + const std::string& interface, + const std::string& method); +// Track synchronous calls independently since we want to highlight +// (and remove) these. +CHROME_DBUS_EXPORT void AddBlockingSentMethodCall(const std::string& service, + const std::string& interface, + const std::string& method); + +// Output the calls into a formatted string. |show| determines what level +// of detail to show: one line per service, per interface, or per method. +// If |show_per_minute| is true include per minute stats. +// Example output for SHOW_METHOD, FORMAT_TOTALS: +// org.chromium.Mtpd.EnumerateStorage: Sent: 100 +// org.chromium.Mtpd.MTPStorageSignal: Received: 20 +// Example output for SHOW_INTERFACE, FORMAT_ALL: +// org.chromium.Mtpd: Sent: 100 (10/min) Received: 20 (2/min) +CHROME_DBUS_EXPORT std::string GetAsString(ShowInString show, + FormatString format); + +namespace testing { +// Sets |sent| to the number of sent calls, |received| to the number of +// received calls, and |blocking| to the number of sent blocking calls for +// service+interface+method. Used in unittests. +CHROME_DBUS_EXPORT bool GetCalls(const std::string& service, + const std::string& interface, + const std::string& method, + int* sent, + int* received, + int* blocking); +} // namespace testing + +} // namespace statistics +} // namespace dbus + +#endif // DBUS_DBUS_STATISTICS_H_ |