| 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/checkin_request.h" | 5 #include "google_apis/gcm/engine/checkin_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 "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 10 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 std::string upload_data; | 139 std::string upload_data; |
| 140 CHECK(request.SerializeToString(&upload_data)); | 140 CHECK(request.SerializeToString(&upload_data)); |
| 141 | 141 |
| 142 url_fetcher_.reset( | 142 url_fetcher_.reset( |
| 143 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this)); | 143 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this)); |
| 144 url_fetcher_->SetRequestContext(request_context_getter_); | 144 url_fetcher_->SetRequestContext(request_context_getter_); |
| 145 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 145 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
| 146 recorder_->RecordCheckinInitiated(request_info_.android_id); | 146 recorder_->RecordCheckinInitiated(request_info_.android_id); |
| 147 request_start_time_ = base::TimeTicks::Now(); |
| 147 url_fetcher_->Start(); | 148 url_fetcher_->Start(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void CheckinRequest::RetryWithBackoff(bool update_backoff) { | 151 void CheckinRequest::RetryWithBackoff(bool update_backoff) { |
| 151 if (update_backoff) { | 152 if (update_backoff) { |
| 152 backoff_entry_.InformOfRequest(false); | 153 backoff_entry_.InformOfRequest(false); |
| 153 url_fetcher_.reset(); | 154 url_fetcher_.reset(); |
| 154 } | 155 } |
| 155 | 156 |
| 156 if (backoff_entry_.ShouldRejectRequest()) { | 157 if (backoff_entry_.ShouldRejectRequest()) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 !response_proto.has_security_token() || | 213 !response_proto.has_security_token() || |
| 213 response_proto.android_id() == 0 || | 214 response_proto.android_id() == 0 || |
| 214 response_proto.security_token() == 0) { | 215 response_proto.security_token() == 0) { |
| 215 LOG(ERROR) << "Android ID or security token is 0. Retrying."; | 216 LOG(ERROR) << "Android ID or security token is 0. Retrying."; |
| 216 RecordCheckinStatusAndReportUMA(ZERO_ID_OR_TOKEN, recorder_, true); | 217 RecordCheckinStatusAndReportUMA(ZERO_ID_OR_TOKEN, recorder_, true); |
| 217 RetryWithBackoff(true); | 218 RetryWithBackoff(true); |
| 218 return; | 219 return; |
| 219 } | 220 } |
| 220 | 221 |
| 221 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); | 222 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); |
| 223 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", |
| 224 backoff_entry_.failure_count()); |
| 225 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", |
| 226 base::TimeTicks::Now() - request_start_time_); |
| 222 callback_.Run(response_proto); | 227 callback_.Run(response_proto); |
| 223 } | 228 } |
| 224 | 229 |
| 225 } // namespace gcm | 230 } // namespace gcm |
| OLD | NEW |