Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Copyright (c) 2006-2008 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 CHROME_COMMON_TASK_QUEUE_H__
6 #define CHROME_COMMON_TASK_QUEUE_H__
8 #include <deque>
10 #include "base/task.h"
12 // A TaskQueue is a queue of tasks waiting to be run. To run the tasks, call
13 // the Run method. A task queue is itself a Task so that it can be placed in a
14 // message loop or another task queue.
15 class TaskQueue : public Task {
16 public:
17 TaskQueue();
18 ~TaskQueue();
20 // Run all the tasks in the queue. New tasks pushed onto the queue during
21 // a run will be run next time |Run| is called.
22 virtual void Run();
24 // Push the specified task onto the queue. When the queue is run, the tasks
25 // will be run in the order they are pushed.
26 //
27 // This method takes ownership of |task| and will delete task after it is run
28 // (or when the TaskQueue is destroyed, if we never got a chance to run it).
29 void Push(Task* task);
31 // Remove all tasks from the queue. The tasks are deleted.
32 void Clear();
34 // Returns true if this queue contains no tasks.
35 bool Empty() const;
37 private:
38 // The list of tasks we are waiting to run.
39 std::deque<Task*> queue_;
40 };
42 #endif // CHROME_COMMON_TASK_QUEUE_H__