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_
10 #include "base/callback.h"
14 // Helper class to save tasks to run until we're ready to execute them.
15 class GCMDelayedTaskController
{
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.
26 // Returns true if it is ready to perform tasks.
27 bool CanRunTaskWithoutDelay() const;
32 // Flag that indicates that controlled component is ready.
35 std::vector
<base::Closure
> delayed_tasks_
;
37 DISALLOW_COPY_AND_ASSIGN(GCMDelayedTaskController
);
42 #endif // COMPONENTS_GCM_DRIVER_GCM_DELAYED_TASK_CONTROLLER_H_