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