OLD | NEW |
(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 #ifndef COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 |
| 12 namespace gcm { |
| 13 |
| 14 // Helper class to save tasks to run until we're ready to execute them. |
| 15 class GCMDelayedTaskController { |
| 16 public: |
| 17 GCMDelayedTaskController(); |
| 18 ~GCMDelayedTaskController(); |
| 19 |
| 20 // Adds a task that will be invoked once we're ready. |
| 21 void AddTask(const base::Closure& task); |
| 22 |
| 23 // Sets ready status, which will release all of the pending tasks. |
| 24 void SetReady(); |
| 25 |
| 26 // Returns true if it is ready to perform tasks. |
| 27 bool CanRunTaskWithoutDelay() const; |
| 28 |
| 29 private: |
| 30 void RunTasks(); |
| 31 |
| 32 // Flag that indicates that controlled component is ready. |
| 33 bool ready_; |
| 34 |
| 35 std::vector<base::Closure> delayed_tasks_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(GCMDelayedTaskController); |
| 38 }; |
| 39 |
| 40 } // namespace gcm |
| 41 |
| 42 #endif // COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_ |
OLD | NEW |