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> | |
fgorski
2014/03/29 05:09:29
nit: not needed
juyik
2014/03/31 22:19:23
Done.
| |
11 | |
12 #include "base/compiler_specific.h" | |
fgorski
2014/03/29 05:09:29
what is that for?
juyik
2014/03/31 22:19:23
Done.
| |
13 #include "base/time/time.h" | |
14 #include "google_apis/gcm/base/gcm_export.h" | |
15 #include "google_apis/gcm/engine/mcs_client.h" | |
16 | |
17 namespace gcm { | |
18 | |
19 // Records GCM internal stats and activities for debugging purpose. Recording | |
20 // can be turned on/off by calling SetRecording(...) function. It is turned off | |
21 // by default. | |
22 // This class is not thread safe. It is meant to be owned by a gcm client | |
23 // instance. | |
24 class GCM_EXPORT GCMStatsRecorder { | |
25 public: | |
26 // Contains data that are common to all activity kinds below. | |
27 struct GCM_EXPORT Activity { | |
28 Activity(); | |
29 virtual ~Activity(); | |
30 | |
31 base::Time time; | |
32 std::string event; // A short description of the event. | |
33 std::string details; // Any additional detail about the event. | |
34 }; | |
35 | |
36 // Contains relevant data of a send-message step. | |
37 struct GCM_EXPORT SendingActivity : Activity { | |
38 SendingActivity(); | |
39 virtual ~SendingActivity() OVERRIDE; | |
40 | |
41 std::string app_id; | |
42 std::string receiver_id; | |
43 std::string message_id; | |
44 }; | |
45 | |
46 GCMStatsRecorder(); | |
47 virtual ~GCMStatsRecorder(); | |
48 | |
49 // Indicates whether the recorder is currently recording activities or not. | |
50 bool is_recording() const { | |
51 return is_recording_; | |
52 } | |
53 | |
54 // Turns recording on/off. | |
55 void SetRecording(bool recording); | |
56 | |
57 // Clear all recorded activities. | |
58 void Clear(); | |
59 | |
60 // Records when the outgoing data message is sent to wire. | |
61 void RecordDataSentToWire(const std::string& app_id, | |
62 const std::string& receiver_id, | |
63 const std::string& message_id, | |
64 int queued); | |
65 // Records when the MCS client sends a send status notification to callback. | |
66 void RecordNotifySendStatus(const std::string& app_id, | |
67 const std::string& receiver_id, | |
68 const std::string& message_id, | |
69 MCSClient::MessageSendStatus status, | |
70 int byte_size, | |
71 int ttl); | |
72 // Records when a 'send error' message is received. | |
73 void RecordIncomingSendError(const std::string& app_id, | |
74 const std::string& receiver_id, | |
75 const std::string& message_id, | |
76 int byte_size, | |
77 int ttl); | |
78 | |
79 const std::deque<SendingActivity>& sending_activities() const { | |
80 return sending_activities_; | |
81 } | |
82 | |
83 protected: | |
84 void RecordSending(const std::string& app_id, | |
85 const std::string& receiver_id, | |
86 const std::string& message_id, | |
87 const std::string& event, | |
88 const std::string& details); | |
89 | |
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 |