Revert of Fix CapsLock remapping. (patchset #2 id:20001 of https://codereview.chromiu...
[chromium-blink-merge.git] / components / gcm_driver / gcm_delayed_task_controller.h
blob0b013486b1ae3672a98ccc6d6483084f6b9f4459
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 #ifndef COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_
6 #define COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_
8 #include <vector>
10 #include "base/callback.h"
12 namespace gcm {
14 // Helper class to save tasks to run until we're ready to execute them.
15 class GCMDelayedTaskController {
16 public:
17 GCMDelayedTaskController();
18 ~GCMDelayedTaskController();
20 // Adds a task that will be invoked once we're ready.
21 void AddTask(const base::Closure& task);
23 // Sets ready status, which will release all of the pending tasks.
24 void SetReady();
26 // Returns true if it is ready to perform tasks.
27 bool CanRunTaskWithoutDelay() const;
29 private:
30 void RunTasks();
32 // Flag that indicates that controlled component is ready.
33 bool ready_;
35 std::vector<base::Closure> delayed_tasks_;
37 DISALLOW_COPY_AND_ASSIGN(GCMDelayedTaskController);
40 } // namespace gcm
42 #endif // COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_