Roll src/third_party/WebKit 3529d49:06e8485 (svn 202554:202555)
[chromium-blink-merge.git] / google_apis / gcm / monitoring / gcm_stats_recorder.h
blob8a093ebbb8232556118c15e3215cfb36651b29fa
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_
8 #include <string>
9 #include <vector>
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"
18 namespace gcm {
20 // Defines the interface to record GCM internal stats and activities for
21 // debugging purpose.
22 class GCM_EXPORT GCMStatsRecorder {
23 public:
24 // Type of a received message
25 enum ReceivedMessageType {
26 // Data message.
27 DATA_MESSAGE,
28 // Message that indicates some messages have been deleted on the server.
29 DELETED_MESSAGES,
32 // A delegate interface that allows the GCMStatsRecorderImpl instance to
33 // interact with its container.
34 class Delegate {
35 public:
36 // Called when the GCMStatsRecorderImpl is recording activities and a new
37 // activity has just been recorded.
38 virtual void OnActivityRecorded() = 0;
41 GCMStatsRecorder() {}
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
85 // backoff logic.
86 virtual void RecordRegistrationRetryDelayed(
87 const std::string& app_id,
88 const std::string& source,
89 int64 delay_msec,
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
104 // backoff logic.
105 virtual void RecordUnregistrationRetryDelayed(const std::string& app_id,
106 const std::string& source,
107 int64 delay_msec,
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
113 // should be true.
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,
124 int queued) = 0;
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,
130 int byte_size,
131 int ttl) = 0;
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;
138 } // namespace gcm
140 #endif // GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_