| 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" | |
| 10 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 12 #include "base/values.h" | 11 #include "base/values.h" |
| 13 #include "google_apis/gcm/base/gcm_util.h" | 12 #include "google_apis/gcm/base/gcm_util.h" |
| 14 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 13 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| 15 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 16 #include "net/http/http_request_headers.h" | 15 #include "net/http/http_request_headers.h" |
| 17 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
| 18 #include "net/url_request/url_fetcher.h" | 17 #include "net/url_request/url_fetcher.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return; | 161 return; |
| 163 } | 162 } |
| 164 | 163 |
| 165 Start(); | 164 Start(); |
| 166 } | 165 } |
| 167 | 166 |
| 168 void UnregistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) { | 167 void UnregistrationRequest::OnURLFetchComplete(const net::URLFetcher* source) { |
| 169 UnregistrationRequest::Status status = ParseResponse(source); | 168 UnregistrationRequest::Status status = ParseResponse(source); |
| 170 | 169 |
| 171 DVLOG(1) << "UnregistrationRequestStauts: " << status; | 170 DVLOG(1) << "UnregistrationRequestStauts: " << status; |
| 172 UMA_HISTOGRAM_ENUMERATION("GCM.UnregistrationRequestStatus", | 171 |
| 173 status, | 172 DCHECK(custom_request_handler_.get()); |
| 174 UNREGISTRATION_STATUS_COUNT); | 173 custom_request_handler_->ReportUMAs( |
| 174 status, |
| 175 backoff_entry_.failure_count(), |
| 176 base::TimeTicks::Now() - request_start_time_); |
| 177 |
| 175 recorder_->RecordUnregistrationResponse(request_info_.app_id, status); | 178 recorder_->RecordUnregistrationResponse(request_info_.app_id, status); |
| 176 | 179 |
| 177 if (status == URL_FETCHING_FAILED || | 180 if (status == URL_FETCHING_FAILED || |
| 178 status == SERVICE_UNAVAILABLE || | 181 status == SERVICE_UNAVAILABLE || |
| 179 status == INTERNAL_SERVER_ERROR || | 182 status == INTERNAL_SERVER_ERROR || |
| 180 status == INCORRECT_APP_ID || | 183 status == INCORRECT_APP_ID || |
| 181 status == RESPONSE_PARSING_FAILED) { | 184 status == RESPONSE_PARSING_FAILED) { |
| 182 RetryWithBackoff(true); | 185 RetryWithBackoff(true); |
| 183 return; | 186 return; |
| 184 } | 187 } |
| 185 | 188 |
| 186 // status == SUCCESS || HTTP_NOT_OK || NO_RESPONSE_BODY || | 189 // status == SUCCESS || HTTP_NOT_OK || NO_RESPONSE_BODY || |
| 187 // INVALID_PARAMETERS || UNKNOWN_ERROR | 190 // INVALID_PARAMETERS || UNKNOWN_ERROR |
| 188 | 191 |
| 189 if (status == SUCCESS) { | |
| 190 UMA_HISTOGRAM_COUNTS("GCM.UnregistrationRetryCount", | |
| 191 backoff_entry_.failure_count()); | |
| 192 UMA_HISTOGRAM_TIMES("GCM.UnregistrationCompleteTime", | |
| 193 base::TimeTicks::Now() - request_start_time_); | |
| 194 } | |
| 195 | |
| 196 callback_.Run(status); | 192 callback_.Run(status); |
| 197 } | 193 } |
| 198 | 194 |
| 199 } // namespace gcm | 195 } // namespace gcm |
| OLD | NEW |