summaryrefslogtreecommitdiffstats
path: root/google_apis
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
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')
-rw-r--r--google_apis/gcm/engine/checkin_request.cc5
-rw-r--r--google_apis/gcm/engine/checkin_request.h2
-rw-r--r--google_apis/gcm/engine/registration_request.cc9
-rw-r--r--google_apis/gcm/engine/registration_request.h2
-rw-r--r--google_apis/gcm/engine/unregistration_request.cc18
-rw-r--r--google_apis/gcm/engine/unregistration_request.h2
-rw-r--r--google_apis/gcm/gcm_client.cc2
-rw-r--r--google_apis/gcm/gcm_client.h2
-rw-r--r--google_apis/gcm/gcm_client_impl.cc39
9 files changed, 76 insertions, 5 deletions
diff --git a/google_apis/gcm/engine/checkin_request.cc b/google_apis/gcm/engine/checkin_request.cc
index aa46655..7b3ff22 100644
--- a/google_apis/gcm/engine/checkin_request.cc
+++ b/google_apis/gcm/engine/checkin_request.cc
@@ -144,6 +144,7 @@ void CheckinRequest::Start() {
url_fetcher_->SetRequestContext(request_context_getter_);
url_fetcher_->SetUploadData(kRequestContentType, upload_data);
recorder_->RecordCheckinInitiated(request_info_.android_id);
+ request_start_time_ = base::TimeTicks::Now();
url_fetcher_->Start();
}
@@ -219,6 +220,10 @@ void CheckinRequest::OnURLFetchComplete(const net::URLFetcher* source) {
}
RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false);
+ UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount",
+ backoff_entry_.failure_count());
+ UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime",
+ base::TimeTicks::Now() - request_start_time_);
callback_.Run(response_proto);
}
diff --git a/google_apis/gcm/engine/checkin_request.h b/google_apis/gcm/engine/checkin_request.h
index 0f04505..9253aac 100644
--- a/google_apis/gcm/engine/checkin_request.h
+++ b/google_apis/gcm/engine/checkin_request.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
#include "google_apis/gcm/base/gcm_export.h"
#include "google_apis/gcm/protocol/android_checkin.pb.h"
#include "google_apis/gcm/protocol/checkin.pb.h"
@@ -83,6 +84,7 @@ class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate {
GURL checkin_url_;
scoped_ptr<net::URLFetcher> url_fetcher_;
const RequestInfo request_info_;
+ base::TimeTicks request_start_time_;
// Recorder that records GCM activities for debugging purpose. Not owned.
GCMStatsRecorder* recorder_;
diff --git a/google_apis/gcm/engine/registration_request.cc b/google_apis/gcm/engine/registration_request.cc
index dd3f369..e72e7ba 100644
--- a/google_apis/gcm/engine/registration_request.cc
+++ b/google_apis/gcm/engine/registration_request.cc
@@ -151,11 +151,14 @@ void RegistrationRequest::Start() {
senders.append(*iter);
}
BuildFormEncoding(kSenderKey, senders, &body);
+ UMA_HISTOGRAM_COUNTS("GCM.RegistrationSenderIdCount",
+ request_info_.sender_ids.size());
DVLOG(1) << "Performing registration for: " << request_info_.app_id;
DVLOG(1) << "Registration request: " << body;
url_fetcher_->SetUploadData(kRegistrationRequestContentType, body);
recorder_->RecordRegistrationSent(request_info_.app_id, senders);
+ request_start_time_ = base::TimeTicks::Now();
url_fetcher_->Start();
}
@@ -252,6 +255,12 @@ void RegistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) {
RecordRegistrationStatusToUMA(status);
}
+ if (status == SUCCESS) {
+ UMA_HISTOGRAM_COUNTS("GCM.RegistrationRetryCount",
+ backoff_entry_.failure_count());
+ UMA_HISTOGRAM_TIMES("GCM.RegistrationCompleteTime",
+ base::TimeTicks::Now() - request_start_time_);
+ }
callback_.Run(status, token);
}
diff --git a/google_apis/gcm/engine/registration_request.h b/google_apis/gcm/engine/registration_request.h
index 30bed41..d41f285 100644
--- a/google_apis/gcm/engine/registration_request.h
+++ b/google_apis/gcm/engine/registration_request.h
@@ -13,6 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
#include "google_apis/gcm/base/gcm_export.h"
#include "net/base/backoff_entry.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -112,6 +113,7 @@ class GCM_EXPORT RegistrationRequest : public net::URLFetcherDelegate {
scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
scoped_ptr<net::URLFetcher> url_fetcher_;
int retries_left_;
+ base::TimeTicks request_start_time_;
// Recorder that records GCM activities for debugging purpose. Not owned.
GCMStatsRecorder* recorder_;
diff --git a/google_apis/gcm/engine/unregistration_request.cc b/google_apis/gcm/engine/unregistration_request.cc
index 92136bf..2b8c97d 100644
--- a/google_apis/gcm/engine/unregistration_request.cc
+++ b/google_apis/gcm/engine/unregistration_request.cc
@@ -159,6 +159,7 @@ void UnregistrationRequest::Start() {
DVLOG(1) << "Performing unregistration for: " << request_info_.app_id;
recorder_->RecordUnregistrationSent(request_info_.app_id);
+ request_start_time_ = base::TimeTicks::Now();
url_fetcher_->Start();
}
@@ -204,11 +205,20 @@ void UnregistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) {
status == INCORRECT_APP_ID ||
status == RESPONSE_PARSING_FAILED) {
RetryWithBackoff(true);
- } else {
- // status == SUCCESS || HTTP_NOT_OK || NO_RESPONSE_BODY ||
- // INVALID_PARAMETERS || UNKNOWN_ERROR
- callback_.Run(status);
+ return;
}
+
+ // status == SUCCESS || HTTP_NOT_OK || NO_RESPONSE_BODY ||
+ // INVALID_PARAMETERS || UNKNOWN_ERROR
+
+ if (status == SUCCESS) {
+ UMA_HISTOGRAM_COUNTS("GCM.UnregistrationRetryCount",
+ backoff_entry_.failure_count());
+ UMA_HISTOGRAM_TIMES("GCM.UnregistrationCompleteTime",
+ base::TimeTicks::Now() - request_start_time_);
+ }
+
+ callback_.Run(status);
}
} // namespace gcm
diff --git a/google_apis/gcm/engine/unregistration_request.h b/google_apis/gcm/engine/unregistration_request.h
index b25e28c..aec3331 100644
--- a/google_apis/gcm/engine/unregistration_request.h
+++ b/google_apis/gcm/engine/unregistration_request.h
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
#include "google_apis/gcm/base/gcm_export.h"
#include "net/base/backoff_entry.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -99,6 +100,7 @@ class GCM_EXPORT UnregistrationRequest : public net::URLFetcherDelegate {
net::BackoffEntry backoff_entry_;
scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
scoped_ptr<net::URLFetcher> url_fetcher_;
+ base::TimeTicks request_start_time_;
// Recorder that records GCM activities for debugging purpose. Not owned.
GCMStatsRecorder* recorder_;
diff --git a/google_apis/gcm/gcm_client.cc b/google_apis/gcm/gcm_client.cc
index 75884d6..dd2a316 100644
--- a/google_apis/gcm/gcm_client.cc
+++ b/google_apis/gcm/gcm_client.cc
@@ -7,7 +7,7 @@
namespace gcm {
GCMClient::OutgoingMessage::OutgoingMessage()
- : time_to_live(0) {
+ : time_to_live(kMaximumTTL) {
}
GCMClient::OutgoingMessage::~OutgoingMessage() {
diff --git a/google_apis/gcm/gcm_client.h b/google_apis/gcm/gcm_client.h
index 28c9ef2..1a24f09 100644
--- a/google_apis/gcm/gcm_client.h
+++ b/google_apis/gcm/gcm_client.h
@@ -67,6 +67,8 @@ class GCM_EXPORT GCMClient {
// In seconds.
int time_to_live;
MessageData data;
+
+ static const int kMaximumTTL = 4 * 7 * 24 * 60 * 60; // 4 weeks.
};
// Message being received from the other party.
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() /