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.
5 #ifndef GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_
6 #define GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_
11 #include "base/time/time.h"
12 #include "google_apis/gcm/base/gcm_export.h"
13 #include "google_apis/gcm/engine/connection_factory.h"
14 #include "google_apis/gcm/engine/mcs_client.h"
15 #include "google_apis/gcm/engine/registration_request.h"
16 #include "google_apis/gcm/engine/unregistration_request.h"
20 // Defines the interface to record GCM internal stats and activities for
22 class GCM_EXPORT GCMStatsRecorder
{
24 // Type of a received message
25 enum ReceivedMessageType
{
28 // Message that indicates some messages have been deleted on the server.
32 // A delegate interface that allows the GCMStatsRecorderImpl instance to
33 // interact with its container.
36 // Called when the GCMStatsRecorderImpl is recording activities and a new
37 // activity has just been recorded.
38 virtual void OnActivityRecorded() = 0;
42 virtual ~GCMStatsRecorder() {}
44 // Records that a check-in has been initiated.
45 virtual void RecordCheckinInitiated(uint64 android_id
) = 0;
47 // Records that a check-in has been delayed due to backoff.
48 virtual void RecordCheckinDelayedDueToBackoff(int64 delay_msec
) = 0;
50 // Records that a check-in request has succeeded.
51 virtual void RecordCheckinSuccess() = 0;
53 // Records that a check-in request has failed. If a retry will be tempted then
54 // will_retry should be true.
55 virtual void RecordCheckinFailure(std::string status
, bool will_retry
) = 0;
57 // Records that a connection to MCS has been initiated.
58 virtual void RecordConnectionInitiated(const std::string
& host
) = 0;
60 // Records that a connection has been delayed due to backoff.
61 virtual void RecordConnectionDelayedDueToBackoff(int64 delay_msec
) = 0;
63 // Records that connection has been successfully established.
64 virtual void RecordConnectionSuccess() = 0;
66 // Records that connection has failed with a network error code.
67 virtual void RecordConnectionFailure(int network_error
) = 0;
69 // Records that connection reset has been signaled.
70 virtual void RecordConnectionResetSignaled(
71 ConnectionFactory::ConnectionResetReason reason
) = 0;
73 // Records that a registration request has been sent. This could be initiated
74 // directly from API, or from retry logic.
75 virtual void RecordRegistrationSent(const std::string
& app_id
,
76 const std::string
& source
) = 0;
78 // Records that a registration response has been received from server.
79 virtual void RecordRegistrationResponse(
80 const std::string
& app_id
,
81 const std::string
& source
,
82 RegistrationRequest::Status status
) = 0;
84 // Records that a registration retry has been requested and delayed due to
86 virtual void RecordRegistrationRetryDelayed(
87 const std::string
& app_id
,
88 const std::string
& source
,
90 int retries_left
) = 0;
92 // Records that an unregistration request has been sent. This could be
93 // initiated directly from API, or from retry logic.
94 virtual void RecordUnregistrationSent(const std::string
& app_id
,
95 const std::string
& source
) = 0;
97 // Records that an unregistration response has been received from server.
98 virtual void RecordUnregistrationResponse(
99 const std::string
& app_id
,
100 const std::string
& source
,
101 UnregistrationRequest::Status status
) = 0;
103 // Records that an unregistration retry has been requested and delayed due to
105 virtual void RecordUnregistrationRetryDelayed(const std::string
& app_id
,
106 const std::string
& source
,
108 int retries_left
) = 0;
110 // Records that a data message has been received. If this message is not
111 // sent to a registered app, to_registered_app shoudl be false. If it
112 // indicates that a message has been dropped on the server, is_message_dropped
114 virtual void RecordDataMessageReceived(const std::string
& app_id
,
115 const std::string
& from
,
116 int message_byte_size
,
117 bool to_registered_app
,
118 ReceivedMessageType message_type
) = 0;
120 // Records that an outgoing data message was sent over the wire.
121 virtual void RecordDataSentToWire(const std::string
& app_id
,
122 const std::string
& receiver_id
,
123 const std::string
& message_id
,
125 // Records that the MCS client sent a 'send status' notification to callback.
126 virtual void RecordNotifySendStatus(const std::string
& app_id
,
127 const std::string
& receiver_id
,
128 const std::string
& message_id
,
129 MCSClient::MessageSendStatus status
,
132 // Records that a 'send error' message was received.
133 virtual void RecordIncomingSendError(const std::string
& app_id
,
134 const std::string
& receiver_id
,
135 const std::string
& message_id
) = 0;
140 #endif // GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_