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 WorkerScheduler
;
25 class SCHEDULER_EXPORT WebThreadImplForWorkerScheduler
26 : public WebThreadBase
,
27 public base::MessageLoop::DestructionObserver
{
29 explicit WebThreadImplForWorkerScheduler(const char* name
);
30 virtual ~WebThreadImplForWorkerScheduler();
32 // blink::WebThread implementation.
33 virtual blink::WebScheduler
* scheduler() const;
34 blink::PlatformThreadId
threadId() const override
;
36 // WebThreadBase implementation.
37 base::SingleThreadTaskRunner
* TaskRunner() const override
;
38 scheduler::SingleThreadIdleTaskRunner
* IdleTaskRunner() const override
;
40 // base::MessageLoop::DestructionObserver implementation.
41 void WillDestroyCurrentMessageLoop() override
;
44 void AddTaskObserverInternal(
45 base::MessageLoop::TaskObserver
* observer
) override
;
46 void RemoveTaskObserverInternal(
47 base::MessageLoop::TaskObserver
* observer
) override
;
49 void InitOnThread(base::WaitableEvent
* completion
);
50 void RestoreTaskRunnerOnThread(base::WaitableEvent
* completion
);
52 scoped_ptr
<base::Thread
> thread_
;
53 scoped_ptr
<scheduler::WorkerScheduler
> worker_scheduler_
;
54 scoped_ptr
<scheduler::WebSchedulerImpl
> web_scheduler_
;
55 scoped_refptr
<base::SingleThreadTaskRunner
> thread_task_runner_
;
56 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
57 scoped_refptr
<scheduler::SingleThreadIdleTaskRunner
> idle_task_runner_
;
58 scoped_refptr
<SchedulerTaskRunnerDelegate
> task_runner_delegate_
;
61 } // namespace scheduler
63 #endif // COMPONENTS_SCHEDULER_CHILD_WEBTHREAD_IMPL_FOR_WORKER_SCHEDULER_H_