diff options
-rw-r--r-- | components/scheduler/ppapi/DEPS | 5 | ||||
-rw-r--r-- | components/scheduler/ppapi/webthread_impl_for_ppapi.cc | 65 | ||||
-rw-r--r-- | components/scheduler/ppapi/webthread_impl_for_ppapi.h | 57 | ||||
-rw-r--r-- | components/scheduler/scheduler.gypi | 2 | ||||
-rw-r--r-- | content/ppapi_plugin/DEPS | 1 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_blink_platform_impl.cc | 10 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_blink_platform_impl.h | 6 |
7 files changed, 145 insertions, 1 deletions
diff --git a/components/scheduler/ppapi/DEPS b/components/scheduler/ppapi/DEPS new file mode 100644 index 0000000..2e466b0 --- /dev/null +++ b/components/scheduler/ppapi/DEPS @@ -0,0 +1,5 @@ +include_rules = [ + "+components/scheduler/child", + "+components/scheduler/scheduler_export.h", + "+third_party/WebKit/public/platform", +] diff --git a/components/scheduler/ppapi/webthread_impl_for_ppapi.cc b/components/scheduler/ppapi/webthread_impl_for_ppapi.cc new file mode 100644 index 0000000..eed3291 --- /dev/null +++ b/components/scheduler/ppapi/webthread_impl_for_ppapi.cc @@ -0,0 +1,65 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/scheduler/ppapi/webthread_impl_for_ppapi.h" + +#include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "components/scheduler/child/scheduler_task_runner_delegate_impl.h" +#include "components/scheduler/child/task_queue.h" +#include "components/scheduler/child/web_scheduler_impl.h" +#include "components/scheduler/child/web_task_runner_impl.h" +#include "components/scheduler/child/worker_scheduler_impl.h" + +namespace scheduler { + +WebThreadImplForPPAPI::WebThreadImplForPPAPI() + : thread_id_(base::PlatformThread::CurrentId()), + task_runner_delegate_(SchedulerTaskRunnerDelegateImpl::Create( + base::MessageLoop::current())), + worker_scheduler_(WorkerScheduler::Create(task_runner_delegate_)) { + worker_scheduler_->Init(); + task_runner_ = worker_scheduler_->DefaultTaskRunner(); + idle_task_runner_ = worker_scheduler_->IdleTaskRunner(); + web_scheduler_.reset(new WebSchedulerImpl( + worker_scheduler_.get(), worker_scheduler_->IdleTaskRunner(), + worker_scheduler_->DefaultTaskRunner(), + worker_scheduler_->DefaultTaskRunner())); + web_task_runner_ = make_scoped_ptr(new WebTaskRunnerImpl(task_runner_)); +} + +WebThreadImplForPPAPI::~WebThreadImplForPPAPI() {} + +blink::PlatformThreadId WebThreadImplForPPAPI::threadId() const { + return thread_id_; +} + +blink::WebScheduler* WebThreadImplForPPAPI::scheduler() const { + return web_scheduler_.get(); +} + +base::SingleThreadTaskRunner* WebThreadImplForPPAPI::TaskRunner() const { + return task_runner_.get(); +} + +SingleThreadIdleTaskRunner* WebThreadImplForPPAPI::IdleTaskRunner() const { + return idle_task_runner_.get(); +} + +blink::WebTaskRunner* WebThreadImplForPPAPI::taskRunner() { + return web_task_runner_.get(); +} + +void WebThreadImplForPPAPI::AddTaskObserverInternal( + base::MessageLoop::TaskObserver* observer) { + worker_scheduler_->AddTaskObserver(observer); +} + +void WebThreadImplForPPAPI::RemoveTaskObserverInternal( + base::MessageLoop::TaskObserver* observer) { + worker_scheduler_->RemoveTaskObserver(observer); +} + +} // namespace scheduler diff --git a/components/scheduler/ppapi/webthread_impl_for_ppapi.h b/components/scheduler/ppapi/webthread_impl_for_ppapi.h new file mode 100644 index 0000000..d85c02a --- /dev/null +++ b/components/scheduler/ppapi/webthread_impl_for_ppapi.h @@ -0,0 +1,57 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_SCHEDULER_PPAPI_WEBTHREAD_IMPL_FOR_PPAPI_H_ +#define COMPONENTS_SCHEDULER_PPAPI_WEBTHREAD_IMPL_FOR_PPAPI_H_ + +#include "components/scheduler/child/webthread_base.h" + +namespace base { +class SingleThreadTaskRunner; +} + +namespace blink { +class WebScheduler; +}; + +namespace scheduler { +class SchedulerTaskRunnerDelegate; +class SingleThreadIdleTaskRunner; +class WebSchedulerImpl; +class WebTaskRunnerImpl; +class WorkerScheduler; + +class SCHEDULER_EXPORT WebThreadImplForPPAPI : public WebThreadBase { + public: + explicit WebThreadImplForPPAPI(); + virtual ~WebThreadImplForPPAPI(); + + // blink::WebThread implementation. + virtual blink::WebScheduler* scheduler() const; + blink::PlatformThreadId threadId() const override; + virtual blink::WebTaskRunner* taskRunner(); + + // WebThreadBase implementation. + base::SingleThreadTaskRunner* TaskRunner() const override; + scheduler::SingleThreadIdleTaskRunner* IdleTaskRunner() const override; + + private: + void AddTaskObserverInternal( + base::MessageLoop::TaskObserver* observer) override; + void RemoveTaskObserverInternal( + base::MessageLoop::TaskObserver* observer) override; + + blink::PlatformThreadId thread_id_; + scoped_refptr<SchedulerTaskRunnerDelegate> task_runner_delegate_; + scoped_ptr<scheduler::WorkerScheduler> worker_scheduler_; + scoped_ptr<scheduler::WebSchedulerImpl> web_scheduler_; + scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; + scoped_refptr<scheduler::SingleThreadIdleTaskRunner> idle_task_runner_; + scoped_ptr<WebTaskRunnerImpl> web_task_runner_; +}; + +} // namespace scheduler + +#endif // COMPONENTS_SCHEDULER_PPAPI_WEBTHREAD_IMPL_FOR_PPAPI_H_ diff --git a/components/scheduler/scheduler.gypi b/components/scheduler/scheduler.gypi index 0e65eea..33457ac 100644 --- a/components/scheduler/scheduler.gypi +++ b/components/scheduler/scheduler.gypi @@ -44,6 +44,8 @@ 'child/worker_scheduler.h', 'child/worker_scheduler_impl.cc', 'child/worker_scheduler_impl.h', + 'ppapi/webthread_impl_for_ppapi.cc', + 'ppapi/webthread_impl_for_ppapi.h', 'renderer/deadline_task_runner.cc', 'renderer/deadline_task_runner.h', 'renderer/renderer_scheduler.cc', diff --git a/content/ppapi_plugin/DEPS b/content/ppapi_plugin/DEPS index bde9e92..903662b 100644 --- a/content/ppapi_plugin/DEPS +++ b/content/ppapi_plugin/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+components/scheduler/ppapi", "+content/child", "+content/public/plugin", "+ppapi/c", diff --git a/content/ppapi_plugin/ppapi_blink_platform_impl.cc b/content/ppapi_plugin/ppapi_blink_platform_impl.cc index 5c9de83..cea7886 100644 --- a/content/ppapi_plugin/ppapi_blink_platform_impl.cc +++ b/content/ppapi_plugin/ppapi_blink_platform_impl.cc @@ -10,6 +10,7 @@ #include "base/strings/string16.h" #include "base/threading/platform_thread.h" #include "build/build_config.h" +#include "components/scheduler/ppapi/webthread_impl_for_ppapi.h" #include "content/child/child_thread_impl.h" #include "content/common/child_process_messages.h" #include "ppapi/proxy/plugin_globals.h" @@ -114,7 +115,8 @@ void PpapiBlinkPlatformImpl::SandboxSupport::getRenderStyleForStrike( #endif // !defined(OS_ANDROID) && !defined(OS_WIN) -PpapiBlinkPlatformImpl::PpapiBlinkPlatformImpl() { +PpapiBlinkPlatformImpl::PpapiBlinkPlatformImpl() + : main_thread_(new scheduler::WebThreadImplForPPAPI()) { #if !defined(OS_ANDROID) && !defined(OS_WIN) sandbox_support_.reset(new PpapiBlinkPlatformImpl::SandboxSupport); #endif @@ -132,6 +134,12 @@ void PpapiBlinkPlatformImpl::Shutdown() { #endif } +blink::WebThread* PpapiBlinkPlatformImpl::currentThread() { + if (main_thread_->isCurrentThread()) + return main_thread_.get(); + return BlinkPlatformImpl::currentThread(); +} + blink::WebClipboard* PpapiBlinkPlatformImpl::clipboard() { NOTREACHED(); return NULL; diff --git a/content/ppapi_plugin/ppapi_blink_platform_impl.h b/content/ppapi_plugin/ppapi_blink_platform_impl.h index 3358436..d6553b7 100644 --- a/content/ppapi_plugin/ppapi_blink_platform_impl.h +++ b/content/ppapi_plugin/ppapi_blink_platform_impl.h @@ -9,6 +9,10 @@ #include "base/memory/scoped_ptr.h" #include "content/child/blink_platform_impl.h" +namespace scheduler { +class WebThreadImplForPPAPI; +} + namespace content { class PpapiBlinkPlatformImpl : public BlinkPlatformImpl { @@ -20,6 +24,7 @@ class PpapiBlinkPlatformImpl : public BlinkPlatformImpl { void Shutdown(); // BlinkPlatformImpl methods: + virtual blink::WebThread* currentThread(); virtual blink::WebClipboard* clipboard(); virtual blink::WebMimeRegistry* mimeRegistry(); virtual blink::WebFileUtilities* fileUtilities(); @@ -54,6 +59,7 @@ class PpapiBlinkPlatformImpl : public BlinkPlatformImpl { class SandboxSupport; scoped_ptr<SandboxSupport> sandbox_support_; #endif + scoped_ptr<scheduler::WebThreadImplForPPAPI> main_thread_; DISALLOW_COPY_AND_ASSIGN(PpapiBlinkPlatformImpl); }; |