Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / test / fake_single_thread_task_runner.cc
blobd2950fd9fb6df2efe7fa9799709e4ead88ce927c
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 "media/cast/test/fake_single_thread_task_runner.h"
7 #include "base/logging.h"
8 #include "base/time/tick_clock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace media {
12 namespace cast {
13 namespace test {
15 FakeSingleThreadTaskRunner::FakeSingleThreadTaskRunner(
16 base::SimpleTestTickClock* clock)
17 : clock_(clock) {}
19 FakeSingleThreadTaskRunner::~FakeSingleThreadTaskRunner() {}
21 bool FakeSingleThreadTaskRunner::PostDelayedTask(
22 const tracked_objects::Location& from_here,
23 const base::Closure& task,
24 base::TimeDelta delay) {
25 EXPECT_GE(delay, base::TimeDelta());
26 PostedTask posed_task(from_here,
27 task,
28 clock_->NowTicks(),
29 delay,
30 base::TestPendingTask::NESTABLE);
32 tasks_.insert(std::make_pair(posed_task.GetTimeToRun(), posed_task));
33 return false;
36 bool FakeSingleThreadTaskRunner::RunsTasksOnCurrentThread() const {
37 return true;
40 void FakeSingleThreadTaskRunner::RunTasks() {
41 while(true) {
42 // Run all tasks equal or older than current time.
43 std::multimap<base::TimeTicks, PostedTask>::iterator it = tasks_.begin();
44 if (it == tasks_.end())
45 return; // No more tasks.
47 PostedTask task = it->second;
48 if (clock_->NowTicks() < task.GetTimeToRun())
49 return;
51 tasks_.erase(it);
52 task.task.Run();
56 bool FakeSingleThreadTaskRunner::PostNonNestableDelayedTask(
57 const tracked_objects::Location& from_here,
58 const base::Closure& task,
59 base::TimeDelta delay) {
60 NOTIMPLEMENTED();
61 return false;
64 } // namespace test
65 } // namespace cast
66 } // namespace media