OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <deque> | 10 #include <deque> |
9 #include <string> | 11 #include <string> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
| 14 #include "base/macros.h" |
12 #include "base/time/time.h" | 15 #include "base/time/time.h" |
13 #include "components/gcm_driver/gcm_activity.h" | 16 #include "components/gcm_driver/gcm_activity.h" |
14 #include "google_apis/gcm/engine/connection_factory.h" | 17 #include "google_apis/gcm/engine/connection_factory.h" |
15 #include "google_apis/gcm/engine/mcs_client.h" | 18 #include "google_apis/gcm/engine/mcs_client.h" |
16 #include "google_apis/gcm/engine/registration_request.h" | 19 #include "google_apis/gcm/engine/registration_request.h" |
17 #include "google_apis/gcm/engine/unregistration_request.h" | 20 #include "google_apis/gcm/engine/unregistration_request.h" |
18 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 21 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
19 | 22 |
20 namespace gcm { | 23 namespace gcm { |
21 | 24 |
22 // Records GCM internal stats and activities for debugging purpose. Recording | 25 // Records GCM internal stats and activities for debugging purpose. Recording |
23 // can be turned on/off by calling set_is_recording(...) function. It is turned | 26 // can be turned on/off by calling set_is_recording(...) function. It is turned |
24 // off by default. | 27 // off by default. |
25 // This class is not thread safe. It is meant to be owned by a gcm client | 28 // This class is not thread safe. It is meant to be owned by a gcm client |
26 // instance. | 29 // instance. |
27 class GCMStatsRecorderImpl : public GCMStatsRecorder { | 30 class GCMStatsRecorderImpl : public GCMStatsRecorder { |
28 public: | 31 public: |
29 GCMStatsRecorderImpl(); | 32 GCMStatsRecorderImpl(); |
30 ~GCMStatsRecorderImpl() override; | 33 ~GCMStatsRecorderImpl() override; |
31 | 34 |
32 // Set a delegate to receive callback from the recorder. | 35 // Set a delegate to receive callback from the recorder. |
33 void SetDelegate(Delegate* delegate); | 36 void SetDelegate(Delegate* delegate); |
34 | 37 |
35 // Clear all recorded activities. | 38 // Clear all recorded activities. |
36 void Clear(); | 39 void Clear(); |
37 | 40 |
38 // GCMStatsRecorder implementation: | 41 // GCMStatsRecorder implementation: |
39 void RecordCheckinInitiated(uint64 android_id) override; | 42 void RecordCheckinInitiated(uint64_t android_id) override; |
40 void RecordCheckinDelayedDueToBackoff(int64 delay_msec) override; | 43 void RecordCheckinDelayedDueToBackoff(int64_t delay_msec) override; |
41 void RecordCheckinSuccess() override; | 44 void RecordCheckinSuccess() override; |
42 void RecordCheckinFailure(const std::string& status, | 45 void RecordCheckinFailure(const std::string& status, |
43 bool will_retry) override; | 46 bool will_retry) override; |
44 void RecordConnectionInitiated(const std::string& host) override; | 47 void RecordConnectionInitiated(const std::string& host) override; |
45 void RecordConnectionDelayedDueToBackoff(int64 delay_msec) override; | 48 void RecordConnectionDelayedDueToBackoff(int64_t delay_msec) override; |
46 void RecordConnectionSuccess() override; | 49 void RecordConnectionSuccess() override; |
47 void RecordConnectionFailure(int network_error) override; | 50 void RecordConnectionFailure(int network_error) override; |
48 void RecordConnectionResetSignaled( | 51 void RecordConnectionResetSignaled( |
49 ConnectionFactory::ConnectionResetReason reason) override; | 52 ConnectionFactory::ConnectionResetReason reason) override; |
50 void RecordRegistrationSent(const std::string& app_id, | 53 void RecordRegistrationSent(const std::string& app_id, |
51 const std::string& source) override; | 54 const std::string& source) override; |
52 void RecordRegistrationResponse(const std::string& app_id, | 55 void RecordRegistrationResponse(const std::string& app_id, |
53 const std::string& source, | 56 const std::string& source, |
54 RegistrationRequest::Status status) override; | 57 RegistrationRequest::Status status) override; |
55 void RecordRegistrationRetryDelayed( | 58 void RecordRegistrationRetryDelayed(const std::string& app_id, |
56 const std::string& app_id, | 59 const std::string& source, |
57 const std::string& source, | 60 int64_t delay_msec, |
58 int64 delay_msec, | 61 int retries_left) override; |
59 int retries_left) override; | |
60 void RecordUnregistrationSent(const std::string& app_id, | 62 void RecordUnregistrationSent(const std::string& app_id, |
61 const std::string& source) override; | 63 const std::string& source) override; |
62 void RecordUnregistrationResponse( | 64 void RecordUnregistrationResponse( |
63 const std::string& app_id, | 65 const std::string& app_id, |
64 const std::string& source, | 66 const std::string& source, |
65 UnregistrationRequest::Status status) override; | 67 UnregistrationRequest::Status status) override; |
66 void RecordUnregistrationRetryDelayed(const std::string& app_id, | 68 void RecordUnregistrationRetryDelayed(const std::string& app_id, |
67 const std::string& source, | 69 const std::string& source, |
68 int64 delay_msec, | 70 int64_t delay_msec, |
69 int retries_left) override; | 71 int retries_left) override; |
70 void RecordDataMessageReceived(const std::string& app_id, | 72 void RecordDataMessageReceived(const std::string& app_id, |
71 const std::string& from, | 73 const std::string& from, |
72 int message_byte_size, | 74 int message_byte_size, |
73 bool to_registered_app, | 75 bool to_registered_app, |
74 ReceivedMessageType message_type) override; | 76 ReceivedMessageType message_type) override; |
75 void RecordDataSentToWire(const std::string& app_id, | 77 void RecordDataSentToWire(const std::string& app_id, |
76 const std::string& receiver_id, | 78 const std::string& receiver_id, |
77 const std::string& message_id, | 79 const std::string& message_id, |
78 int queued) override; | 80 int queued) override; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 std::deque<ConnectionActivity> connection_activities_; | 145 std::deque<ConnectionActivity> connection_activities_; |
144 std::deque<RegistrationActivity> registration_activities_; | 146 std::deque<RegistrationActivity> registration_activities_; |
145 std::deque<ReceivingActivity> receiving_activities_; | 147 std::deque<ReceivingActivity> receiving_activities_; |
146 std::deque<SendingActivity> sending_activities_; | 148 std::deque<SendingActivity> sending_activities_; |
147 | 149 |
148 base::TimeTicks last_connection_initiation_time_; | 150 base::TimeTicks last_connection_initiation_time_; |
149 base::TimeTicks last_connection_success_time_; | 151 base::TimeTicks last_connection_success_time_; |
150 bool data_message_received_since_connected_; | 152 bool data_message_received_since_connected_; |
151 base::TimeTicks last_received_data_message_burst_start_time_; | 153 base::TimeTicks last_received_data_message_burst_start_time_; |
152 base::TimeTicks last_received_data_message_time_within_burst_; | 154 base::TimeTicks last_received_data_message_time_within_burst_; |
153 int64 received_data_message_burst_size_; | 155 int64_t received_data_message_burst_size_; |
154 | 156 |
155 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorderImpl); | 157 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorderImpl); |
156 }; | 158 }; |
157 | 159 |
158 } // namespace gcm | 160 } // namespace gcm |
159 | 161 |
160 #endif // COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ | 162 #endif // COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ |
OLD | NEW |