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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 request_info_(request_info), | 120 request_info_(request_info), |
| 121 registration_url_(registration_url), | 121 registration_url_(registration_url), |
| 122 backoff_entry_(&backoff_policy), | 122 backoff_entry_(&backoff_policy), |
| 123 request_context_getter_(request_context_getter), | 123 request_context_getter_(request_context_getter), |
| 124 recorder_(recorder), | 124 recorder_(recorder), |
| 125 weak_ptr_factory_(this) { | 125 weak_ptr_factory_(this) { |
| 126 } | 126 } |
| 127 | 127 |
| 128 UnregistrationRequest::~UnregistrationRequest() {} | 128 UnregistrationRequest::~UnregistrationRequest() {} |
| 129 | 129 |
| 130 void UnregistrationRequest::Start() { | 130 void UnregistrationRequest::Start() { |
|
fgorski
2014/05/08 18:08:36
Add UMA about Unregistration attempt.
jianli
2014/05/08 18:40:07
What do you mean?
fgorski
2014/05/08 18:46:30
My mistake, I was going for being symmetric with R
| |
| 131 DCHECK(!callback_.is_null()); | 131 DCHECK(!callback_.is_null()); |
| 132 DCHECK(request_info_.android_id != 0UL); | 132 DCHECK(request_info_.android_id != 0UL); |
| 133 DCHECK(request_info_.security_token != 0UL); | 133 DCHECK(request_info_.security_token != 0UL); |
| 134 DCHECK(!url_fetcher_.get()); | 134 DCHECK(!url_fetcher_.get()); |
| 135 | 135 |
| 136 url_fetcher_.reset(net::URLFetcher::Create( | 136 url_fetcher_.reset(net::URLFetcher::Create( |
| 137 registration_url_, net::URLFetcher::POST, this)); | 137 registration_url_, net::URLFetcher::POST, this)); |
| 138 url_fetcher_->SetRequestContext(request_context_getter_); | 138 url_fetcher_->SetRequestContext(request_context_getter_); |
| 139 | 139 |
| 140 std::string android_id = base::Uint64ToString(request_info_.android_id); | 140 std::string android_id = base::Uint64ToString(request_info_.android_id); |
| (...skipping 11 matching lines...) Expand all 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", | |
|
fgorski
2014/05/08 18:08:36
Same comments as in Registration
jianli
2014/05/08 18:40:07
ditto.
| |
| 216 backoff_entry_.failure_count() + 1); | |
| 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 |