OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ | |
6 #define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ | |
7 | |
8 #include <deque> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/compiler_specific.h" | |
13 #include "base/memory/ref_counted.h" | |
jianli
2014/03/21 18:25:27
nit: not needed
juyik
2014/03/26 04:06:03
Done.
| |
14 #include "base/memory/weak_ptr.h" | |
jianli
2014/03/21 18:25:27
ditto
juyik
2014/03/26 04:06:03
Done.
| |
15 #include "base/time/time.h" | |
16 #include "google_apis/gcm/base/gcm_export.h" | |
17 | |
18 namespace gcm { | |
19 | |
20 // Records GCM internal stats and activities for debugging purpose. Recording | |
21 // can be turned on/off by calling SetRecording(...) function. It is turned off | |
22 // by default. | |
23 // This class is not thread safe. It is meant to be owned by a gcm client | |
24 // instance. | |
25 class GCM_EXPORT GCMStatsRecorder { | |
26 public: | |
27 // Contains data that are common to all activity kinds below. | |
28 struct GCM_EXPORT Activity { | |
29 Activity(); | |
30 virtual ~Activity(); | |
31 | |
32 base::Time time; | |
33 std::string event; // A short description of the event. | |
34 std::string details; // Any additional detail about the event. | |
35 }; | |
36 | |
37 // Contains relevant data of a send-message step. | |
38 struct GCM_EXPORT SendingActivity : Activity { | |
39 SendingActivity(); | |
40 virtual ~SendingActivity() OVERRIDE; | |
41 | |
42 std::string app_id; | |
43 std::string receiver_id; | |
44 std::string message_id; | |
45 }; | |
46 | |
47 GCMStatsRecorder(); | |
48 virtual ~GCMStatsRecorder(); | |
49 | |
50 // Indicates whether the recorder is currently recording activities or not. | |
51 bool is_recording() const { | |
52 return is_recording_; | |
53 } | |
54 | |
55 // Turns recording on/off. | |
56 void SetRecording(bool recording); | |
57 | |
58 // Clear all recorded activities. | |
59 void Clear(); | |
60 | |
61 // Record a sending activity. | |
62 void RecordSending(const std::string& app_id, | |
63 const std::string& receiver_id, | |
64 const std::string& message_id, | |
65 const std::string& event, | |
66 const std::string& details); | |
67 // Record a sending activity together with UMA enumeration metrics. | |
68 void RecordSendingWithUMAEnum(const std::string& app_id, | |
69 const std::string& receiver_id, | |
70 const std::string& message_id, | |
71 const std::string& event, | |
72 const std::string& details, | |
73 const std::string& uma_name, | |
74 int uma_value, | |
75 int uma_value_bound); | |
76 // Record a sending activity together with UMA count metrics. | |
77 void RecordSendingWithUMACounts(const std::string& app_id, | |
78 const std::string& receiver_id, | |
79 const std::string& message_id, | |
80 const std::string& event, | |
81 const std::string& details, | |
82 const std::string& uma_name, | |
83 int uma_value); | |
84 | |
85 const std::deque<SendingActivity>& sending_activities() const { | |
86 return sending_activities_; | |
87 } | |
88 | |
89 protected: | |
90 bool is_recording_; | |
91 | |
92 std::deque<SendingActivity> sending_activities_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder); | |
95 }; | |
96 | |
97 } // namespace gcm | |
98 | |
99 #endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ | |
OLD | NEW |