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..69796b4a3f12b2635524320827ac94ce4e39627b 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 { |
+ ZERO_TTL, |
fgorski
2014/05/08 18:08:36
TTL_ZERO
TTL_IS_ZERO
and TTL_MAX / TTL_MAXIMUM
t
jianli
2014/05/08 18:40:07
Done.
|
+ 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, |
+ MAXIMUM_TTL, |
+ // 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 RecordROutgoingMessageToUMA( |
+ const gcm::GCMClient::OutgoingMessage& message) { |
+ OutgoingMessageTTLCategory ttl_category; |
+ if (message.time_to_live == 0) |
+ ttl_category = ZERO_TTL; |
+ 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 <= 60 * 60 * 24) |
+ ttl_category = TTL_LESS_THAN_OR_EQUAL_TO_ONE_DAY; |
+ else if (message.time_to_live <= 60 * 60 * 24 * 7) |
fgorski
2014/05/08 18:08:36
nit: if you decide to reverse the order in my last
jianli
2014/05/08 18:40:07
Done.
|
+ 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 = MAXIMUM_TTL; |
+ |
+ 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); |
+ RecordROutgoingMessageToUMA(message); |
+ |
mcs_proto::DataMessageStanza stanza; |
stanza.set_ttl(message.time_to_live); |
stanza.set_sent(clock_->Now().ToInternalValue() / |