Chromium Code Reviews| 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/unregistration_request.h" | 5 #include "google_apis/gcm/engine/unregistration_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 BuildFormEncoding(kDeleteKey, kDeleteValue, &body); | 152 BuildFormEncoding(kDeleteKey, kDeleteValue, &body); |
| 153 BuildFormEncoding(kUnregistrationCallerKey, | 153 BuildFormEncoding(kUnregistrationCallerKey, |
| 154 kUnregistrationCallerValue, | 154 kUnregistrationCallerValue, |
| 155 &body); | 155 &body); |
| 156 | 156 |
| 157 DVLOG(1) << "Unregistration request: " << body; | 157 DVLOG(1) << "Unregistration request: " << body; |
| 158 url_fetcher_->SetUploadData(kRequestContentType, body); | 158 url_fetcher_->SetUploadData(kRequestContentType, body); |
| 159 | 159 |
| 160 DVLOG(1) << "Performing unregistration for: " << request_info_.app_id; | 160 DVLOG(1) << "Performing unregistration for: " << request_info_.app_id; |
| 161 recorder_->RecordUnregistrationSent(request_info_.app_id); | 161 recorder_->RecordUnregistrationSent(request_info_.app_id); |
| 162 request_start_time_ = base::TimeTicks::Now(); | |
| 162 url_fetcher_->Start(); | 163 url_fetcher_->Start(); |
| 163 } | 164 } |
| 164 | 165 |
| 165 void UnregistrationRequest::RetryWithBackoff(bool update_backoff) { | 166 void UnregistrationRequest::RetryWithBackoff(bool update_backoff) { |
| 166 if (update_backoff) { | 167 if (update_backoff) { |
| 167 url_fetcher_.reset(); | 168 url_fetcher_.reset(); |
| 168 backoff_entry_.InformOfRequest(false); | 169 backoff_entry_.InformOfRequest(false); |
| 169 } | 170 } |
| 170 | 171 |
| 171 if (backoff_entry_.ShouldRejectRequest()) { | 172 if (backoff_entry_.ShouldRejectRequest()) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 197 status, | 198 status, |
| 198 UNREGISTRATION_STATUS_COUNT); | 199 UNREGISTRATION_STATUS_COUNT); |
| 199 recorder_->RecordUnregistrationResponse(request_info_.app_id, status); | 200 recorder_->RecordUnregistrationResponse(request_info_.app_id, status); |
| 200 | 201 |
| 201 if (status == URL_FETCHING_FAILED || | 202 if (status == URL_FETCHING_FAILED || |
| 202 status == SERVICE_UNAVAILABLE || | 203 status == SERVICE_UNAVAILABLE || |
| 203 status == INTERNAL_SERVER_ERROR || | 204 status == INTERNAL_SERVER_ERROR || |
| 204 status == INCORRECT_APP_ID || | 205 status == INCORRECT_APP_ID || |
| 205 status == RESPONSE_PARSING_FAILED) { | 206 status == RESPONSE_PARSING_FAILED) { |
| 206 RetryWithBackoff(true); | 207 RetryWithBackoff(true); |
| 207 } else { | 208 return; |
| 208 // status == SUCCESS || HTTP_NOT_OK || NO_RESPONSE_BODY || | |
| 209 // INVALID_PARAMETERS || UNKNOWN_ERROR | |
| 210 callback_.Run(status); | |
| 211 } | 209 } |
| 210 | |
| 211 // status == SUCCESS || HTTP_NOT_OK || NO_RESPONSE_BODY || | |
| 212 // INVALID_PARAMETERS || UNKNOWN_ERROR | |
| 213 | |
| 214 if (status == SUCCESS) { | |
| 215 UMA_HISTOGRAM_COUNTS("GCM.UnregistrationRetryNumber", | |
|
Nicolas Zea
2014/05/08 21:28:19
Number -> Count
jianli
2014/05/08 21:40:47
Done.
| |
| 216 backoff_entry_.failure_count()); | |
| 217 UMA_HISTOGRAM_TIMES("GCM.UnregistrationCompleteTime", | |
| 218 base::TimeTicks::Now() - request_start_time_); | |
| 219 } | |
| 220 | |
| 221 callback_.Run(status); | |
| 212 } | 222 } |
| 213 | 223 |
| 214 } // namespace gcm | 224 } // namespace gcm |
| OLD | NEW |