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 #include "cc/test/ordered_simple_task_runner.h"
10 #include "base/logging.h"
14 bool TestPendingTaskComparator(const base::TestPendingTask
& lhs
,
15 const base::TestPendingTask
& rhs
) {
16 return lhs
.ShouldRunBefore(rhs
);
23 OrderedSimpleTaskRunner::OrderedSimpleTaskRunner() {}
25 OrderedSimpleTaskRunner::~OrderedSimpleTaskRunner() {}
27 void OrderedSimpleTaskRunner::RunPendingTasks() {
28 DCHECK(thread_checker_
.CalledOnValidThread());
29 // Swap with a local variable to avoid re-entrancy problems.
30 std::deque
<base::TestPendingTask
> tasks_to_run
;
31 tasks_to_run
.swap(pending_tasks_
);
32 std::stable_sort(tasks_to_run
.begin(),
34 TestPendingTaskComparator
);
35 for (std::deque
<base::TestPendingTask
>::iterator it
= tasks_to_run
.begin();
36 it
!= tasks_to_run
.end(); ++it
) {