Chromium Code Reviews| Index: google_apis/gcm/monitoring/gcm_stats_recorder.h |
| diff --git a/google_apis/gcm/monitoring/gcm_stats_recorder.h b/google_apis/gcm/monitoring/gcm_stats_recorder.h |
| index 71b6c6ac35e25d0cb29cfb9fc60f001e70fa3a2a..c470fbd32886a62f43338b1d69ddd48e66d1fd1e 100644 |
| --- a/google_apis/gcm/monitoring/gcm_stats_recorder.h |
| +++ b/google_apis/gcm/monitoring/gcm_stats_recorder.h |
| @@ -11,7 +11,9 @@ |
| #include "base/time/time.h" |
| #include "google_apis/gcm/base/gcm_export.h" |
| +#include "google_apis/gcm/engine/connection_factory.h" |
| #include "google_apis/gcm/engine/mcs_client.h" |
| +#include "google_apis/gcm/engine/registration_request.h" |
| namespace gcm { |
| @@ -32,6 +34,33 @@ class GCM_EXPORT GCMStatsRecorder { |
| std::string details; // Any additional detail about the event. |
| }; |
| + // Contains relevant data of a connection activity. |
| + struct GCM_EXPORT ConnectionActivity : Activity { |
| + ConnectionActivity(); |
| + virtual ~ConnectionActivity(); |
| + |
|
jianli
2014/04/23 17:22:35
nit: remove empty line
juyik
2014/04/23 21:36:56
Done.
|
| + }; |
| + |
| + // Contains relevant data of a registration step. |
| + struct GCM_EXPORT RegistrationActivity : Activity { |
| + RegistrationActivity(); |
| + virtual ~RegistrationActivity(); |
| + |
| + std::string android_id; |
|
jianli
2014/04/23 17:22:35
Is this needed? Android id is one per profile.
juyik
2014/04/23 21:36:56
Done.
|
| + std::string app_id; |
| + std::string sender_ids; // Comma separated sender ids. |
| + }; |
| + |
| + // Contains relevant data of a message receiving event. |
| + struct GCM_EXPORT ReceivingActivity : Activity { |
| + ReceivingActivity(); |
| + virtual ~ReceivingActivity(); |
| + |
| + std::string app_id; |
| + std::string from; |
| + int message_byte_size; |
| + }; |
| + |
| // Contains relevant data of a send-message step. |
| struct GCM_EXPORT SendingActivity : Activity { |
| SendingActivity(); |
| @@ -56,6 +85,49 @@ class GCM_EXPORT GCMStatsRecorder { |
| // Clear all recorded activities. |
| void Clear(); |
| + // Records that a connection to MCS has been initiated. |
| + void RecordConnectionInitiated(const std::string& host); |
| + |
| + // Records that a connection has been delayed due to backoff. |
| + void RecordConnectionDelayedDueToBackoff(int64 delay_msec); |
| + |
| + // Records that connection has been successfully established. |
| + void RecordConnectionSuccess(); |
| + |
| + // Records that connection reset has been signaled. |
| + void RecordConnectionResetSignaled( |
| + ConnectionFactory::ConnectionResetReason reason); |
| + |
| + // Records that a registration request has been sent. This could be initiated |
| + // directly from API, or from retry logic. |
| + void RecordRegistrationSent(const std::string& android_id, |
|
jianli
2014/04/23 17:22:35
No need to record android_id.
juyik
2014/04/23 21:36:56
Done.
|
| + const std::string& app_id, |
| + const std::string& sender_ids); |
| + |
| + // Records that a registration response has been received from server. |
| + void RecordRegistrationResponse(const std::string& android_id, |
|
jianli
2014/04/23 17:22:35
ditto for android_id.
juyik
2014/04/23 21:36:56
Done.
|
| + const std::string& app_id, |
| + const std::vector<std::string>& sender_ids, |
| + RegistrationRequest::Status status); |
| + // Records that a registration retry has been requested. The actual retry |
| + // action may not occur until some time later according to backoff logic. |
| + void RecordRegistrationRetryRequested( |
| + const std::string& android_id, |
|
jianli
2014/04/23 17:22:35
ditto for android_id.
juyik
2014/04/23 21:36:56
Done.
|
| + const std::string& app_id, |
| + const std::vector<std::string>& sender_ids, |
| + int retries_left); |
| + |
| + // Records that a data message has been received. |
| + void RecordDataRecieved(const std::string& app_id, |
|
jianli
2014/04/23 17:22:35
RecordDataMessageReceived
juyik
2014/04/23 21:36:56
Done.
|
| + const std::string& from, |
| + int message_byte_size, |
| + bool to_registered_app); |
|
jianli
2014/04/23 17:22:35
dropped?
juyik
2014/04/23 21:36:56
Not really. This means the received message is mea
|
| + // Records that a received message said data message has been deleted on |
| + // server. |
| + void RecordDataDeletedMessage(const std::string& app_id, |
|
jianli
2014/04/23 17:22:35
RecordMessagesDeletedReceived
juyik
2014/04/23 21:36:56
N/A anymore because I combined merged the 2 method
|
| + const std::string& from, |
| + int message_byte_size); |
| + |
| // Records that an outgoing data message was sent over the wire. |
| void RecordDataSentToWire(const std::string& app_id, |
| const std::string& receiver_id, |
| @@ -74,15 +146,40 @@ class GCM_EXPORT GCMStatsRecorder { |
| const std::string& message_id); |
| // Records that a sending activity has occurred. It will be inserted to the |
| - // front of a queue ao that entries in the queue had reverse chronological |
| + // front of a queue so that entries in the queue had reverse chronological |
| // order. |
| - void CollectSendingActivities(std::vector<SendingActivity>* activities) const; |
| - |
| + void CollectActivities( |
| + std::vector<ConnectionActivity>* connection_activities, |
| + std::vector<RegistrationActivity>* registration_activities, |
| + std::vector<ReceivingActivity>* receiving_activities, |
| + std::vector<SendingActivity>* sending_activities) const; |
| + |
| + const std::deque<ConnectionActivity>& connection_activities() const { |
| + return connection_activities_; |
| + } |
| + const std::deque<RegistrationActivity>& registration_activities() const { |
| + return registration_activities_; |
| + } |
| + const std::deque<ReceivingActivity>& receiving_activities() const { |
| + return receiving_activities_; |
| + } |
| const std::deque<SendingActivity>& sending_activities() const { |
| return sending_activities_; |
| } |
| protected: |
| + void RecordConnection(const std::string& event, |
| + const std::string& details); |
| + void RecordRegistration(const std::string& android_id, |
| + const std::string& app_id, |
| + const std::string& sender_id, |
| + const std::string& event, |
| + const std::string& details); |
| + void RecordReceiving(const std::string& app_id, |
| + const std::string& from, |
| + int message_byte_size, |
| + const std::string& event, |
| + const std::string& details); |
| void RecordSending(const std::string& app_id, |
| const std::string& receiver_id, |
| const std::string& message_id, |
| @@ -91,6 +188,9 @@ class GCM_EXPORT GCMStatsRecorder { |
| bool is_recording_; |
| + std::deque<ConnectionActivity> connection_activities_; |
| + std::deque<RegistrationActivity> registration_activities_; |
| + std::deque<ReceivingActivity> receiving_activities_; |
| std::deque<SendingActivity> sending_activities_; |
| DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder); |