Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: google_apis/gcm/monitoring/gcm_stats_recorder.h

Issue 294053017: Move all gcm activity types out of GCMStatsRecorder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ 5 #ifndef GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
6 #define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ 6 #define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_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 "google_apis/gcm/base/gcm_export.h" 13 #include "google_apis/gcm/base/gcm_export.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/gcm_activity.h"
18 19
19 namespace gcm { 20 namespace gcm {
20 21
21 // Records GCM internal stats and activities for debugging purpose. Recording 22 // Records GCM internal stats and activities for debugging purpose. Recording
22 // can be turned on/off by calling SetRecording(...) function. It is turned off 23 // can be turned on/off by calling SetRecording(...) function. It is turned off
23 // by default. 24 // by default.
24 // 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
25 // instance. 26 // instance.
26 class GCM_EXPORT GCMStatsRecorder { 27 class GCM_EXPORT GCMStatsRecorder {
27 public: 28 public:
28 // Type of a received message 29 // Type of a received message
29 enum ReceivedMessageType { 30 enum ReceivedMessageType {
30 // Data message. 31 // Data message.
31 DATA_MESSAGE, 32 DATA_MESSAGE,
32 // Message that indicates some messages have been deleted on the server. 33 // Message that indicates some messages have been deleted on the server.
33 DELETED_MESSAGES, 34 DELETED_MESSAGES,
34 }; 35 };
35 36
36 // Contains data that are common to all activity kinds below.
37 struct GCM_EXPORT Activity {
38 Activity();
39 virtual ~Activity();
40
41 base::Time time;
42 std::string event; // A short description of the event.
43 std::string details; // Any additional detail about the event.
44 };
45
46 // Contains relevant data of a connection activity.
47 struct GCM_EXPORT ConnectionActivity : Activity {
48 ConnectionActivity();
49 virtual ~ConnectionActivity();
50 };
51
52 // Contains relevant data of a check-in activity.
53 struct GCM_EXPORT CheckinActivity : Activity {
54 CheckinActivity();
55 virtual ~CheckinActivity();
56 };
57
58 // Contains relevant data of a registration/unregistration step.
59 struct GCM_EXPORT RegistrationActivity : Activity {
60 RegistrationActivity();
61 virtual ~RegistrationActivity();
62
63 std::string app_id;
64 std::string sender_ids; // Comma separated sender ids.
65 };
66
67 // Contains relevant data of a message receiving event.
68 struct GCM_EXPORT ReceivingActivity : Activity {
69 ReceivingActivity();
70 virtual ~ReceivingActivity();
71
72 std::string app_id;
73 std::string from;
74 int message_byte_size;
75 };
76
77 // Contains relevant data of a send-message step.
78 struct GCM_EXPORT SendingActivity : Activity {
79 SendingActivity();
80 virtual ~SendingActivity();
81
82 std::string app_id;
83 std::string receiver_id;
84 std::string message_id;
85 };
86
87 struct GCM_EXPORT RecordedActivities {
88 RecordedActivities();
89 virtual ~RecordedActivities();
90
91 std::vector<GCMStatsRecorder::CheckinActivity> checkin_activities;
92 std::vector<GCMStatsRecorder::ConnectionActivity> connection_activities;
93 std::vector<GCMStatsRecorder::RegistrationActivity> registration_activities;
94 std::vector<GCMStatsRecorder::ReceivingActivity> receiving_activities;
95 std::vector<GCMStatsRecorder::SendingActivity> sending_activities;
96 };
97
98 // A delegate interface that allows the GCMStatsRecorder instance to interact 37 // A delegate interface that allows the GCMStatsRecorder instance to interact
99 // with its container. 38 // with its container.
100 class Delegate { 39 class Delegate {
101 public: 40 public:
102 // Called when the GCMStatsRecorder is recording activities and a new 41 // Called when the GCMStatsRecorder is recording activities and a new
103 // activity has just been recorded. 42 // activity has just been recorded.
104 virtual void OnActivityRecorded() = 0; 43 virtual void OnActivityRecorded() = 0;
105 }; 44 };
106 45
107 GCMStatsRecorder(); 46 GCMStatsRecorder();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 std::deque<RegistrationActivity> registration_activities_; 205 std::deque<RegistrationActivity> registration_activities_;
267 std::deque<ReceivingActivity> receiving_activities_; 206 std::deque<ReceivingActivity> receiving_activities_;
268 std::deque<SendingActivity> sending_activities_; 207 std::deque<SendingActivity> sending_activities_;
269 208
270 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder); 209 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder);
271 }; 210 };
272 211
273 } // namespace gcm 212 } // namespace gcm
274 213
275 #endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_ 214 #endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698