From b20aece2f8054df33d74db6f4a77e0cdc00c10de Mon Sep 17 00:00:00 2001 From: "jianli@chromium.org" Date: Fri, 9 May 2014 22:34:08 +0000 Subject: [GCM] Add more UMA to GCM Also fix a bug that the default TTL value is set to 0. BUG=361374,371149 TEST=new test added for default TTL bug Review URL: https://codereview.chromium.org/270783002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269439 0039d316-1c4b-4281-b951-d872f2087c98 --- google_apis/gcm/gcm_client_impl.cc | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to '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 a0a2142..00134f7 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() / -- cgit v1.1