Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(961)

Side by Side Diff: components/gcm_driver/gcm_channel_status_syncer.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_syncer.h" 5 #include "components/gcm_driver/gcm_channel_status_syncer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/prefs/pref_registry_simple.h" 11 #include "base/prefs/pref_registry_simple.h"
13 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
14 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/thread_task_runner_handle.h"
16 #include "components/gcm_driver/gcm_channel_status_request.h" 17 #include "components/gcm_driver/gcm_channel_status_request.h"
17 #include "components/gcm_driver/gcm_driver.h" 18 #include "components/gcm_driver/gcm_driver.h"
18 #include "components/pref_registry/pref_registry_syncable.h" 19 #include "components/pref_registry/pref_registry_syncable.h"
19 20
20 namespace gcm { 21 namespace gcm {
21 22
22 namespace { 23 namespace {
23 24
24 // A small delay to avoid sending request at browser startup time for first-time 25 // A small delay to avoid sending request at browser startup time for first-time
25 // request. 26 // request.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 176 }
176 } 177 }
177 178
178 // Do not schedule next request if syncer is stopped. 179 // Do not schedule next request if syncer is stopped.
179 if (started_) 180 if (started_)
180 ScheduleRequest(); 181 ScheduleRequest();
181 } 182 }
182 183
183 void GCMChannelStatusSyncer::ScheduleRequest() { 184 void GCMChannelStatusSyncer::ScheduleRequest() {
184 current_request_delay_interval_ = GetRequestDelayInterval(); 185 current_request_delay_interval_ = GetRequestDelayInterval();
185 base::MessageLoop::current()->PostDelayedTask( 186 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
186 FROM_HERE, 187 FROM_HERE, base::Bind(&GCMChannelStatusSyncer::StartRequest,
187 base::Bind(&GCMChannelStatusSyncer::StartRequest, 188 weak_ptr_factory_.GetWeakPtr()),
188 weak_ptr_factory_.GetWeakPtr()),
189 current_request_delay_interval_); 189 current_request_delay_interval_);
190 190
191 if (custom_poll_interval_use_count_) 191 if (custom_poll_interval_use_count_)
192 custom_poll_interval_use_count_--; 192 custom_poll_interval_use_count_--;
193 } 193 }
194 194
195 void GCMChannelStatusSyncer::StartRequest() { 195 void GCMChannelStatusSyncer::StartRequest() {
196 DCHECK(!request_); 196 DCHECK(!request_);
197 197
198 request_.reset(new GCMChannelStatusRequest( 198 request_.reset(new GCMChannelStatusRequest(
(...skipping 26 matching lines...) Expand all
225 // Otherwise, add a fuzzing variation to the delay. 225 // Otherwise, add a fuzzing variation to the delay.
226 // The fuzzing variation is off when the custom interval is used. 226 // The fuzzing variation is off when the custom interval is used.
227 if (!custom_poll_interval_use_count_) 227 if (!custom_poll_interval_use_count_)
228 delay_seconds += base::RandInt(0, kGCMChannelRequestTimeJitterSeconds); 228 delay_seconds += base::RandInt(0, kGCMChannelRequestTimeJitterSeconds);
229 } 229 }
230 230
231 return base::TimeDelta::FromSeconds(delay_seconds); 231 return base::TimeDelta::FromSeconds(delay_seconds);
232 } 232 }
233 233
234 } // namespace gcm 234 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_channel_status_request_unittest.cc ('k') | components/gcm_driver/gcm_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698