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

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: . 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 c203c2a6bb259545de2d3b32dadd7e57505d4721..d9b8d1ef322897f462eba5be3167037061e8404b 100644
--- a/google_apis/gcm/engine/mcs_client.cc
+++ b/google_apis/gcm/engine/mcs_client.cc
@@ -63,6 +63,30 @@ bool BuildPersistentIdListFromProto(const google::protobuf::string& bytes,
return true;
}
+// Helper for getting string representation of the MessageSendStatus enum.
+std::string GetMessageSendStatusString(
fgorski 2014/03/18 21:28:37 This should happen closer to UI. MCS client should
juyik 2014/03/20 01:09:53 Following my comments about SoC principle in gcm_s
+ gcm::MCSClient::MessageSendStatus status) {
+ switch (status) {
+ case gcm::MCSClient::QUEUED:
+ return "QUEUED";
+ case gcm::MCSClient::SENT:
+ return "SENT";
+ case gcm::MCSClient::QUEUE_SIZE_LIMIT_REACHED:
+ return "QUEUE_SIZE_LIMIT_REACHED";
+ case gcm::MCSClient::APP_QUEUE_SIZE_LIMIT_REACHED:
+ return "APP_QUEUE_SIZE_LIMIT_REACHED";
+ case gcm::MCSClient::MESSAGE_TOO_LARGE:
+ return "MESSAGE_TOO_LARGE";
+ case gcm::MCSClient::NO_CONNECTION_ON_ZERO_TTL:
+ return "NO_CONNECTION_ON_ZERO_TTL";
+ case gcm::MCSClient::TTL_EXCEEDED:
+ return "TTL_EXCEEDED";
+ default:
+ NOTREACHED();
+ return "UNKNOWN";
+ }
+}
+
} // namespace
class CollapseKey {
@@ -128,6 +152,14 @@ ReliablePacketInfo::ReliablePacketInfo()
}
ReliablePacketInfo::~ReliablePacketInfo() {}
+int MCSClient::GetSendQueueSize() const {
+ return to_send_.size();
fgorski 2014/03/18 21:28:37 Could we pass these values to the recorder every t
juyik 2014/03/20 01:09:53 It seems that having a snapshot of these items (li
+}
+
+int MCSClient::GetUnackedQueueSize() const {
+ return to_resend_.size();
+}
+
std::string MCSClient::GetStateString() const {
switch(state_) {
case UNINITIALIZED:
@@ -147,7 +179,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 +193,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 +529,13 @@ void MCSClient::SendPacketToWire(ReliablePacketInfo* packet_info) {
base::Time::kMicrosecondsPerSecond) - sent;
DVLOG(1) << "Message was queued for " << queued << " seconds.";
data_message->set_queued(queued);
+ recorder_->RecordSendWithDetails(
+ data_message->category(),
+ gcm::GCMStatsRecorder::Intermediate,
+ data_message->to(),
+ data_message->id(),
+ packet_info->protobuf->ByteSize(),
+ "SENT TO WIRE");
}
// Set the proper last received stream id to acknowledge received server
@@ -862,6 +903,15 @@ void MCSClient::NotifyMessageSendStatus(
const mcs_proto::DataMessageStanza* data_message_stanza =
reinterpret_cast<const mcs_proto::DataMessageStanza*>(&protobuf);
+ recorder_->RecordSendWithDetails(
+ data_message_stanza->category(),
+ status == SENT ? gcm::GCMStatsRecorder::Success :
+ (status == QUEUED ? gcm::GCMStatsRecorder::Intermediate :
+ gcm::GCMStatsRecorder::Failure),
+ data_message_stanza->to(),
+ data_message_stanza->id(),
+ protobuf.ByteSize(),
+ GetMessageSendStatusString(status));
message_sent_callback_.Run(
data_message_stanza->device_user_id(),
data_message_stanza->category(),

Powered by Google App Engine
This is Rietveld 408576698