| Index: google_apis/gcm/engine/unregistration_request.cc
|
| diff --git a/google_apis/gcm/engine/unregistration_request.cc b/google_apis/gcm/engine/unregistration_request.cc
|
| index c0b444e709b74bd6198f2dcca9d362f489bd47d3..15c8d883fa39dc806c2475555f849dd26c8b89fa 100644
|
| --- a/google_apis/gcm/engine/unregistration_request.cc
|
| +++ b/google_apis/gcm/engine/unregistration_request.cc
|
| @@ -36,6 +36,29 @@ const char kDeleteValue[] = "true";
|
| const char kDeviceIdKey[] = "device";
|
| const char kLoginHeader[] = "AidLogin";
|
|
|
| +// Determines whether to retry based on the status of the last request.
|
| +bool ShouldRetryWithStatus(UnregistrationRequest::Status status) {
|
| + switch (status) {
|
| + case UnregistrationRequest::URL_FETCHING_FAILED:
|
| + case UnregistrationRequest::NO_RESPONSE_BODY:
|
| + case UnregistrationRequest::RESPONSE_PARSING_FAILED:
|
| + case UnregistrationRequest::INCORRECT_APP_ID:
|
| + case UnregistrationRequest::SERVICE_UNAVAILABLE:
|
| + case UnregistrationRequest::INTERNAL_SERVER_ERROR:
|
| + case UnregistrationRequest::HTTP_NOT_OK:
|
| + return true;
|
| + case UnregistrationRequest::SUCCESS:
|
| + case UnregistrationRequest::INVALID_PARAMETERS:
|
| + case UnregistrationRequest::UNKNOWN_ERROR:
|
| + case UnregistrationRequest::REACHED_MAX_RETRIES:
|
| + return false;
|
| + case UnregistrationRequest::UNREGISTRATION_STATUS_COUNT:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| } // namespace
|
|
|
| UnregistrationRequest::RequestInfo::RequestInfo(uint64_t android_id,
|
| @@ -177,7 +200,7 @@ void UnregistrationRequest::RetryWithBackoff() {
|
| void UnregistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) {
|
| UnregistrationRequest::Status status = ParseResponse(source);
|
|
|
| - DVLOG(1) << "UnregistrationRequestStauts: " << status;
|
| + DVLOG(1) << "UnregistrationRequestStatus: " << status;
|
|
|
| DCHECK(custom_request_handler_.get());
|
| custom_request_handler_->ReportUMAs(
|
| @@ -188,13 +211,7 @@ void UnregistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) {
|
| recorder_->RecordUnregistrationResponse(request_info_.app_id(),
|
| source_to_record_, status);
|
|
|
| - if (status == URL_FETCHING_FAILED ||
|
| - status == HTTP_NOT_OK ||
|
| - status == NO_RESPONSE_BODY ||
|
| - status == SERVICE_UNAVAILABLE ||
|
| - status == INTERNAL_SERVER_ERROR ||
|
| - status == INCORRECT_APP_ID ||
|
| - status == RESPONSE_PARSING_FAILED) {
|
| + if (ShouldRetryWithStatus(status)) {
|
| if (retries_left_ > 0) {
|
| RetryWithBackoff();
|
| return;
|
| @@ -210,9 +227,6 @@ void UnregistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) {
|
| custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta());
|
| }
|
|
|
| - // status == SUCCESS || INVALID_PARAMETERS || UNKNOWN_ERROR ||
|
| - // REACHED_MAX_RETRIES
|
| -
|
| callback_.Run(status);
|
| }
|
|
|
|
|