blob: 8ccf47ec1610216793a1e07822ba446f11bd1af6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/test/scheduler_test_common.h"
#include "base/logging.h"
namespace cc {
void FakeTimeSourceClient::OnTimerTick() { tick_called_ = true; }
FakeThread::FakeThread() { Reset(); }
FakeThread::~FakeThread() {}
void FakeThread::RunPendingTask() {
ASSERT_TRUE(pending_task_);
scoped_ptr<base::Closure> task = pending_task_.Pass();
task->Run();
}
void FakeThread::PostTask(base::Closure cb) {
PostDelayedTask(cb, base::TimeDelta());
}
void FakeThread::PostDelayedTask(base::Closure cb, base::TimeDelta delay) {
if (run_pending_task_on_overwrite_ && HasPendingTask())
RunPendingTask();
ASSERT_FALSE(HasPendingTask());
pending_task_.reset(new base::Closure(cb));
pending_task_delay_ = delay.InMilliseconds();
}
bool FakeThread::BelongsToCurrentThread() const { return true; }
base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; }
} // namespace cc
|