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

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

Issue 202083005: Add activity recording capability to gcm internals page. User can refresh, start/stop recording, an… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing arv's comments. Created 6 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
6 #define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
7
8 #include <deque>
9 #include <string>
10 #include <vector>
11
12 #include "base/compiler_specific.h"
13 #include "base/time/time.h"
14 #include "google_apis/gcm/base/gcm_export.h"
15 #include "google_apis/gcm/engine/mcs_client.h"
16
17 namespace gcm {
18
19 // Records GCM internal stats and activities for debugging purpose. Recording
20 // can be turned on/off by calling SetRecording(...) function. It is turned off
21 // by default.
22 // This class is not thread safe. It is meant to be owned by a gcm client
23 // instance.
24 class GCM_EXPORT GCMStatsRecorder {
25 public:
26 // Contains data that are common to all activity kinds below.
27 struct GCM_EXPORT Activity {
28 Activity();
29 virtual ~Activity();
30
31 base::Time time;
32 std::string event; // A short description of the event.
33 std::string details; // Any additional detail about the event.
34 };
35
36 // Contains relevant data of a send-message step.
37 struct GCM_EXPORT SendingActivity : Activity {
38 SendingActivity();
39 virtual ~SendingActivity() OVERRIDE;
40
41 std::string app_id;
42 std::string receiver_id;
43 std::string message_id;
44 };
45
46 GCMStatsRecorder();
47 virtual ~GCMStatsRecorder();
48
49 // Indicates whether the recorder is currently recording activities or not.
50 bool is_recording() const {
51 return is_recording_;
52 }
53
54 // Turns recording on/off.
55 void SetRecording(bool recording);
56
57 // Clear all recorded activities.
58 void Clear();
59
60 // Records when the outgoing message is sent to wire.
61 void RecordSentToWire(const std::string& app_id,
62 const std::string& receiver_id,
63 const std::string& message_id,
64 int queued);
65 // Records when the MCS client sends a send status notification to callback.
66 void RecordNotifySendStatus(const std::string& app_id,
67 const std::string& receiver_id,
68 const std::string& message_id,
69 MCSClient::MessageSendStatus status,
70 int byte_size,
71 int ttl);
72 // Records when a 'send error' message is received.
73 void RecordIncomingSendError(const std::string& app_id,
74 const std::string& receiver_id,
75 const std::string& message_id,
76 int byte_size,
77 int ttl);
78
79 const std::deque<SendingActivity>& sending_activities() const {
80 return sending_activities_;
81 }
82
83 protected:
84 void RecordSending(const std::string& app_id,
85 const std::string& receiver_id,
86 const std::string& message_id,
87 const std::string& event,
88 const std::string& details);
89
90 bool is_recording_;
91
92 std::deque<SendingActivity> sending_activities_;
Nicolas Zea 2014/03/27 18:55:42 If this is a circular buffer, why use a dequeue ra
juyik 2014/03/27 20:05:11 My intention is to display events in reverse chron
93
94 DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder);
95 };
96
97 } // namespace gcm
98
99 #endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698