OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/scheduler/test/fake_web_task_runner.h" | 5 #include "platform/scheduler/test/fake_web_task_runner.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "wtf/RefCounted.h" | 8 #include "wtf/RefCounted.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 namespace scheduler { | 11 namespace scheduler { |
12 | 12 |
13 class FakeWebTaskRunner::Data : public WTF::ThreadSafeRefCounted<Data> { | 13 class FakeWebTaskRunner::Data : public WTF::ThreadSafeRefCounted<Data> { |
14 public: | 14 public: |
15 Data() : time_(0.0) {} | 15 Data() : time_(0.0) {} |
16 | 16 |
17 std::unique_ptr<Task> task_; | 17 std::unique_ptr<Task> task_; |
| 18 base::Closure closure_; |
18 double time_; | 19 double time_; |
19 | 20 |
20 private: | 21 private: |
21 ~Data() {} | 22 ~Data() {} |
22 | 23 |
23 friend ThreadSafeRefCounted<Data>; | 24 friend ThreadSafeRefCounted<Data>; |
24 DISALLOW_COPY_AND_ASSIGN(Data); | 25 DISALLOW_COPY_AND_ASSIGN(Data); |
25 }; | 26 }; |
26 | 27 |
27 FakeWebTaskRunner::FakeWebTaskRunner() : data_(adoptRef(new Data)) {} | 28 FakeWebTaskRunner::FakeWebTaskRunner() : data_(adoptRef(new Data)) {} |
(...skipping 12 matching lines...) Expand all Loading... |
40 void FakeWebTaskRunner::postTask(const WebTraceLocation&, Task*) { | 41 void FakeWebTaskRunner::postTask(const WebTraceLocation&, Task*) { |
41 NOTREACHED(); | 42 NOTREACHED(); |
42 } | 43 } |
43 | 44 |
44 void FakeWebTaskRunner::postDelayedTask(const WebTraceLocation&, | 45 void FakeWebTaskRunner::postDelayedTask(const WebTraceLocation&, |
45 Task* task, | 46 Task* task, |
46 double) { | 47 double) { |
47 data_->task_.reset(task); | 48 data_->task_.reset(task); |
48 } | 49 } |
49 | 50 |
| 51 void FakeWebTaskRunner::postDelayedTask(const WebTraceLocation&, |
| 52 const base::Closure& closure, |
| 53 double) { |
| 54 data_->closure_ = closure; |
| 55 } |
| 56 |
50 bool FakeWebTaskRunner::runsTasksOnCurrentThread() { | 57 bool FakeWebTaskRunner::runsTasksOnCurrentThread() { |
51 return true; | 58 return true; |
52 } | 59 } |
53 | 60 |
54 std::unique_ptr<WebTaskRunner> FakeWebTaskRunner::clone() { | 61 std::unique_ptr<WebTaskRunner> FakeWebTaskRunner::clone() { |
55 return WTF::wrapUnique(new FakeWebTaskRunner(data_)); | 62 return WTF::wrapUnique(new FakeWebTaskRunner(data_)); |
56 } | 63 } |
57 | 64 |
58 double FakeWebTaskRunner::virtualTimeSeconds() const { | 65 double FakeWebTaskRunner::virtualTimeSeconds() const { |
59 return data_->time_; | 66 return data_->time_; |
60 } | 67 } |
61 | 68 |
62 double FakeWebTaskRunner::monotonicallyIncreasingVirtualTimeSeconds() const { | 69 double FakeWebTaskRunner::monotonicallyIncreasingVirtualTimeSeconds() const { |
63 return data_->time_; | 70 return data_->time_; |
64 } | 71 } |
65 | 72 |
66 SingleThreadTaskRunner* FakeWebTaskRunner::toSingleThreadTaskRunner() { | 73 SingleThreadTaskRunner* FakeWebTaskRunner::toSingleThreadTaskRunner() { |
67 NOTREACHED(); | 74 NOTREACHED(); |
68 return nullptr; | 75 return nullptr; |
69 } | 76 } |
70 | 77 |
71 } // namespace scheduler | 78 } // namespace scheduler |
72 } // namespace blink | 79 } // namespace blink |
OLD | NEW |