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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE
_LOOP_DELEGATE_FOR_TESTS_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE
_LOOP_DELEGATE_FOR_TESTS_H_ |
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE
_LOOP_DELEGATE_FOR_TESTS_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE
_LOOP_DELEGATE_FOR_TESTS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
| 10 #include "base/callback.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "base/time/tick_clock.h" | 13 #include "base/time/tick_clock.h" |
13 #include "platform/scheduler/child/scheduler_tqm_delegate.h" | 14 #include "platform/scheduler/child/scheduler_tqm_delegate.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 namespace scheduler { | 17 namespace scheduler { |
17 | 18 |
18 // This class connects the scheduler to a MessageLoop, but unlike | 19 // This class connects the scheduler to a MessageLoop, but unlike |
19 // SchedulerMessageLoopDelegate it allows the message loop to be created lazily | 20 // SchedulerMessageLoopDelegate it allows the message loop to be created lazily |
20 // after the scheduler has been brought up. This is needed in testing scenarios | 21 // after the scheduler has been brought up. This is needed in testing scenarios |
21 // where Blink is initialized before a MessageLoop has been created. | 22 // where Blink is initialized before a MessageLoop has been created. |
22 // | 23 // |
23 // TODO(skyostil): Fix the relevant test suites and remove this class | 24 // TODO(skyostil): Fix the relevant test suites and remove this class |
24 // (crbug.com/495659). | 25 // (crbug.com/495659). |
25 class LazySchedulerMessageLoopDelegateForTests : public SchedulerTqmDelegate { | 26 class LazySchedulerMessageLoopDelegateForTests : public SchedulerTqmDelegate { |
26 public: | 27 public: |
27 static scoped_refptr<LazySchedulerMessageLoopDelegateForTests> Create(); | 28 static scoped_refptr<LazySchedulerMessageLoopDelegateForTests> Create(); |
28 | 29 |
29 // SchedulerTqmDelegate implementation | 30 // SchedulerTqmDelegate implementation |
30 void SetDefaultTaskRunner( | 31 void SetDefaultTaskRunner( |
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; | 32 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; |
32 void RestoreDefaultTaskRunner() override; | 33 void RestoreDefaultTaskRunner() override; |
33 bool PostDelayedTask(const tracked_objects::Location& from_here, | 34 bool PostDelayedTask(const tracked_objects::Location& from_here, |
34 const base::Closure& task, | 35 base::Closure task, |
35 base::TimeDelta delay) override; | 36 base::TimeDelta delay) override; |
36 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 37 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
37 const base::Closure& task, | 38 base::Closure task, |
38 base::TimeDelta delay) override; | 39 base::TimeDelta delay) override; |
39 bool RunsTasksOnCurrentThread() const override; | 40 bool RunsTasksOnCurrentThread() const override; |
40 bool IsNested() const override; | 41 bool IsNested() const override; |
41 void AddNestingObserver( | 42 void AddNestingObserver( |
42 base::MessageLoop::NestingObserver* observer) override; | 43 base::MessageLoop::NestingObserver* observer) override; |
43 void RemoveNestingObserver( | 44 void RemoveNestingObserver( |
44 base::MessageLoop::NestingObserver* observer) override; | 45 base::MessageLoop::NestingObserver* observer) override; |
45 base::TimeTicks NowTicks() override; | 46 base::TimeTicks NowTicks() override; |
46 | 47 |
47 private: | 48 private: |
(...skipping 13 matching lines...) Expand all Loading... |
61 | 62 |
62 base::MessageLoop::NestingObserver* pending_observer_; | 63 base::MessageLoop::NestingObserver* pending_observer_; |
63 | 64 |
64 DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegateForTests); | 65 DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegateForTests); |
65 }; | 66 }; |
66 | 67 |
67 } // namespace scheduler | 68 } // namespace scheduler |
68 } // namespace blink | 69 } // namespace blink |
69 | 70 |
70 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_LAZY_SCHEDULER_MESS
AGE_LOOP_DELEGATE_FOR_TESTS_H_ | 71 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_LAZY_SCHEDULER_MESS
AGE_LOOP_DELEGATE_FOR_TESTS_H_ |
OLD | NEW |