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

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

Issue 2427633005: Improve GCM enum switch type safety (Closed)
Patch Set: Rebase Created 4 years, 2 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
« no previous file with comments | « google_apis/gcm/engine/mcs_client.cc ('k') | google_apis/gcm/engine/unregistration_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ccb89eeb0ac41d36db1146c3aa4f6327aeadd5a1..137b3c26c00326e86f4c05a08921d706ebded186 100644
--- a/google_apis/gcm/engine/registration_request.cc
+++ b/google_apis/gcm/engine/registration_request.cc
@@ -61,15 +61,26 @@ RegistrationRequest::Status GetStatusFromError(const std::string& error) {
return RegistrationRequest::UNKNOWN_ERROR;
}
-// Indicates whether a retry attempt should be made based on the status of the
-// last request.
+// Determines whether to retry based on the status of the last request.
bool ShouldRetryWithStatus(RegistrationRequest::Status status) {
- return status == RegistrationRequest::UNKNOWN_ERROR ||
- status == RegistrationRequest::AUTHENTICATION_FAILED ||
- status == RegistrationRequest::DEVICE_REGISTRATION_ERROR ||
- status == RegistrationRequest::HTTP_NOT_OK ||
- status == RegistrationRequest::URL_FETCHING_FAILED ||
- status == RegistrationRequest::RESPONSE_PARSING_FAILED;
+ switch (status) {
+ case RegistrationRequest::AUTHENTICATION_FAILED:
+ case RegistrationRequest::DEVICE_REGISTRATION_ERROR:
+ case RegistrationRequest::UNKNOWN_ERROR:
+ case RegistrationRequest::URL_FETCHING_FAILED:
+ case RegistrationRequest::HTTP_NOT_OK:
+ case RegistrationRequest::RESPONSE_PARSING_FAILED:
+ return true;
+ case RegistrationRequest::SUCCESS:
+ case RegistrationRequest::INVALID_PARAMETERS:
+ case RegistrationRequest::INVALID_SENDER:
+ case RegistrationRequest::REACHED_MAX_RETRIES:
+ return false;
+ case RegistrationRequest::STATUS_COUNT:
+ NOTREACHED();
+ break;
+ }
+ return false;
}
} // namespace
« no previous file with comments | « google_apis/gcm/engine/mcs_client.cc ('k') | google_apis/gcm/engine/unregistration_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698