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 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H
_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H
_ |
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H
_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H
_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "platform/WebTaskRunner.h" | 13 #include "platform/WebTaskRunner.h" |
14 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
15 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 namespace scheduler { | 18 namespace scheduler { |
19 | 19 |
20 // A dummy WebTaskRunner for tests. | 20 // A dummy WebTaskRunner for tests. |
21 class FakeWebTaskRunner : public WebTaskRunner { | 21 class FakeWebTaskRunner : public WebTaskRunner { |
22 public: | 22 public: |
23 FakeWebTaskRunner(); | 23 FakeWebTaskRunner(); |
24 | 24 |
25 void setTime(double new_time); | 25 void setTime(double new_time); |
26 | 26 |
27 // WebTaskRunner implementation: | 27 // WebTaskRunner implementation: |
28 void postDelayedTask(const WebTraceLocation&, base::Closure, double) override; | 28 void postDelayedTask(const WebTraceLocation&, |
| 29 base::OnceClosure, |
| 30 double) override; |
29 bool runsTasksOnCurrentThread() override; | 31 bool runsTasksOnCurrentThread() override; |
30 double virtualTimeSeconds() const override; | 32 double virtualTimeSeconds() const override; |
31 double monotonicallyIncreasingVirtualTimeSeconds() const override; | 33 double monotonicallyIncreasingVirtualTimeSeconds() const override; |
32 SingleThreadTaskRunner* toSingleThreadTaskRunner() override; | 34 SingleThreadTaskRunner* toSingleThreadTaskRunner() override; |
33 | 35 |
34 void runUntilIdle(); | 36 void runUntilIdle(); |
35 void advanceTimeAndRun(double delta_seconds); | 37 void advanceTimeAndRun(double delta_seconds); |
36 std::deque<std::pair<base::Closure, double>> takePendingTasksForTesting(); | 38 std::deque<std::pair<base::OnceClosure, double>> takePendingTasksForTesting(); |
37 | 39 |
38 private: | 40 private: |
39 ~FakeWebTaskRunner() override; | 41 ~FakeWebTaskRunner() override; |
40 | 42 |
41 class Data; | 43 class Data; |
42 class BaseTaskRunner; | 44 class BaseTaskRunner; |
43 RefPtr<Data> data_; | 45 RefPtr<Data> data_; |
44 scoped_refptr<BaseTaskRunner> base_task_runner_; | 46 scoped_refptr<BaseTaskRunner> base_task_runner_; |
45 | 47 |
46 FakeWebTaskRunner(PassRefPtr<Data> data, | 48 FakeWebTaskRunner(PassRefPtr<Data> data, |
47 scoped_refptr<BaseTaskRunner> base_task_runner); | 49 scoped_refptr<BaseTaskRunner> base_task_runner); |
48 | 50 |
49 DISALLOW_COPY_AND_ASSIGN(FakeWebTaskRunner); | 51 DISALLOW_COPY_AND_ASSIGN(FakeWebTaskRunner); |
50 }; | 52 }; |
51 | 53 |
52 } // namespace scheduler | 54 } // namespace scheduler |
53 } // namespace blink | 55 } // namespace blink |
54 | 56 |
55 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNE
R_H_ | 57 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNE
R_H_ |
OLD | NEW |