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

Unified Diff: google_apis/gcm/gcm_client_impl.cc

Issue 270783002: [GCM] Add more UMA to GCM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/gcm_client.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/gcm_client_impl.cc
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index a0a2142f2167aca1d681e7a320605bdba02f7e11..00134f780c82ade7aa1cd38a3c7883dca48f24c6 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -69,6 +69,20 @@ enum MessageType {
SEND_ERROR, // Error sending a message.
};
+enum OutgoingMessageTTLCategory {
+ TTL_ZERO,
+ TTL_LESS_THAN_OR_EQUAL_TO_ONE_MINUTE,
+ TTL_LESS_THAN_OR_EQUAL_TO_ONE_HOUR,
+ TTL_LESS_THAN_OR_EQUAL_TO_ONE_DAY,
+ TTL_LESS_THAN_OR_EQUAL_TO_ONE_WEEK,
+ TTL_MORE_THAN_ONE_WEEK,
+ TTL_MAXIMUM,
+ // NOTE: always keep this entry at the end. Add new TTL category only
+ // immediately above this line. Make sure to update the corresponding
+ // histogram enum accordingly.
+ TTL_CATEGORY_COUNT
+};
+
// MCS endpoints. SSL Key pinning is done automatically due to the *.google.com
// pinning rule.
// Note: modifying the endpoints will affect the ability to compare the
@@ -117,6 +131,29 @@ MessageType DecodeMessageType(const std::string& value) {
return UNKNOWN;
}
+void RecordOutgoingMessageToUMA(
+ const gcm::GCMClient::OutgoingMessage& message) {
+ OutgoingMessageTTLCategory ttl_category;
+ if (message.time_to_live == 0)
+ ttl_category = TTL_ZERO;
+ else if (message.time_to_live <= 60 )
+ ttl_category = TTL_LESS_THAN_OR_EQUAL_TO_ONE_MINUTE;
+ else if (message.time_to_live <= 60 * 60)
+ ttl_category = TTL_LESS_THAN_OR_EQUAL_TO_ONE_HOUR;
+ else if (message.time_to_live <= 24 * 60 * 60)
+ ttl_category = TTL_LESS_THAN_OR_EQUAL_TO_ONE_DAY;
+ else if (message.time_to_live <= 7 * 24 * 60 * 60)
+ ttl_category = TTL_LESS_THAN_OR_EQUAL_TO_ONE_WEEK;
+ else if (message.time_to_live < gcm::GCMClient::OutgoingMessage::kMaximumTTL)
+ ttl_category = TTL_MORE_THAN_ONE_WEEK;
+ else
+ ttl_category = TTL_MAXIMUM;
+
+ UMA_HISTOGRAM_ENUMERATION("GCM.GCMOutgoingMessageTTLCategory",
+ ttl_category,
+ TTL_CATEGORY_COUNT);
+}
+
} // namespace
GCMInternalsBuilder::GCMInternalsBuilder() {}
@@ -557,6 +594,8 @@ void GCMClientImpl::Send(const std::string& app_id,
const OutgoingMessage& message) {
DCHECK_EQ(state_, READY);
+ RecordOutgoingMessageToUMA(message);
+
mcs_proto::DataMessageStanza stanza;
stanza.set_ttl(message.time_to_live);
stanza.set_sent(clock_->Now().ToInternalValue() /
« no previous file with comments | « google_apis/gcm/gcm_client.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698