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

Unified Diff: components/gcm_driver/gcm_delayed_task_controller.h

Issue 551163002: [GCM] Extracting Delayed Task Controller from GCMDesktopDriver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Solving compilation issue 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.h
diff --git a/components/gcm_driver/gcm_delayed_task_controller.h b/components/gcm_driver/gcm_delayed_task_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b013486b1ae3672a98ccc6d6483084f6b9f4459
--- /dev/null
+++ b/components/gcm_driver/gcm_delayed_task_controller.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_
+#define COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+
+namespace gcm {
+
+// Helper class to save tasks to run until we're ready to execute them.
+class GCMDelayedTaskController {
+ public:
+ GCMDelayedTaskController();
+ ~GCMDelayedTaskController();
+
+ // Adds a task that will be invoked once we're ready.
+ void AddTask(const base::Closure& task);
+
+ // Sets ready status, which will release all of the pending tasks.
+ void SetReady();
+
+ // Returns true if it is ready to perform tasks.
+ bool CanRunTaskWithoutDelay() const;
+
+ private:
+ void RunTasks();
+
+ // Flag that indicates that controlled component is ready.
+ bool ready_;
+
+ std::vector<base::Closure> delayed_tasks_;
+
+ DISALLOW_COPY_AND_ASSIGN(GCMDelayedTaskController);
+};
+
+} // namespace gcm
+
+#endif // COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698