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_CHILD_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_ | 5 #ifndef COMPONENTS_SCHEDULER_CHILD_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_ |
6 #define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_ | 6 #define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_ |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "components/scheduler/child/nestable_single_thread_task_runner.h" | 9 #include "components/scheduler/child/nestable_single_thread_task_runner.h" |
10 #include "components/scheduler/scheduler_export.h" | 10 #include "components/scheduler/scheduler_export.h" |
11 | 11 |
12 namespace scheduler { | 12 namespace scheduler { |
13 | 13 |
14 class SCHEDULER_EXPORT SchedulerMessageLoopDelegate | 14 class SCHEDULER_EXPORT SchedulerMessageLoopDelegate |
15 : public NestableSingleThreadTaskRunner { | 15 : public NestableSingleThreadTaskRunner { |
16 public: | 16 public: |
17 // |message_loop| is not owned and must outlive the lifetime of this object. | 17 // |message_loop| is not owned and must outlive the lifetime of this object. |
18 static scoped_refptr<SchedulerMessageLoopDelegate> Create( | 18 static scoped_refptr<SchedulerMessageLoopDelegate> Create( |
19 base::MessageLoop* message_loop); | 19 base::MessageLoop* message_loop); |
20 | 20 |
21 // NestableSingleThreadTaskRunner implementation | 21 // NestableSingleThreadTaskRunner implementation |
| 22 void SetDefaultTaskRunner( |
| 23 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override; |
22 bool PostDelayedTask(const tracked_objects::Location& from_here, | 24 bool PostDelayedTask(const tracked_objects::Location& from_here, |
23 const base::Closure& task, | 25 const base::Closure& task, |
24 base::TimeDelta delay) override; | 26 base::TimeDelta delay) override; |
25 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 27 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
26 const base::Closure& task, | 28 const base::Closure& task, |
27 base::TimeDelta delay) override; | 29 base::TimeDelta delay) override; |
28 bool RunsTasksOnCurrentThread() const override; | 30 bool RunsTasksOnCurrentThread() const override; |
29 bool IsNested() const override; | 31 bool IsNested() const override; |
30 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; | 32 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; |
31 void RemoveTaskObserver( | 33 void RemoveTaskObserver( |
32 base::MessageLoop::TaskObserver* task_observer) override; | 34 base::MessageLoop::TaskObserver* task_observer) override; |
33 | 35 |
34 protected: | 36 protected: |
35 ~SchedulerMessageLoopDelegate() override; | 37 ~SchedulerMessageLoopDelegate() override; |
36 | 38 |
37 private: | 39 private: |
38 SchedulerMessageLoopDelegate(base::MessageLoop* message_loop); | 40 SchedulerMessageLoopDelegate(base::MessageLoop* message_loop); |
39 | 41 |
40 // Not owned. | 42 // Not owned. |
41 base::MessageLoop* message_loop_; | 43 base::MessageLoop* message_loop_; |
| 44 scoped_refptr<SingleThreadTaskRunner> message_loop_task_runner_; |
42 | 45 |
43 DISALLOW_COPY_AND_ASSIGN(SchedulerMessageLoopDelegate); | 46 DISALLOW_COPY_AND_ASSIGN(SchedulerMessageLoopDelegate); |
44 }; | 47 }; |
45 | 48 |
46 } // namespace scheduler | 49 } // namespace scheduler |
47 | 50 |
48 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_ | 51 #endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_ |
OLD | NEW |