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> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" |
16 #include "components/gcm_driver/gcm_activity.h" | 17 #include "components/gcm_driver/gcm_activity.h" |
17 #include "google_apis/gcm/engine/connection_factory.h" | 18 #include "google_apis/gcm/engine/connection_factory.h" |
18 #include "google_apis/gcm/engine/mcs_client.h" | 19 #include "google_apis/gcm/engine/mcs_client.h" |
19 #include "google_apis/gcm/engine/registration_request.h" | 20 #include "google_apis/gcm/engine/registration_request.h" |
20 #include "google_apis/gcm/engine/unregistration_request.h" | 21 #include "google_apis/gcm/engine/unregistration_request.h" |
21 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 22 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
22 | 23 |
23 namespace gcm { | 24 namespace gcm { |
24 | 25 |
25 // Records GCM internal stats and activities for debugging purpose. Recording | 26 // Records GCM internal stats and activities for debugging purpose. Recording |
26 // can be turned on/off by calling set_is_recording(...) function. It is turned | 27 // can be turned on/off by calling set_is_recording(...) function. It is turned |
27 // off by default. | 28 // off by default. |
28 // This class is not thread safe. It is meant to be owned by a gcm client | 29 // This class is not thread safe. It is meant to be owned by a gcm client |
29 // instance. | 30 // instance. |
30 class GCMStatsRecorderImpl : public GCMStatsRecorder { | 31 class GCMStatsRecorderImpl : public GCMStatsRecorder { |
31 public: | 32 public: |
32 GCMStatsRecorderImpl(); | 33 GCMStatsRecorderImpl(); |
33 ~GCMStatsRecorderImpl() override; | 34 ~GCMStatsRecorderImpl() override; |
34 | 35 |
35 // Set a delegate to receive callback from the recorder. | 36 // Set a delegate to receive callback from the recorder. |
36 void SetDelegate(Delegate* delegate); | 37 void SetDelegate(Delegate* delegate); |
37 | 38 |
38 // Clear all recorded activities. | 39 // Clear all recorded activities. |
39 void Clear(); | 40 void Clear(); |
40 | 41 |
| 42 // Records a message decryption failure caused by |reason| for |app_id|. |
| 43 void RecordDecryptionFailure(const std::string& app_id, |
| 44 GCMEncryptionProvider::DecryptionFailure reason); |
| 45 |
41 // GCMStatsRecorder implementation: | 46 // GCMStatsRecorder implementation: |
42 void RecordCheckinInitiated(uint64_t android_id) override; | 47 void RecordCheckinInitiated(uint64_t android_id) override; |
43 void RecordCheckinDelayedDueToBackoff(int64_t delay_msec) override; | 48 void RecordCheckinDelayedDueToBackoff(int64_t delay_msec) override; |
44 void RecordCheckinSuccess() override; | 49 void RecordCheckinSuccess() override; |
45 void RecordCheckinFailure(const std::string& status, | 50 void RecordCheckinFailure(const std::string& status, |
46 bool will_retry) override; | 51 bool will_retry) override; |
47 void RecordConnectionInitiated(const std::string& host) override; | 52 void RecordConnectionInitiated(const std::string& host) override; |
48 void RecordConnectionDelayedDueToBackoff(int64_t delay_msec) override; | 53 void RecordConnectionDelayedDueToBackoff(int64_t delay_msec) override; |
49 void RecordConnectionSuccess() override; | 54 void RecordConnectionSuccess() override; |
50 void RecordConnectionFailure(int network_error) override; | 55 void RecordConnectionFailure(int network_error) override; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 107 } |
103 const std::deque<RegistrationActivity>& registration_activities() const { | 108 const std::deque<RegistrationActivity>& registration_activities() const { |
104 return registration_activities_; | 109 return registration_activities_; |
105 } | 110 } |
106 const std::deque<ReceivingActivity>& receiving_activities() const { | 111 const std::deque<ReceivingActivity>& receiving_activities() const { |
107 return receiving_activities_; | 112 return receiving_activities_; |
108 } | 113 } |
109 const std::deque<SendingActivity>& sending_activities() const { | 114 const std::deque<SendingActivity>& sending_activities() const { |
110 return sending_activities_; | 115 return sending_activities_; |
111 } | 116 } |
| 117 const std::deque<DecryptionFailureActivity>& decryption_failure_activities() |
| 118 const { |
| 119 return decryption_failure_activities_; |
| 120 } |
112 | 121 |
113 protected: | 122 protected: |
114 // Notify the recorder delegate, if it exists, that an activity has been | 123 // Notify the recorder delegate, if it exists, that an activity has been |
115 // recorded. | 124 // recorded. |
116 void NotifyActivityRecorded(); | 125 void NotifyActivityRecorded(); |
117 | 126 |
118 void RecordCheckin(const std::string& event, | 127 void RecordCheckin(const std::string& event, |
119 const std::string& details); | 128 const std::string& details); |
120 | 129 |
121 void RecordConnection(const std::string& event, | 130 void RecordConnection(const std::string& event, |
(...skipping 17 matching lines...) Expand all Loading... |
139 const std::string& details); | 148 const std::string& details); |
140 | 149 |
141 bool is_recording_; | 150 bool is_recording_; |
142 Delegate* delegate_; | 151 Delegate* delegate_; |
143 | 152 |
144 std::deque<CheckinActivity> checkin_activities_; | 153 std::deque<CheckinActivity> checkin_activities_; |
145 std::deque<ConnectionActivity> connection_activities_; | 154 std::deque<ConnectionActivity> connection_activities_; |
146 std::deque<RegistrationActivity> registration_activities_; | 155 std::deque<RegistrationActivity> registration_activities_; |
147 std::deque<ReceivingActivity> receiving_activities_; | 156 std::deque<ReceivingActivity> receiving_activities_; |
148 std::deque<SendingActivity> sending_activities_; | 157 std::deque<SendingActivity> sending_activities_; |
| 158 std::deque<DecryptionFailureActivity> decryption_failure_activities_; |
149 | 159 |
150 base::TimeTicks last_connection_initiation_time_; | 160 base::TimeTicks last_connection_initiation_time_; |
151 base::TimeTicks last_connection_success_time_; | 161 base::TimeTicks last_connection_success_time_; |
152 bool data_message_received_since_connected_; | 162 bool data_message_received_since_connected_; |
153 base::TimeTicks last_received_data_message_burst_start_time_; | 163 base::TimeTicks last_received_data_message_burst_start_time_; |
154 base::TimeTicks last_received_data_message_time_within_burst_; | 164 base::TimeTicks last_received_data_message_time_within_burst_; |
155 int64_t received_data_message_burst_size_; | 165 int64_t received_data_message_burst_size_; |
156 | 166 |
157 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorderImpl); | 167 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorderImpl); |
158 }; | 168 }; |
159 | 169 |
160 } // namespace gcm | 170 } // namespace gcm |
161 | 171 |
162 #endif // COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ | 172 #endif // COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ |
OLD | NEW |