Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: content/child/blink_platform_impl.cc

Issue 1589463002: compositor worker: Use a WebThread for the compositor thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self-nits Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/child/blink_platform_impl.h" 5 #include "content/child/blink_platform_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 #include "ui/events/keycodes/dom/keycode_converter.h" 76 #include "ui/events/keycodes/dom/keycode_converter.h"
77 77
78 using blink::WebData; 78 using blink::WebData;
79 using blink::WebFallbackThemeEngine; 79 using blink::WebFallbackThemeEngine;
80 using blink::WebLocalizedString; 80 using blink::WebLocalizedString;
81 using blink::WebString; 81 using blink::WebString;
82 using blink::WebThemeEngine; 82 using blink::WebThemeEngine;
83 using blink::WebURL; 83 using blink::WebURL;
84 using blink::WebURLError; 84 using blink::WebURLError;
85 using blink::WebURLLoader; 85 using blink::WebURLLoader;
86 using scheduler::WebThreadImplForWorkerScheduler;
86 87
87 namespace content { 88 namespace content {
88 89
89 namespace { 90 namespace {
90 91
92 class WebThreadForCompositor : public WebThreadImplForWorkerScheduler {
93 public:
94 explicit WebThreadForCompositor(base::Thread::Options options)
95 : WebThreadImplForWorkerScheduler("Compositor", options) {
96 Init();
97 }
98 ~WebThreadForCompositor() override {}
99
100 private:
101 // WebThreadImplForWorkerScheduler:
102 bool UseThreadTaskRunnerAsDefault() const override { return true; }
103
104 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor);
105 };
106
91 class WebWaitableEventImpl : public blink::WebWaitableEvent { 107 class WebWaitableEventImpl : public blink::WebWaitableEvent {
92 public: 108 public:
93 WebWaitableEventImpl(ResetPolicy policy, InitialState state) { 109 WebWaitableEventImpl(ResetPolicy policy, InitialState state) {
94 bool manual_reset = policy == ResetPolicy::Manual; 110 bool manual_reset = policy == ResetPolicy::Manual;
95 bool initially_signaled = state == InitialState::Signaled; 111 bool initially_signaled = state == InitialState::Signaled;
96 impl_.reset(new base::WaitableEvent(manual_reset, initially_signaled)); 112 impl_.reset(new base::WaitableEvent(manual_reset, initially_signaled));
97 } 113 }
98 ~WebWaitableEventImpl() override {} 114 ~WebWaitableEventImpl() override {}
99 115
100 void reset() override { impl_->Reset(); } 116 void reset() override { impl_->Reset(); }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 notification_dispatcher_ = 491 notification_dispatcher_ =
476 ChildThreadImpl::current()->notification_dispatcher(); 492 ChildThreadImpl::current()->notification_dispatcher();
477 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher(); 493 push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher();
478 permission_client_.reset(new PermissionDispatcher( 494 permission_client_.reset(new PermissionDispatcher(
479 ChildThreadImpl::current()->service_registry())); 495 ChildThreadImpl::current()->service_registry()));
480 main_thread_sync_provider_.reset( 496 main_thread_sync_provider_.reset(
481 new BackgroundSyncProvider(main_thread_task_runner_.get())); 497 new BackgroundSyncProvider(main_thread_task_runner_.get()));
482 } 498 }
483 } 499 }
484 500
501 void BlinkPlatformImpl::WaitUntilWebThreadTLSUpdate(
502 scheduler::WebThreadBase* thread) {
503 base::WaitableEvent event(false, false);
504 thread->TaskRunner()->PostTask(
505 FROM_HERE,
506 base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, base::Unretained(this),
507 base::Unretained(thread), base::Unretained(&event)));
508 event.Wait();
509 }
510
485 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread, 511 void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread,
486 base::WaitableEvent* event) { 512 base::WaitableEvent* event) {
487 DCHECK(!current_thread_slot_.Get()); 513 DCHECK(!current_thread_slot_.Get());
488 current_thread_slot_.Set(thread); 514 current_thread_slot_.Set(thread);
489 event->Signal(); 515 event->Signal();
490 } 516 }
491 517
492 BlinkPlatformImpl::~BlinkPlatformImpl() { 518 BlinkPlatformImpl::~BlinkPlatformImpl() {
493 } 519 }
494 520
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme()); 576 return net::IsPortAllowedForScheme(gurl.EffectiveIntPort(), gurl.scheme());
551 } 577 }
552 578
553 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { 579 blink::WebThread* BlinkPlatformImpl::createThread(const char* name) {
554 return createThreadWithOptions(name, base::Thread::Options()).release(); 580 return createThreadWithOptions(name, base::Thread::Options()).release();
555 } 581 }
556 582
557 scoped_ptr<scheduler::WebThreadBase> BlinkPlatformImpl::createThreadWithOptions( 583 scoped_ptr<scheduler::WebThreadBase> BlinkPlatformImpl::createThreadWithOptions(
558 const char* name, 584 const char* name,
559 base::Thread::Options options) { 585 base::Thread::Options options) {
560 scoped_ptr<scheduler::WebThreadBase> thread( 586 WebThreadImplForWorkerScheduler* thread =
561 new scheduler::WebThreadImplForWorkerScheduler(name, options)); 587 new WebThreadImplForWorkerScheduler(name, options);
562 base::WaitableEvent event(false, false); 588 thread->Init();
563 thread->TaskRunner()->PostTask( 589 WaitUntilWebThreadTLSUpdate(thread);
564 FROM_HERE, 590 return make_scoped_ptr(thread);
565 base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, base::Unretained(this), 591 }
566 base::Unretained(thread.get()), base::Unretained(&event))); 592
567 event.Wait(); 593 scoped_ptr<scheduler::WebThreadBase>
568 return thread; 594 BlinkPlatformImpl::createCompositorThread() {
595 base::Thread::Options options;
596 #if defined(OS_ANDROID)
597 options.priority = base::ThreadPriority::DISPLAY;
598 #endif
599 compositor_thread_ = new WebThreadForCompositor(options);
600 WaitUntilWebThreadTLSUpdate(compositor_thread_);
601 return make_scoped_ptr(compositor_thread_);
569 } 602 }
570 603
571 blink::WebThread* BlinkPlatformImpl::currentThread() { 604 blink::WebThread* BlinkPlatformImpl::currentThread() {
572 return static_cast<blink::WebThread*>(current_thread_slot_.Get()); 605 return static_cast<blink::WebThread*>(current_thread_slot_.Get());
573 } 606 }
574 607
575 void BlinkPlatformImpl::yieldCurrentThread() { 608 void BlinkPlatformImpl::yieldCurrentThread() {
576 base::PlatformThread::YieldCurrentThread(); 609 base::PlatformThread::YieldCurrentThread();
577 } 610 }
578 611
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( 1334 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
1302 static_cast<ui::DomKey>(dom_key))); 1335 static_cast<ui::DomKey>(dom_key)));
1303 } 1336 }
1304 1337
1305 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { 1338 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) {
1306 return static_cast<int>( 1339 return static_cast<int>(
1307 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); 1340 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8()));
1308 } 1341 }
1309 1342
1310 } // namespace content 1343 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698