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/location.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "base/thread_task_runner_handle.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "google_apis/gcm/base/gcm_util.h" | 13 #include "google_apis/gcm/base/gcm_util.h" |
13 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 14 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
16 #include "net/http/http_request_headers.h" | 17 #include "net/http/http_request_headers.h" |
17 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" |
18 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
19 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
20 #include "net/url_request/url_request_status.h" | 21 #include "net/url_request/url_request_status.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (backoff_entry_.ShouldRejectRequest()) { | 158 if (backoff_entry_.ShouldRejectRequest()) { |
158 DVLOG(1) << "Delaying GCM unregistration of app: " | 159 DVLOG(1) << "Delaying GCM unregistration of app: " |
159 << request_info_.app_id << ", for " | 160 << request_info_.app_id << ", for " |
160 << backoff_entry_.GetTimeUntilRelease().InMilliseconds() | 161 << backoff_entry_.GetTimeUntilRelease().InMilliseconds() |
161 << " milliseconds."; | 162 << " milliseconds."; |
162 recorder_->RecordUnregistrationRetryDelayed( | 163 recorder_->RecordUnregistrationRetryDelayed( |
163 request_info_.app_id, | 164 request_info_.app_id, |
164 source_to_record_, | 165 source_to_record_, |
165 backoff_entry_.GetTimeUntilRelease().InMilliseconds(), | 166 backoff_entry_.GetTimeUntilRelease().InMilliseconds(), |
166 retries_left_ + 1); | 167 retries_left_ + 1); |
167 base::MessageLoop::current()->PostDelayedTask( | 168 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
168 FROM_HERE, | 169 FROM_HERE, |
169 base::Bind(&UnregistrationRequest::RetryWithBackoff, | 170 base::Bind(&UnregistrationRequest::RetryWithBackoff, |
170 weak_ptr_factory_.GetWeakPtr(), | 171 weak_ptr_factory_.GetWeakPtr(), |
171 false), | 172 false), |
172 backoff_entry_.GetTimeUntilRelease()); | 173 backoff_entry_.GetTimeUntilRelease()); |
173 return; | 174 return; |
174 } | 175 } |
175 | 176 |
176 Start(); | 177 Start(); |
177 } | 178 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); | 213 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); |
213 } | 214 } |
214 | 215 |
215 // status == SUCCESS || INVALID_PARAMETERS || UNKNOWN_ERROR || | 216 // status == SUCCESS || INVALID_PARAMETERS || UNKNOWN_ERROR || |
216 // REACHED_MAX_RETRIES | 217 // REACHED_MAX_RETRIES |
217 | 218 |
218 callback_.Run(status); | 219 callback_.Run(status); |
219 } | 220 } |
220 | 221 |
221 } // namespace gcm | 222 } // namespace gcm |
OLD | NEW |