Chromium Code Reviews| Index: google_apis/gcm/monitoring/gcm_stats_recorder.h |
| diff --git a/google_apis/gcm/monitoring/gcm_stats_recorder.h b/google_apis/gcm/monitoring/gcm_stats_recorder.h |
| index ddae2948cc1f2785bbe1996ce9c12df95d1b4f3f..148bad700bbc5f7814bd92ac4536d6a21560a6f8 100644 |
| --- a/google_apis/gcm/monitoring/gcm_stats_recorder.h |
| +++ b/google_apis/gcm/monitoring/gcm_stats_recorder.h |
| @@ -95,6 +95,15 @@ class GCM_EXPORT GCMStatsRecorder { |
| std::vector<GCMStatsRecorder::SendingActivity> sending_activities; |
| }; |
| + // A delegate interface that allows the GCMStatsRecorder instance to interact |
| + // with its container. |
| + class RecorderDelegate { |
|
jianli
2014/05/06 22:54:53
Simpler to name it as Delegate since it is already
juyik
2014/05/07 00:07:48
Done.
|
| + public: |
| + // Called when the GCMStatsRecorder is recording activities and a new |
| + // activity has just been recorded. |
| + virtual void OnActivityRecorded() = 0; |
| + }; |
| + |
| GCMStatsRecorder(); |
| virtual ~GCMStatsRecorder(); |
| @@ -106,6 +115,9 @@ class GCM_EXPORT GCMStatsRecorder { |
| // Turns recording on/off. |
| void SetRecording(bool recording); |
| + // Set a delegate to receive async callback from the recorder. |
| + void SetDelegate(RecorderDelegate* delegate); |
| + |
| // Clear all recorded activities. |
| void Clear(); |
| @@ -219,6 +231,9 @@ class GCM_EXPORT GCMStatsRecorder { |
| } |
| protected: |
| + // Notify the recorder delegate, if it exists, that an activity has been |
| + // recorded. |
| + void NotifyActivityRecorded(); |
| void RecordCheckin(const std::string& event, |
| const std::string& details); |
| void RecordConnection(const std::string& event, |
| @@ -239,6 +254,7 @@ class GCM_EXPORT GCMStatsRecorder { |
| const std::string& details); |
| bool is_recording_; |
| + RecorderDelegate* delegate_; |
| std::deque<CheckinActivity> checkin_activities_; |
| std::deque<ConnectionActivity> connection_activities_; |