| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS
_H_ | 5 #ifndef COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS
_H_ |
| 6 #define COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS
_H_ | 6 #define COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS
_H_ |
| 7 | 7 |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/tick_clock.h" |
| 9 #include "components/scheduler/child/scheduler_task_runner_delegate.h" | 10 #include "components/scheduler/child/scheduler_task_runner_delegate.h" |
| 10 | 11 |
| 11 namespace scheduler { | 12 namespace scheduler { |
| 12 | 13 |
| 13 // This class connects the scheduler to a MessageLoop, but unlike | 14 // This class connects the scheduler to a MessageLoop, but unlike |
| 14 // SchedulerMessageLoopDelegate it allows the message loop to be created lazily | 15 // SchedulerMessageLoopDelegate it allows the message loop to be created lazily |
| 15 // after the scheduler has been brought up. This is needed in testing scenarios | 16 // after the scheduler has been brought up. This is needed in testing scenarios |
| 16 // where Blink is initialized before a MessageLoop has been created. | 17 // where Blink is initialized before a MessageLoop has been created. |
| 17 // | 18 // |
| 18 // TODO(skyostil): Fix the relevant test suites and remove this class | 19 // TODO(skyostil): Fix the relevant test suites and remove this class |
| 19 // (crbug.com/495659). | 20 // (crbug.com/495659). |
| 20 class LazySchedulerMessageLoopDelegateForTests | 21 class LazySchedulerMessageLoopDelegateForTests |
| 21 : public SchedulerTaskRunnerDelegate { | 22 : public SchedulerTaskRunnerDelegate { |
| 22 public: | 23 public: |
| 23 static scoped_refptr<LazySchedulerMessageLoopDelegateForTests> Create(); | 24 static scoped_refptr<LazySchedulerMessageLoopDelegateForTests> Create(); |
| 24 | 25 |
| 25 // SchedulerTaskRunnerDelegate implementation | 26 // SchedulerTaskRunnerDelegate implementation |
| 26 void SetDefaultTaskRunner( | 27 void SetDefaultTaskRunner( |
| 27 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; | 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; |
| 28 void RestoreDefaultTaskRunner() override; | 29 void RestoreDefaultTaskRunner() override; |
| 29 bool PostDelayedTask(const tracked_objects::Location& from_here, | 30 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 30 const base::Closure& task, | 31 const base::Closure& task, |
| 31 base::TimeDelta delay) override; | 32 base::TimeDelta delay) override; |
| 32 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 33 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 33 const base::Closure& task, | 34 const base::Closure& task, |
| 34 base::TimeDelta delay) override; | 35 base::TimeDelta delay) override; |
| 35 bool RunsTasksOnCurrentThread() const override; | 36 bool RunsTasksOnCurrentThread() const override; |
| 36 bool IsNested() const override; | 37 bool IsNested() const override; |
| 38 base::TimeTicks NowTicks() override; |
| 39 void OnNoMoreWork() override; |
| 37 | 40 |
| 38 private: | 41 private: |
| 39 LazySchedulerMessageLoopDelegateForTests(); | 42 LazySchedulerMessageLoopDelegateForTests(); |
| 40 ~LazySchedulerMessageLoopDelegateForTests() override; | 43 ~LazySchedulerMessageLoopDelegateForTests() override; |
| 41 | 44 |
| 42 bool HasMessageLoop() const; | 45 bool HasMessageLoop() const; |
| 43 base::MessageLoop* EnsureMessageLoop() const; | 46 base::MessageLoop* EnsureMessageLoop() const; |
| 44 | 47 |
| 45 mutable base::MessageLoop* message_loop_; | 48 mutable base::MessageLoop* message_loop_; |
| 46 base::PlatformThreadId thread_id_; | 49 base::PlatformThreadId thread_id_; |
| 47 | 50 |
| 48 // A task runner which hasn't yet been overridden in the message loop. | 51 // A task runner which hasn't yet been overridden in the message loop. |
| 49 mutable scoped_refptr<base::SingleThreadTaskRunner> pending_task_runner_; | 52 mutable scoped_refptr<base::SingleThreadTaskRunner> pending_task_runner_; |
| 50 mutable scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_; | 53 mutable scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_; |
| 54 scoped_ptr<base::TickClock> time_source_; |
| 51 | 55 |
| 52 DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegateForTests); | 56 DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegateForTests); |
| 53 }; | 57 }; |
| 54 | 58 |
| 55 } // namespace scheduler | 59 } // namespace scheduler |
| 56 | 60 |
| 57 #endif // COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TE
STS_H_ | 61 #endif // COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TE
STS_H_ |
| OLD | NEW |