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