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

Unified Diff: google_apis/gcm/monitoring/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: . Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/gcm_client_impl_unittest.cc ('k') | google_apis/gcm/monitoring/gcm_stats_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..71b6c6ac35e25d0cb29cfb9fc60f001e70fa3a2a
--- /dev/null
+++ b/google_apis/gcm/monitoring/gcm_stats_recorder.h
@@ -0,0 +1,101 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
+#define GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
+
+#include <deque>
+#include <string>
+#include <vector>
+
+#include "base/time/time.h"
+#include "google_apis/gcm/base/gcm_export.h"
+#include "google_apis/gcm/engine/mcs_client.h"
+
+namespace gcm {
+
+// Records GCM internal stats and activities for debugging purpose. Recording
+// can be turned on/off by calling SetRecording(...) function. It is turned off
+// by default.
+// This class is not thread safe. It is meant to be owned by a gcm client
+// instance.
+class GCM_EXPORT GCMStatsRecorder {
+ public:
+ // Contains data that are common to all activity kinds below.
+ struct GCM_EXPORT Activity {
+ Activity();
+ virtual ~Activity();
+
+ base::Time time;
+ std::string event; // A short description of the event.
+ std::string details; // Any additional detail about the event.
+ };
+
+ // Contains relevant data of a send-message step.
+ struct GCM_EXPORT SendingActivity : Activity {
+ SendingActivity();
+ virtual ~SendingActivity();
+
+ std::string app_id;
+ std::string receiver_id;
+ std::string message_id;
+ };
+
+ GCMStatsRecorder();
+ virtual ~GCMStatsRecorder();
+
+ // Indicates whether the recorder is currently recording activities or not.
+ bool is_recording() const {
+ return is_recording_;
+ }
+
+ // Turns recording on/off.
+ void SetRecording(bool recording);
+
+ // Clear all recorded activities.
+ void Clear();
+
+ // Records that an outgoing data message was sent over the wire.
+ void RecordDataSentToWire(const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id,
+ int queued);
+ // Records that the MCS client sent a 'send status' notification to callback.
+ void RecordNotifySendStatus(const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id,
+ MCSClient::MessageSendStatus status,
+ int byte_size,
+ int ttl);
+ // Records that a 'send error' message was received.
+ void RecordIncomingSendError(const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id);
+
+ // Records that a sending activity has occurred. It will be inserted to the
+ // front of a queue ao that entries in the queue had reverse chronological
+ // order.
+ void CollectSendingActivities(std::vector<SendingActivity>* activities) const;
+
+ const std::deque<SendingActivity>& sending_activities() const {
+ return sending_activities_;
+ }
+
+ protected:
+ void RecordSending(const std::string& app_id,
+ const std::string& receiver_id,
+ const std::string& message_id,
+ const std::string& event,
+ const std::string& details);
+
+ bool is_recording_;
+
+ std::deque<SendingActivity> sending_activities_;
+
+ DISALLOW_COPY_AND_ASSIGN(GCMStatsRecorder);
+};
+
+} // namespace gcm
+
+#endif // GOOGLE_APIS_GCM_GCM_STATS_RECORDER_H_
« no previous file with comments | « google_apis/gcm/gcm_client_impl_unittest.cc ('k') | google_apis/gcm/monitoring/gcm_stats_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698