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

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

Issue 551163002: [GCM] Extracting Delayed Task Controller from GCMDesktopDriver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/gcm_driver/gcm_delayed_task_controller.h"
6
7 #include "base/logging.h"
8
9 namespace gcm {
10
11 GCMDelayedTaskController::GCMDelayedTaskController() : ready_(false) {
12 }
13
14 GCMDelayedTaskController::~GCMDelayedTaskController() {
15 }
16
17 void GCMDelayedTaskController::AddTask(const base::Closure& task) {
18 delayed_tasks_.push_back(task);
19 }
20
21 void GCMDelayedTaskController::SetReady() {
22 ready_ = true;
23 RunTasks();
24 }
25
26 bool GCMDelayedTaskController::CanRunTaskWithoutDelay() const {
27 return ready_;
28 }
29
30 void GCMDelayedTaskController::RunTasks() {
31 DCHECK(ready_);
32
33 for (size_t i = 0; i < delayed_tasks_.size(); ++i)
34 delayed_tasks_[i].Run();
35 delayed_tasks_.clear();
36 }
37
38 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_delayed_task_controller.h ('k') | components/gcm_driver/gcm_delayed_task_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698