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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/gcm_delayed_task_controller.cc
diff --git a/components/gcm_driver/gcm_delayed_task_controller.cc b/components/gcm_driver/gcm_delayed_task_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0506a34848d3b4bb2700905d0c8583fb7244c1e4
--- /dev/null
+++ b/components/gcm_driver/gcm_delayed_task_controller.cc
@@ -0,0 +1,38 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/gcm_driver/gcm_delayed_task_controller.h"
+
+#include "base/logging.h"
+
+namespace gcm {
+
+GCMDelayedTaskController::GCMDelayedTaskController() : ready_(false) {
+}
+
+GCMDelayedTaskController::~GCMDelayedTaskController() {
+}
+
+void GCMDelayedTaskController::AddTask(const base::Closure& task) {
+ delayed_tasks_.push_back(task);
+}
+
+void GCMDelayedTaskController::SetReady() {
+ ready_ = true;
+ RunTasks();
+}
+
+bool GCMDelayedTaskController::CanRunTaskWithoutDelay() const {
+ return ready_;
+}
+
+void GCMDelayedTaskController::RunTasks() {
+ DCHECK(ready_);
+
+ for (size_t i = 0; i < delayed_tasks_.size(); ++i)
+ delayed_tasks_[i].Run();
+ delayed_tasks_.clear();
+}
+
+} // namespace gcm
« 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