Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1039)

Side by Side Diff: dbus/dbus_statistics.h

Issue 11363173: Add DBusStatistics and DBusLogSource to log and show dbus stats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
17 class CHROME_DBUS_EXPORT DbusStatistics {
satorux1 2012/11/12 00:40:43 Please write some class comment.
satorux1 2012/11/12 00:40:43 Dbus -> DBus, to be consistent with other classes
stevenjb 2012/11/12 19:46:40 Done.
stevenjb 2012/11/12 19:46:40 Done.
18 public:
19 // Enum to specify which details to show in GetAsString
20 enum ShowInString {
21 SHOW_SERVICE = 0, // Service totals only
22 SHOW_INTERFACE = 1, // Service + interface totals
23 SHOW_METHOD = 2, // Service + interface + method totals
24 };
25
26 struct Stat {
27 Stat(const std::string& service,
28 const std::string& interface,
29 const std::string& method);
30 std::string service;
31 std::string interface;
32 std::string method;
33 int sent_calls;
34 int received_calls;
35
36 bool Compare(const Stat& other) const;
satorux1 2012/11/12 00:40:43 Returns true when?
stevenjb 2012/11/12 19:46:40 Compare == < is pretty standard, but added a comme
37
38 struct PtrCompare {
39 bool operator()(Stat* lhs, Stat* rhs) const;
40 };
41 };
42
43 DbusStatistics();
hashimoto 2012/11/12 04:33:16 Since all public methods are static, how about hid
satorux1 2012/11/12 04:43:17 Good ideas. I think we can hide the DbusStatistics
stevenjb 2012/11/12 19:46:40 That makes sense. I think I started this expecting
44 ~DbusStatistics();
45
46 // Initializes / shuts down dbus statistics gathering. Calling Initialize
47 // more than once will reset the statistics.
48 static void Initialize();
49 static void Shutdown();
50
51 // Static methods do nothing uless Initialize() was called.
satorux1 2012/11/12 00:40:43 Please also write what these functions do.
stevenjb 2012/11/12 19:46:40 Done.
52 static void AddSentCall(const std::string& service,
satorux1 2012/11/12 00:40:43 Call -> MethodCall to be a bit more descriptive?
stevenjb 2012/11/12 19:46:40 Done.
53 const std::string& interface,
54 const std::string& method);
55 static void AddReceivedCall(const std::string& service,
satorux1 2012/11/12 00:40:43 ditto.
stevenjb 2012/11/12 19:46:40 Done.
56 const std::string& interface,
57 const std::string& method);
58
59 // Output the calls into a formatted string. |show| determines what level
60 // of detail to show: one line per service, per interface, or per method.
61 // If |show_per_minute| is true include per minute stats.
62 static std::string GetAsString(ShowInString show, bool show_per_minute);
satorux1 2012/11/12 00:40:43 boolean parameter like this makes the client code
stevenjb 2012/11/12 19:46:40 I find bitfields to be error-prone; C++ doesn't ha
63
64 // Testing
satorux1 2012/11/12 00:40:43 Please write a function comment.
stevenjb 2012/11/12 19:46:40 Done.
65 static bool GetCallsForTesting(const std::string& service,
66 const std::string& interface,
67 const std::string& method,
68 int* sent,
69 int* received);
70
71 private:
72 // Eunum to specify which field in Stat to incrament in AddStat
73 enum StatType {
74 TYPE_SENT,
75 TYPE_RECEIVED
76 };
77
78 typedef std::set<Stat*, Stat::PtrCompare> StatSet;
79
80 // Add a call to |method| for |interface|. See also MethodCall in message.h.
81 void AddStat(const std::string& service,
82 const std::string& interface,
83 const std::string& method,
84 StatType type);
85
86 // Look up the Stat entry in |stats_|. If |add_stat| is true, add a new entry
87 // if one does not already exist.
88 Stat* GetStat(const std::string& service,
89 const std::string& interface,
90 const std::string& method,
91 bool add_stat);
92
93 StatSet stats_;
94 base::Time start_time_;
95
96 DISALLOW_COPY_AND_ASSIGN(DbusStatistics);
97 };
98
99 } // namespace dbus
100
101 #endif // DBUS_DBUS_STATISTICS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698