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