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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SCHEDULER_CHILD_WEBTHREAD_IMPL_FOR_WORKER_SCHEDULER_H_
6 #define COMPONENTS_SCHEDULER_CHILD_WEBTHREAD_IMPL_FOR_WORKER_SCHEDULER_H_
8 #include "components/scheduler/child/task_queue_manager.h"
9 #include "components/scheduler/child/webthread_base.h"
20 class SchedulerTaskRunnerDelegate
;
21 class SingleThreadIdleTaskRunner
;
22 class WebSchedulerImpl
;
23 class WebTaskRunnerImpl
;
24 class WorkerScheduler
;
26 class SCHEDULER_EXPORT WebThreadImplForWorkerScheduler
27 : public WebThreadBase
,
28 public base::MessageLoop::DestructionObserver
{
30 explicit WebThreadImplForWorkerScheduler(const char* name
);
31 virtual ~WebThreadImplForWorkerScheduler();
33 // blink::WebThread implementation.
34 virtual blink::WebScheduler
* scheduler() const;
35 blink::PlatformThreadId
threadId() const override
;
36 virtual blink::WebTaskRunner
* taskRunner();
38 // WebThreadBase implementation.
39 base::SingleThreadTaskRunner
* TaskRunner() const override
;
40 scheduler::SingleThreadIdleTaskRunner
* IdleTaskRunner() const override
;
42 // base::MessageLoop::DestructionObserver implementation.
43 void WillDestroyCurrentMessageLoop() override
;
46 void AddTaskObserverInternal(
47 base::MessageLoop::TaskObserver
* observer
) override
;
48 void RemoveTaskObserverInternal(
49 base::MessageLoop::TaskObserver
* observer
) override
;
51 void InitOnThread(base::WaitableEvent
* completion
);
52 void RestoreTaskRunnerOnThread(base::WaitableEvent
* completion
);
54 scoped_ptr
<base::Thread
> thread_
;
55 scoped_ptr
<scheduler::WorkerScheduler
> worker_scheduler_
;
56 scoped_ptr
<scheduler::WebSchedulerImpl
> web_scheduler_
;
57 scoped_refptr
<base::SingleThreadTaskRunner
> thread_task_runner_
;
58 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
59 scoped_refptr
<scheduler::SingleThreadIdleTaskRunner
> idle_task_runner_
;
60 scoped_refptr
<SchedulerTaskRunnerDelegate
> task_runner_delegate_
;
61 scoped_ptr
<WebTaskRunnerImpl
> web_task_runner_
;
64 } // namespace scheduler
66 #endif // COMPONENTS_SCHEDULER_CHILD_WEBTHREAD_IMPL_FOR_WORKER_SCHEDULER_H_