summaryrefslogtreecommitdiffstats
path: root/google_apis/gcm/gcm_client_impl.cc
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 22:34:08 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 22:34:08 +0000
commitb20aece2f8054df33d74db6f4a77e0cdc00c10de (patch)
tree8345d0b42a11a37f15521683b50f55b15a1be6d4 /google_apis/gcm/gcm_client_impl.cc
parent69f65a24803adfc456ef9382c31ee37d6cdac5b1 (diff)
downloadchromium_src-b20aece2f8054df33d74db6f4a77e0cdc00c10de.zip
chromium_src-b20aece2f8054df33d74db6f4a77e0cdc00c10de.tar.gz
chromium_src-b20aece2f8054df33d74db6f4a77e0cdc00c10de.tar.bz2
[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
Diffstat (limited to 'google_apis/gcm/gcm_client_impl.cc')
-rw-r--r--google_apis/gcm/gcm_client_impl.cc39
1 files changed, 39 insertions, 0 deletions
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() /