Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: google_apis/gcm/engine/registration_request.cc

Issue 202083005: Add activity recording capability to gcm internals page. User can refresh, start/stop recording, an… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: google_apis/gcm/engine/registration_request.cc
diff --git a/google_apis/gcm/engine/registration_request.cc b/google_apis/gcm/engine/registration_request.cc
index db6981d231eed3a6d2e65df3f11a8230408ec7b1..1a6169916b5f357aa2e71a31de710247eef44c70 100644
--- a/google_apis/gcm/engine/registration_request.cc
+++ b/google_apis/gcm/engine/registration_request.cc
@@ -4,6 +4,8 @@
#include "google_apis/gcm/engine/registration_request.h"
+#include <string>
+
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
@@ -51,6 +53,35 @@ void BuildFormEncoding(const std::string& key,
out->append(key + "=" + net::EscapeUrlEncodedData(value, true));
}
+// Helper for getting string representation of the Status enum.
+std::string GetStatusString(RegistrationRequest::Status status) {
fgorski 2014/03/18 21:28:37 Same here, I think it is better to pass the Regist
juyik 2014/03/20 01:09:53 Removed changes for now. Will do this in a future
+ switch (status) {
+ case RegistrationRequest::SUCCESS:
+ return "SUCCESS";
+ case RegistrationRequest::INVALID_PARAMETERS:
+ return "INVALID_PARAMETERS";
+ case RegistrationRequest::INVALID_SENDER:
+ return "INVALID_SENDER";
+ case RegistrationRequest::AUTHENTICATION_FAILED:
+ return "AUTHENTICATION_FAILED";
+ case RegistrationRequest::DEVICE_REGISTRATION_ERROR:
+ return "DEVICE_REGISTRATION_ERROR";
+ case RegistrationRequest::UNKNOWN_ERROR:
+ return "UNKNOWN_ERROR";
+ case RegistrationRequest::URL_FETCHING_FAILED:
+ return "URL_FETCHING_FAILED";
+ case RegistrationRequest::HTTP_NOT_OK:
+ return "HTTP_NOT_OK";
+ case RegistrationRequest::RESPONSE_PARSING_FAILED:
+ return "RESPONSE_PARSING_FAILED";
+ case RegistrationRequest::REACHED_MAX_RETRIES:
+ return "REACHED_MAX_RETRIES";
+ default:
+ NOTREACHED();
+ return "UNKNOWN";
+ }
+}
+
// Gets correct status from the error message.
RegistrationRequest::Status GetStatusFromError(const std::string& error) {
// TODO(fgorski): Improve error parsing in case there is nore then just an
@@ -102,12 +133,14 @@ RegistrationRequest::RegistrationRequest(
const net::BackoffEntry::Policy& backoff_policy,
const RegistrationCallback& callback,
int max_retry_count,
- scoped_refptr<net::URLRequestContextGetter> request_context_getter)
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter,
+ GCMStatsRecorder* recorder)
: callback_(callback),
request_info_(request_info),
backoff_entry_(&backoff_policy),
request_context_getter_(request_context_getter),
retries_left_(max_retry_count),
+ recorder_(recorder),
weak_ptr_factory_(this) {
DCHECK_GE(max_retry_count, 0);
}
@@ -177,6 +210,8 @@ void RegistrationRequest::RetryWithBackoff(bool update_backoff) {
return;
}
+ recorder_->RecordRegister(request_info_.app_id, GCMStatsRecorder::Retry,
+ request_info_.sender_ids);
Start();
}
@@ -228,12 +263,25 @@ void RegistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) {
if (ShouldRetryWithStatus(status)) {
if (retries_left_ > 0) {
+ recorder_->RecordRegisterWithStatus(request_info_.app_id,
+ GCMStatsRecorder::RetryRequested,
+ request_info_.sender_ids,
+ GetStatusString(status));
RetryWithBackoff(true);
return;
}
status = REACHED_MAX_RETRIES;
RecordRegistrationStatusToUMA(status);
+ recorder_->RecordRegisterWithStatus(request_info_.app_id,
+ GCMStatsRecorder::Failure,
+ request_info_.sender_ids,
+ GetStatusString(status));
+ } else {
+ recorder_->RecordRegister(request_info_.app_id,
+ GCMStatsRecorder::Success,
+ request_info_.sender_ids);
+
}
callback_.Run(status, token);

Powered by Google App Engine
This is Rietveld 408576698