Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / gcm_driver / gcm_delayed_task_controller.cc
blob0506a34848d3b4bb2700905d0c8583fb7244c1e4
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.
5 #include "components/gcm_driver/gcm_delayed_task_controller.h"
7 #include "base/logging.h"
9 namespace gcm {
11 GCMDelayedTaskController::GCMDelayedTaskController() : ready_(false) {
14 GCMDelayedTaskController::~GCMDelayedTaskController() {
17 void GCMDelayedTaskController::AddTask(const base::Closure& task) {
18 delayed_tasks_.push_back(task);
21 void GCMDelayedTaskController::SetReady() {
22 ready_ = true;
23 RunTasks();
26 bool GCMDelayedTaskController::CanRunTaskWithoutDelay() const {
27 return ready_;
30 void GCMDelayedTaskController::RunTasks() {
31 DCHECK(ready_);
33 for (size_t i = 0; i < delayed_tasks_.size(); ++i)
34 delayed_tasks_[i].Run();
35 delayed_tasks_.clear();
38 } // namespace gcm