Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: google_apis/gcm/monitoring/gcm_stats_recorder.h

Issue 248213004: Record connection, registration, and receiving activities. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add struct constructor/destructor. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/gcm_client_impl_unittest.cc ('k') | google_apis/gcm/monitoring/gcm_stats_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b1b6cdda686896fb548829d6b596e031d85f4791 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();
@@ -42,6 +70,16 @@ class GCM_EXPORT GCMStatsRecorder {
std::string message_id;
};
+ struct GCM_EXPORT RecordedActivities {
+ RecordedActivities();
+ virtual ~RecordedActivities();
+
+ std::vector<GCMStatsRecorder::ConnectionActivity> connection_activities;
+ std::vector<GCMStatsRecorder::RegistrationActivity> registration_activities;
+ std::vector<GCMStatsRecorder::ReceivingActivity> receiving_activities;
+ std::vector<GCMStatsRecorder::SendingActivity> sending_activities;
+ };
+
GCMStatsRecorder();
virtual ~GCMStatsRecorder();
@@ -56,6 +94,66 @@ class GCM_EXPORT GCMStatsRecorder {
// Clear all recorded activities.
void Clear();
+ // All RecordXXXX methods below will record one activity. It will be inserted
+ // to the front of a queue so that entries in the queue had reverse
+ // chronological order.
+
+ // 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 has failed with a network error code.
+ void RecordConnectionFailure(int network_error);
+
+ // 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,
Nicolas Zea 2014/04/24 21:37:43 nit: style guide prefers using an enum rather than
juyik 2014/04/25 20:37:39 Done. Added enum of received message type.
+ 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,
@@ -73,16 +171,34 @@ class GCM_EXPORT GCMStatsRecorder {
const std::string& receiver_id,
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
- // order.
- void CollectSendingActivities(std::vector<SendingActivity>* activities) const;
+ // Collect all recorded activities into the struct.
+ void CollectActivities(RecordedActivities* recorder_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 +207,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);
« no previous file with comments | « google_apis/gcm/gcm_client_impl_unittest.cc ('k') | google_apis/gcm/monitoring/gcm_stats_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698