| 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 "platform/wtf/PassRefPtr.h" | 14 #include "platform/wtf/PassRefPtr.h" |
| 15 #include "platform/wtf/RefPtr.h" | 15 #include "platform/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&, | |
| 29 base::OnceClosure, | |
| 30 double) override; | |
| 31 bool RunsTasksInCurrentSequence() override; | 28 bool RunsTasksInCurrentSequence() override; |
| 32 double VirtualTimeSeconds() const override; | 29 double VirtualTimeSeconds() const override; |
| 33 double MonotonicallyIncreasingVirtualTimeSeconds() const override; | 30 double MonotonicallyIncreasingVirtualTimeSeconds() const override; |
| 34 SingleThreadTaskRunner* ToSingleThreadTaskRunner() override; | 31 SingleThreadTaskRunner* ToSingleThreadTaskRunner() override; |
| 35 | 32 |
| 36 void RunUntilIdle(); | 33 void RunUntilIdle(); |
| 37 void AdvanceTimeAndRun(double delta_seconds); | 34 void AdvanceTimeAndRun(double delta_seconds); |
| 38 std::deque<std::pair<base::OnceClosure, double>> TakePendingTasksForTesting(); | 35 std::deque<std::pair<base::OnceClosure, double>> TakePendingTasksForTesting(); |
| 39 | 36 |
| 40 private: | 37 private: |
| 41 ~FakeWebTaskRunner() override; | 38 ~FakeWebTaskRunner() override; |
| 42 | 39 |
| 43 class Data; | 40 class Data; |
| 44 class BaseTaskRunner; | 41 class BaseTaskRunner; |
| 45 RefPtr<Data> data_; | 42 RefPtr<Data> data_; |
| 46 scoped_refptr<BaseTaskRunner> base_task_runner_; | 43 scoped_refptr<BaseTaskRunner> base_task_runner_; |
| 47 | 44 |
| 48 FakeWebTaskRunner(PassRefPtr<Data> data, | 45 FakeWebTaskRunner(PassRefPtr<Data> data, |
| 49 scoped_refptr<BaseTaskRunner> base_task_runner); | 46 scoped_refptr<BaseTaskRunner> base_task_runner); |
| 50 | 47 |
| 51 DISALLOW_COPY_AND_ASSIGN(FakeWebTaskRunner); | 48 DISALLOW_COPY_AND_ASSIGN(FakeWebTaskRunner); |
| 52 }; | 49 }; |
| 53 | 50 |
| 54 } // namespace scheduler | 51 } // namespace scheduler |
| 55 } // namespace blink | 52 } // namespace blink |
| 56 | 53 |
| 57 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNE
R_H_ | 54 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNE
R_H_ |
| OLD | NEW |