| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "google_apis/gcm/engine/registration_request.h" | 5 #include "google_apis/gcm/engine/registration_request.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return RegistrationRequest::DEVICE_REGISTRATION_ERROR; | 54 return RegistrationRequest::DEVICE_REGISTRATION_ERROR; |
| 55 if (error.find(kAuthenticationFailed) != std::string::npos) | 55 if (error.find(kAuthenticationFailed) != std::string::npos) |
| 56 return RegistrationRequest::AUTHENTICATION_FAILED; | 56 return RegistrationRequest::AUTHENTICATION_FAILED; |
| 57 if (error.find(kInvalidSender) != std::string::npos) | 57 if (error.find(kInvalidSender) != std::string::npos) |
| 58 return RegistrationRequest::INVALID_SENDER; | 58 return RegistrationRequest::INVALID_SENDER; |
| 59 if (error.find(kInvalidParameters) != std::string::npos) | 59 if (error.find(kInvalidParameters) != std::string::npos) |
| 60 return RegistrationRequest::INVALID_PARAMETERS; | 60 return RegistrationRequest::INVALID_PARAMETERS; |
| 61 return RegistrationRequest::UNKNOWN_ERROR; | 61 return RegistrationRequest::UNKNOWN_ERROR; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Indicates whether a retry attempt should be made based on the status of the | 64 // Determines whether to retry based on the status of the last request. |
| 65 // last request. | |
| 66 bool ShouldRetryWithStatus(RegistrationRequest::Status status) { | 65 bool ShouldRetryWithStatus(RegistrationRequest::Status status) { |
| 67 return status == RegistrationRequest::UNKNOWN_ERROR || | 66 switch (status) { |
| 68 status == RegistrationRequest::AUTHENTICATION_FAILED || | 67 case RegistrationRequest::AUTHENTICATION_FAILED: |
| 69 status == RegistrationRequest::DEVICE_REGISTRATION_ERROR || | 68 case RegistrationRequest::DEVICE_REGISTRATION_ERROR: |
| 70 status == RegistrationRequest::HTTP_NOT_OK || | 69 case RegistrationRequest::UNKNOWN_ERROR: |
| 71 status == RegistrationRequest::URL_FETCHING_FAILED || | 70 case RegistrationRequest::URL_FETCHING_FAILED: |
| 72 status == RegistrationRequest::RESPONSE_PARSING_FAILED; | 71 case RegistrationRequest::HTTP_NOT_OK: |
| 72 case RegistrationRequest::RESPONSE_PARSING_FAILED: |
| 73 return true; |
| 74 case RegistrationRequest::SUCCESS: |
| 75 case RegistrationRequest::INVALID_PARAMETERS: |
| 76 case RegistrationRequest::INVALID_SENDER: |
| 77 case RegistrationRequest::REACHED_MAX_RETRIES: |
| 78 return false; |
| 79 case RegistrationRequest::STATUS_COUNT: |
| 80 NOTREACHED(); |
| 81 break; |
| 82 } |
| 83 return false; |
| 73 } | 84 } |
| 74 | 85 |
| 75 } // namespace | 86 } // namespace |
| 76 | 87 |
| 77 RegistrationRequest::RequestInfo::RequestInfo(uint64_t android_id, | 88 RegistrationRequest::RequestInfo::RequestInfo(uint64_t android_id, |
| 78 uint64_t security_token, | 89 uint64_t security_token, |
| 79 const std::string& category, | 90 const std::string& category, |
| 80 const std::string& subtype) | 91 const std::string& subtype) |
| 81 : android_id(android_id), | 92 : android_id(android_id), |
| 82 security_token(security_token), | 93 security_token(security_token), |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // Only REACHED_MAX_RETRIES is reported because the function will skip | 262 // Only REACHED_MAX_RETRIES is reported because the function will skip |
| 252 // reporting count and time when status is not SUCCESS. | 263 // reporting count and time when status is not SUCCESS. |
| 253 DCHECK(custom_request_handler_.get()); | 264 DCHECK(custom_request_handler_.get()); |
| 254 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); | 265 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); |
| 255 } | 266 } |
| 256 | 267 |
| 257 callback_.Run(status, token); | 268 callback_.Run(status, token); |
| 258 } | 269 } |
| 259 | 270 |
| 260 } // namespace gcm | 271 } // namespace gcm |
| OLD | NEW |