| Index: content/child/blink_platform_impl.cc
|
| diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc
|
| index 05d0cd2c903ba72e3f13cf6f13f3e2270c513c8a..75ac1489d92152578b6eb70a33921fcf3ad52010 100644
|
| --- a/content/child/blink_platform_impl.cc
|
| +++ b/content/child/blink_platform_impl.cc
|
| @@ -83,11 +83,27 @@ using blink::WebThemeEngine;
|
| using blink::WebURL;
|
| using blink::WebURLError;
|
| using blink::WebURLLoader;
|
| +using scheduler::WebThreadImplForWorkerScheduler;
|
|
|
| namespace content {
|
|
|
| namespace {
|
|
|
| +class WebThreadForCompositor : public WebThreadImplForWorkerScheduler {
|
| + public:
|
| + explicit WebThreadForCompositor(base::Thread::Options options)
|
| + : WebThreadImplForWorkerScheduler("Compositor", options) {
|
| + Init();
|
| + }
|
| + ~WebThreadForCompositor() override {}
|
| +
|
| + private:
|
| + // WebThreadImplForWorkerScheduler:
|
| + bool UseThreadTaskRunnerAsDefault() const override { return true; }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor);
|
| +};
|
| +
|
| class WebWaitableEventImpl : public blink::WebWaitableEvent {
|
| public:
|
| WebWaitableEventImpl(ResetPolicy policy, InitialState state) {
|
| @@ -482,6 +498,16 @@ void BlinkPlatformImpl::InternalInit() {
|
| }
|
| }
|
|
|
| +void BlinkPlatformImpl::WaitUntilWebThreadTLSUpdate(
|
| + scheduler::WebThreadBase* thread) {
|
| + base::WaitableEvent event(false, false);
|
| + thread->TaskRunner()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, base::Unretained(this),
|
| + base::Unretained(thread), base::Unretained(&event)));
|
| + event.Wait();
|
| +}
|
| +
|
| void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread,
|
| base::WaitableEvent* event) {
|
| DCHECK(!current_thread_slot_.Get());
|
| @@ -557,15 +583,22 @@ blink::WebThread* BlinkPlatformImpl::createThread(const char* name) {
|
| scoped_ptr<scheduler::WebThreadBase> BlinkPlatformImpl::createThreadWithOptions(
|
| const char* name,
|
| base::Thread::Options options) {
|
| - scoped_ptr<scheduler::WebThreadBase> thread(
|
| - new scheduler::WebThreadImplForWorkerScheduler(name, options));
|
| - base::WaitableEvent event(false, false);
|
| - thread->TaskRunner()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, base::Unretained(this),
|
| - base::Unretained(thread.get()), base::Unretained(&event)));
|
| - event.Wait();
|
| - return thread;
|
| + WebThreadImplForWorkerScheduler* thread =
|
| + new WebThreadImplForWorkerScheduler(name, options);
|
| + thread->Init();
|
| + WaitUntilWebThreadTLSUpdate(thread);
|
| + return make_scoped_ptr(thread);
|
| +}
|
| +
|
| +scoped_ptr<scheduler::WebThreadBase>
|
| +BlinkPlatformImpl::createCompositorThread() {
|
| + base::Thread::Options options;
|
| +#if defined(OS_ANDROID)
|
| + options.priority = base::ThreadPriority::DISPLAY;
|
| +#endif
|
| + compositor_thread_ = new WebThreadForCompositor(options);
|
| + WaitUntilWebThreadTLSUpdate(compositor_thread_);
|
| + return make_scoped_ptr(compositor_thread_);
|
| }
|
|
|
| blink::WebThread* BlinkPlatformImpl::currentThread() {
|
|
|