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 "components/gcm_driver/gcm_channel_status_request.h" | 5 #include "components/gcm_driver/gcm_channel_status_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/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
9 #include "components/gcm_driver/gcm_backoff_policy.h" | 11 #include "components/gcm_driver/gcm_backoff_policy.h" |
10 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
11 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
12 #include "net/http/http_status_code.h" | 14 #include "net/http/http_status_code.h" |
13 #include "net/url_request/url_fetcher.h" | 15 #include "net/url_request/url_fetcher.h" |
14 #include "net/url_request/url_request_status.h" | 16 #include "net/url_request/url_request_status.h" |
15 #include "sync/protocol/experiment_status.pb.h" | 17 #include "sync/protocol/experiment_status.pb.h" |
16 #include "url/gurl.h" | 18 #include "url/gurl.h" |
17 | 19 |
18 namespace gcm { | 20 namespace gcm { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void GCMChannelStatusRequest::RetryWithBackoff(bool update_backoff) { | 137 void GCMChannelStatusRequest::RetryWithBackoff(bool update_backoff) { |
136 if (update_backoff) { | 138 if (update_backoff) { |
137 url_fetcher_.reset(); | 139 url_fetcher_.reset(); |
138 backoff_entry_.InformOfRequest(false); | 140 backoff_entry_.InformOfRequest(false); |
139 } | 141 } |
140 | 142 |
141 if (backoff_entry_.ShouldRejectRequest()) { | 143 if (backoff_entry_.ShouldRejectRequest()) { |
142 DVLOG(1) << "Delaying GCM channel request for " | 144 DVLOG(1) << "Delaying GCM channel request for " |
143 << backoff_entry_.GetTimeUntilRelease().InMilliseconds() | 145 << backoff_entry_.GetTimeUntilRelease().InMilliseconds() |
144 << " ms."; | 146 << " ms."; |
145 base::MessageLoop::current()->PostDelayedTask( | 147 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
146 FROM_HERE, | 148 FROM_HERE, base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, |
147 base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, | 149 weak_ptr_factory_.GetWeakPtr(), false), |
148 weak_ptr_factory_.GetWeakPtr(), | |
149 false), | |
150 backoff_entry_.GetTimeUntilRelease()); | 150 backoff_entry_.GetTimeUntilRelease()); |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 Start(); | 154 Start(); |
155 } | 155 } |
156 | 156 |
157 } // namespace gcm | 157 } // namespace gcm |
OLD | NEW |