| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "third_party/blink/renderer/platform/testing/testing_platform_support_with_custom_scheduler.h" |
| |
| #include "third_party/blink/public/platform/web_thread.h" |
| #include "third_party/blink/renderer/platform/wtf/wtf.h" |
| |
| namespace blink { |
| |
| namespace { |
| |
| class ThreadWithCustomScheduler : public WebThread { |
| public: |
| explicit ThreadWithCustomScheduler(ThreadScheduler* scheduler) |
| : scheduler_(scheduler) {} |
| ~ThreadWithCustomScheduler() override {} |
| |
| bool IsCurrentThread() const override { |
| DCHECK(WTF::IsMainThread()); |
| return true; |
| } |
| ThreadScheduler* Scheduler() const override { return scheduler_; } |
| |
| private: |
| ThreadScheduler* scheduler_; |
| }; |
| |
| } // namespace |
| |
| TestingPlatformSupportWithCustomScheduler :: |
| TestingPlatformSupportWithCustomScheduler(ThreadScheduler* scheduler) |
| : thread_(std::make_unique<ThreadWithCustomScheduler>(scheduler)) {} |
| |
| TestingPlatformSupportWithCustomScheduler :: |
| ~TestingPlatformSupportWithCustomScheduler() {} |
| |
| WebThread* TestingPlatformSupportWithCustomScheduler::CurrentThread() { |
| DCHECK(WTF::IsMainThread()); |
| return thread_.get(); |
| } |
| |
| } // namespace blink |