Remove implicit conversions from scoped_refptr to T* in base/
[chromium-blink-merge.git] / google_apis / gcm / monitoring / gcm_stats_recorder.h
blob71915693fdabebb550c10fdceccb885ee0691c51
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& sender_ids) = 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::vector<std::string>& sender_ids,
82 RegistrationRequest::Status status) = 0;
84 // Records that a registration retry has been requested. The actual retry
85 // action may not occur until some time later according to backoff logic.
86 virtual void RecordRegistrationRetryRequested(
87 const std::string& app_id,
88 const std::vector<std::string>& sender_ids,
89 int retries_left) = 0;
91 // Records that an unregistration request has been sent. This could be
92 // initiated directly from API, or from retry logic.
93 virtual void RecordUnregistrationSent(const std::string& app_id) = 0;
95 // Records that an unregistration response has been received from server.
96 virtual void RecordUnregistrationResponse(
97 const std::string& app_id,
98 UnregistrationRequest::Status status) = 0;
100 // Records that an unregistration retry has been requested and delayed due to
101 // backoff logic.
102 virtual void RecordUnregistrationRetryDelayed(const std::string& app_id,
103 int64 delay_msec) = 0;
105 // Records that a data message has been received. If this message is not
106 // sent to a registered app, to_registered_app shoudl be false. If it
107 // indicates that a message has been dropped on the server, is_message_dropped
108 // should be true.
109 virtual void RecordDataMessageReceived(const std::string& app_id,
110 const std::string& from,
111 int message_byte_size,
112 bool to_registered_app,
113 ReceivedMessageType message_type) = 0;
115 // Records that an outgoing data message was sent over the wire.
116 virtual void RecordDataSentToWire(const std::string& app_id,
117 const std::string& receiver_id,
118 const std::string& message_id,
119 int queued) = 0;
120 // Records that the MCS client sent a 'send status' notification to callback.
121 virtual void RecordNotifySendStatus(const std::string& app_id,
122 const std::string& receiver_id,
123 const std::string& message_id,
124 MCSClient::MessageSendStatus status,
125 int byte_size,
126 int ttl) = 0;
127 // Records that a 'send error' message was received.
128 virtual void RecordIncomingSendError(const std::string& app_id,
129 const std::string& receiver_id,
130 const std::string& message_id) = 0;
133 } // namespace gcm
135 #endif // GOOGLE_APIS_GCM_MONITORING_GCM_STATS_RECORDER_H_