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

Unified Diff: google_apis/gcm/engine/mcs_client.cc

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: Resolving another merge conflict. 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gcm/engine/mcs_client.cc
diff --git a/google_apis/gcm/engine/mcs_client.cc b/google_apis/gcm/engine/mcs_client.cc
index da8300c799266957263fff5d38b676d114e8e1f8..72432c29d45532e811348a8287087f0cb9415336 100644
--- a/google_apis/gcm/engine/mcs_client.cc
+++ b/google_apis/gcm/engine/mcs_client.cc
@@ -10,11 +10,13 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
jianli 2014/03/26 20:17:18 nit: is this needed?
juyik 2014/03/26 20:57:32 Done. Not anymore.
#include "base/time/clock.h"
#include "base/time/time.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/base/socket_stream.h"
#include "google_apis/gcm/engine/connection_factory.h"
+#include "google_apis/gcm/gcm_stats_recorder.h"
using namespace google::protobuf::io;
@@ -128,6 +130,14 @@ ReliablePacketInfo::ReliablePacketInfo()
}
ReliablePacketInfo::~ReliablePacketInfo() {}
+int MCSClient::GetSendQueueSize() const {
+ return to_send_.size();
+}
+
+int MCSClient::GetUnackedQueueSize() const {
+ return to_resend_.size();
+}
+
std::string MCSClient::GetStateString() const {
switch(state_) {
case UNINITIALIZED:
@@ -147,7 +157,8 @@ std::string MCSClient::GetStateString() const {
MCSClient::MCSClient(const std::string& version_string,
base::Clock* clock,
ConnectionFactory* connection_factory,
- GCMStore* gcm_store)
+ GCMStore* gcm_store,
+ GCMStatsRecorder* recorder)
: version_string_(version_string),
clock_(clock),
state_(UNINITIALIZED),
@@ -160,6 +171,7 @@ MCSClient::MCSClient(const std::string& version_string,
stream_id_out_(0),
stream_id_in_(0),
gcm_store_(gcm_store),
+ recorder_(recorder),
weak_ptr_factory_(this) {
}
@@ -495,6 +507,11 @@ void MCSClient::SendPacketToWire(ReliablePacketInfo* packet_info) {
base::Time::kMicrosecondsPerSecond) - sent;
DVLOG(1) << "Message was queued for " << queued << " seconds.";
data_message->set_queued(queued);
+ recorder_->RecordSentToWire(
+ data_message->category(),
+ data_message->to(),
+ data_message->id(),
+ queued);
}
// Set the proper last received stream id to acknowledge received server
@@ -862,6 +879,13 @@ void MCSClient::NotifyMessageSendStatus(
const mcs_proto::DataMessageStanza* data_message_stanza =
reinterpret_cast<const mcs_proto::DataMessageStanza*>(&protobuf);
+ recorder_->RecordNotifySendStatus(
+ data_message_stanza->category(),
+ data_message_stanza->to(),
+ data_message_stanza->id(),
+ status,
+ protobuf.ByteSize(),
+ data_message_stanza->ttl());
message_sent_callback_.Run(
data_message_stanza->device_user_id(),
data_message_stanza->category(),

Powered by Google App Engine
This is Rietveld 408576698