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 <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "components/gcm_driver/gcm_activity.h" | 13 #include "components/gcm_driver/gcm_activity.h" |
14 #include "google_apis/gcm/engine/connection_factory.h" | 14 #include "google_apis/gcm/engine/connection_factory.h" |
15 #include "google_apis/gcm/engine/mcs_client.h" | 15 #include "google_apis/gcm/engine/mcs_client.h" |
16 #include "google_apis/gcm/engine/registration_request.h" | 16 #include "google_apis/gcm/engine/registration_request.h" |
17 #include "google_apis/gcm/engine/unregistration_request.h" | 17 #include "google_apis/gcm/engine/unregistration_request.h" |
18 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 18 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
19 | 19 |
20 namespace gcm { | 20 namespace gcm { |
21 | 21 |
22 // Records GCM internal stats and activities for debugging purpose. Recording | 22 // Records GCM internal stats and activities for debugging purpose. Recording |
23 // can be turned on/off by calling SetRecording(...) function. It is turned off | 23 // can be turned on/off by calling set_is_recording(...) function. It is turned |
24 // by default. | 24 // off by default. |
25 // This class is not thread safe. It is meant to be owned by a gcm client | 25 // This class is not thread safe. It is meant to be owned by a gcm client |
26 // instance. | 26 // instance. |
27 class GCMStatsRecorderImpl : public GCMStatsRecorder { | 27 class GCMStatsRecorderImpl : public GCMStatsRecorder { |
28 public: | 28 public: |
29 GCMStatsRecorderImpl(); | 29 GCMStatsRecorderImpl(); |
30 ~GCMStatsRecorderImpl() override; | 30 ~GCMStatsRecorderImpl() override; |
31 | 31 |
32 // Indicates whether the recorder is currently recording activities or not. | |
33 bool is_recording() const { | |
34 return is_recording_; | |
35 } | |
36 | |
37 // Turns recording on/off. | |
38 void SetRecording(bool recording); | |
39 | |
40 // Set a delegate to receive callback from the recorder. | 32 // Set a delegate to receive callback from the recorder. |
41 void SetDelegate(Delegate* delegate); | 33 void SetDelegate(Delegate* delegate); |
42 | 34 |
43 // Clear all recorded activities. | 35 // Clear all recorded activities. |
44 void Clear(); | 36 void Clear(); |
45 | 37 |
46 // GCMStatsRecorder implementation: | 38 // GCMStatsRecorder implementation: |
47 void RecordCheckinInitiated(uint64 android_id) override; | 39 void RecordCheckinInitiated(uint64 android_id) override; |
48 void RecordCheckinDelayedDueToBackoff(int64 delay_msec) override; | 40 void RecordCheckinDelayedDueToBackoff(int64 delay_msec) override; |
49 void RecordCheckinSuccess() override; | 41 void RecordCheckinSuccess() override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void RecordNotifySendStatus(const std::string& app_id, | 79 void RecordNotifySendStatus(const std::string& app_id, |
88 const std::string& receiver_id, | 80 const std::string& receiver_id, |
89 const std::string& message_id, | 81 const std::string& message_id, |
90 MCSClient::MessageSendStatus status, | 82 MCSClient::MessageSendStatus status, |
91 int byte_size, | 83 int byte_size, |
92 int ttl) override; | 84 int ttl) override; |
93 void RecordIncomingSendError(const std::string& app_id, | 85 void RecordIncomingSendError(const std::string& app_id, |
94 const std::string& receiver_id, | 86 const std::string& receiver_id, |
95 const std::string& message_id) override; | 87 const std::string& message_id) override; |
96 | 88 |
97 // Collect all recorded activities into the struct. | 89 // Collect all recorded activities into |*recorded_activities|. |
98 void CollectActivities(RecordedActivities* recorder_activities) const; | 90 void CollectActivities(RecordedActivities* recorded_activities) const; |
| 91 |
| 92 bool is_recording() const { return is_recording_; } |
| 93 void set_is_recording(bool recording) { is_recording_ = recording; } |
99 | 94 |
100 const std::deque<CheckinActivity>& checkin_activities() const { | 95 const std::deque<CheckinActivity>& checkin_activities() const { |
101 return checkin_activities_; | 96 return checkin_activities_; |
102 } | 97 } |
103 const std::deque<ConnectionActivity>& connection_activities() const { | 98 const std::deque<ConnectionActivity>& connection_activities() const { |
104 return connection_activities_; | 99 return connection_activities_; |
105 } | 100 } |
106 const std::deque<RegistrationActivity>& registration_activities() const { | 101 const std::deque<RegistrationActivity>& registration_activities() const { |
107 return registration_activities_; | 102 return registration_activities_; |
108 } | 103 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 base::TimeTicks last_received_data_message_burst_start_time_; | 151 base::TimeTicks last_received_data_message_burst_start_time_; |
157 base::TimeTicks last_received_data_message_time_within_burst_; | 152 base::TimeTicks last_received_data_message_time_within_burst_; |
158 int64 received_data_message_burst_size_; | 153 int64 received_data_message_burst_size_; |
159 | 154 |
160 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorderImpl); | 155 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorderImpl); |
161 }; | 156 }; |
162 | 157 |
163 } // namespace gcm | 158 } // namespace gcm |
164 | 159 |
165 #endif // COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ | 160 #endif // COMPONENTS_GCM_DRIVER_GCM_STATS_RECORDER_IMPL_H_ |
OLD | NEW |