Index: google_apis/gcm/engine/checkin_request.cc |
diff --git a/google_apis/gcm/engine/checkin_request.cc b/google_apis/gcm/engine/checkin_request.cc |
index b46415ab96ffb48e073e7e9ff420e5816f445551..af01f33d22fd14562ee363e79b4697c45bd26227 100644 |
--- a/google_apis/gcm/engine/checkin_request.cc |
+++ b/google_apis/gcm/engine/checkin_request.cc |
@@ -6,6 +6,7 @@ |
#include "base/bind.h" |
#include "base/message_loop/message_loop.h" |
+#include "base/metrics/histogram.h" |
#include "google_apis/gcm/protocol/checkin.pb.h" |
#include "net/http/http_status_code.h" |
#include "net/url_request/url_fetcher.h" |
@@ -18,6 +19,30 @@ namespace { |
const char kCheckinURL[] = "https://android.clients.google.com/checkin"; |
const char kRequestContentType[] = "application/x-protobuf"; |
const int kRequestVersionValue = 2; |
+ |
+// This enum is also used in an UMA histogram (GCMRegistrationRequestStatus |
fgorski
2014/02/12 18:22:58
GCMRegistrationRequestStatus?
juyik
2014/02/12 18:31:54
Done.
|
+// enum defined in tools/metrics/histograms/histogram.xml). Hence the entries |
+// here shouldn't be deleted or re-ordered and new ones should be added to |
+// the end. |
+enum CheckinRequestStatus { |
+ SUCCESS, // Checkin completed successfully. |
+ URL_FETCHING_FAILED, // URL fetching failed. |
+ HTTP_BAD_REQUEST, // The request was malformed. |
+ HTTP_UNAUTHORIZED, // The security token didn't match the android id. |
+ HTTP_NOT_OK, // HTTP status was not OK. |
+ FAILED_PARSING_RESPONSE, // Failed to parse the checkin response. |
fgorski
2014/02/12 18:22:58
RESPONSE_PARSIN_FAILED
will be consistent with URL
juyik
2014/02/12 18:31:54
Done.
juyik
2014/02/12 18:31:54
Done.
|
+ ZERO_ID_OR_TOKEN, // Either returned android id or security token |
+ // was zero. |
+ // NOTE: always keep this entry at the end. Add new status types only |
+ // immediately above this line. Make sure to update the corresponding |
+ // histogram enum accordingly. |
+ STATUS_COUNT |
+}; |
+ |
+void RecordCheckinStatusToUMA(CheckinRequestStatus status) { |
+ UMA_HISTOGRAM_ENUMERATION("GCM.CheckinRequestStatus", status, STATUS_COUNT); |
+} |
+ |
} // namespace |
CheckinRequest::CheckinRequest( |
@@ -94,6 +119,7 @@ void CheckinRequest::OnURLFetchComplete(const net::URLFetcher* source) { |
checkin_proto::AndroidCheckinResponse response_proto; |
if (!source->GetStatus().is_success()) { |
LOG(ERROR) << "Failed to get checkin response. Fetcher failed. Retrying."; |
+ RecordCheckinStatusToUMA(URL_FETCHING_FAILED); |
RetryWithBackoff(true); |
return; |
} |
@@ -106,6 +132,11 @@ void CheckinRequest::OnURLFetchComplete(const net::URLFetcher* source) { |
// UNAUTHORIZED indicates that security token didn't match the android id. |
LOG(ERROR) << "No point retrying the checkin with status: " |
<< response_status << ". Checkin failed."; |
+ if (response_status == net::HTTP_BAD_REQUEST) { |
+ RecordCheckinStatusToUMA(HTTP_BAD_REQUEST); |
+ } else { |
+ RecordCheckinStatusToUMA(HTTP_UNAUTHORIZED); |
+ } |
callback_.Run(0,0); |
return; |
} |
@@ -115,6 +146,11 @@ void CheckinRequest::OnURLFetchComplete(const net::URLFetcher* source) { |
!response_proto.ParseFromString(response_string)) { |
LOG(ERROR) << "Failed to get checkin response. HTTP Status: " |
<< response_status << ". Retrying."; |
+ if (response_status != net::HTTP_OK) { |
+ RecordCheckinStatusToUMA(HTTP_NOT_OK); |
+ } else { |
+ RecordCheckinStatusToUMA(FAILED_PARSING_RESPONSE); |
+ } |
RetryWithBackoff(true); |
return; |
} |
@@ -124,10 +160,12 @@ void CheckinRequest::OnURLFetchComplete(const net::URLFetcher* source) { |
response_proto.android_id() == 0 || |
response_proto.security_token() == 0) { |
LOG(ERROR) << "Android ID or security token is 0. Retrying."; |
+ RecordCheckinStatusToUMA(ZERO_ID_OR_TOKEN); |
RetryWithBackoff(true); |
return; |
} |
+ RecordCheckinStatusToUMA(SUCCESS); |
callback_.Run(response_proto.android_id(), response_proto.security_token()); |
} |