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

Side by Side Diff: base/task_queue.cc

Issue 8570022: base::Bind() conversion for chrome/browser/search_engines (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/task_queue.h ('k') | base/task_queue_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include "base/task_queue.h"
6
7 #include "base/logging.h"
8 #include "base/stl_util.h"
9
10 TaskQueue::TaskQueue() {
11 }
12
13 TaskQueue::~TaskQueue() {
14 // We own all the pointes in |queue_|. It is our job to delete them.
15 STLDeleteElements(&queue_);
16 }
17
18 void TaskQueue::Push(Task* task) {
19 DCHECK(task);
20
21 // Add the task to the back of the queue.
22 queue_.push_back(task);
23 }
24
25 void TaskQueue::Clear() {
26 // Delete all the elements in the queue and clear the dead pointers.
27 STLDeleteElements(&queue_);
28 }
29
30 bool TaskQueue::IsEmpty() const {
31 return queue_.empty();
32 }
33
34 void TaskQueue::Run() {
35 // Nothing to run if our queue is empty.
36 if (queue_.empty())
37 return;
38
39 std::deque<Task*> ready;
40 queue_.swap(ready);
41
42 // Run the tasks that are ready.
43 std::deque<Task*>::const_iterator task;
44 for (task = ready.begin(); task != ready.end(); ++task) {
45 // Run the task and then delete it.
46 (*task)->Run();
47 delete (*task);
48 }
49 }
OLDNEW
« no previous file with comments | « base/task_queue.h ('k') | base/task_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698