| 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..504e81715df9b905aa53553e3ce53f2971f67f80 100644
|
| --- a/google_apis/gcm/monitoring/gcm_stats_recorder.h
|
| +++ b/google_apis/gcm/monitoring/gcm_stats_recorder.h
|
| @@ -11,7 +11,10 @@
|
|
|
| #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"
|
| +#include "google_apis/gcm/engine/unregistration_request.h"
|
|
|
| namespace gcm {
|
|
|
| @@ -32,6 +35,31 @@ 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();
|
| + };
|
| +
|
| + // Contains relevant data of a registration/unregistration step.
|
| + struct GCM_EXPORT RegistrationActivity : Activity {
|
| + RegistrationActivity();
|
| + virtual ~RegistrationActivity();
|
| +
|
| + 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 +84,59 @@ 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& app_id,
|
| + const std::string& sender_ids);
|
| +
|
| + // Records that a registration response has been received from server.
|
| + void RecordRegistrationResponse(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& app_id,
|
| + const std::vector<std::string>& sender_ids,
|
| + int retries_left);
|
| +
|
| + // Records that an unregistration request has been sent. This could be
|
| + // initiated directly from API, or from retry logic.
|
| + void RecordUnregistrationSent(const std::string& app_id);
|
| +
|
| + // Records that an unregistration response has been received from server.
|
| + void RecordUnregistrationResponse(const std::string& app_id,
|
| + UnregistrationRequest::Status status);
|
| +
|
| + // Records that an unregistration retry has been requested and delayed due to
|
| + // backoff logic.
|
| + void RecordUnregistrationRetryDelayed(const std::string& app_id,
|
| + int64 delay_msec);
|
| +
|
| + // Records that a data message has been received. If this message is not
|
| + // sent to a registered app, to_registered_app shoudl be false. If it
|
| + // indicates that a message has been dropped on the server, is_message_dropped
|
| + // should be true.
|
| + void RecordDataMessageRecieved(const std::string& app_id,
|
| + const std::string& from,
|
| + int message_byte_size,
|
| + bool to_registered_app,
|
| + bool is_message_dropped);
|
| +
|
| // 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 +155,39 @@ 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& 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 +196,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);
|
|
|