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

Unified 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 side-by-side diff with in-line comments
Download patch
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() {

Powered by Google App Engine
This is Rietveld 408576698