Chromium Code Reviews| Index: components/html_viewer/blink_platform_impl.cc |
| diff --git a/components/html_viewer/blink_platform_impl.cc b/components/html_viewer/blink_platform_impl.cc |
| index 4f71823663be9dcc6185f4a785c38b9442af4c2a..666de5ed5b4ec88d623e12a10c9fe2c6406ffd5b 100644 |
| --- a/components/html_viewer/blink_platform_impl.cc |
| +++ b/components/html_viewer/blink_platform_impl.cc |
| @@ -17,8 +17,10 @@ |
| #include "components/html_viewer/web_cookie_jar_impl.h" |
| #include "components/html_viewer/web_message_port_channel_impl.h" |
| #include "components/html_viewer/web_socket_handle_impl.h" |
| -#include "components/html_viewer/web_thread_impl.h" |
| #include "components/html_viewer/web_url_loader_impl.h" |
| +#include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
| +#include "components/scheduler/renderer/renderer_scheduler.h" |
| +#include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" |
| #include "net/base/data_url.h" |
| #include "net/base/mime_util.h" |
| #include "net/base/net_errors.h" |
| @@ -58,14 +60,16 @@ class WebWaitableEventImpl : public blink::WebWaitableEvent { |
| } // namespace |
| -BlinkPlatformImpl::BlinkPlatformImpl(mojo::ApplicationImpl* app) |
| - : main_loop_(base::MessageLoop::current()), |
| +BlinkPlatformImpl::BlinkPlatformImpl( |
| + mojo::ApplicationImpl* app, |
| + scheduler::RendererScheduler* renderer_scheduler) |
| + : main_thread_task_runner_(renderer_scheduler->DefaultTaskRunner()), |
| + main_thread_( |
| + new scheduler::WebThreadImplForRendererScheduler(renderer_scheduler)), |
| shared_timer_func_(NULL), |
| shared_timer_fire_time_(0.0), |
| shared_timer_fire_time_was_set_while_suspended_(false), |
| - shared_timer_suspended_(0), |
| - current_thread_slot_(&DestroyCurrentThread), |
| - scheduler_(main_loop_->message_loop_proxy()) { |
| + shared_timer_suspended_(0) { |
| if (app) { |
| app->ConnectToService("mojo:network_service", &network_service_); |
| @@ -79,6 +83,8 @@ BlinkPlatformImpl::BlinkPlatformImpl(mojo::ApplicationImpl* app) |
| mojo::ConnectToService(service_provider.get(), &clipboard); |
| clipboard_.reset(new WebClipboardImpl(clipboard.Pass())); |
| } |
| + if (main_thread_task_runner_.get()) |
|
Sami
2015/04/28 15:20:21
This should never be null.
|
| + shared_timer_.SetTaskRunner(main_thread_task_runner_); |
| } |
| BlinkPlatformImpl::~BlinkPlatformImpl() { |
| @@ -100,10 +106,6 @@ blink::WebThemeEngine* BlinkPlatformImpl::themeEngine() { |
| return &theme_engine_; |
| } |
| -blink::WebScheduler* BlinkPlatformImpl::scheduler() { |
| - return &scheduler_; |
| -} |
| - |
| blink::WebString BlinkPlatformImpl::defaultLocale() { |
| return blink::WebString::fromUTF8("en-US"); |
| } |
| @@ -166,7 +168,7 @@ void BlinkPlatformImpl::stopSharedTimer() { |
| void BlinkPlatformImpl::callOnMainThread( |
| void (*func)(void*), void* context) { |
| - main_loop_->PostTask(FROM_HERE, base::Bind(func, context)); |
| + main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(func, context)); |
| } |
| bool BlinkPlatformImpl::isThreadedCompositingEnabled() { |
| @@ -258,23 +260,18 @@ bool BlinkPlatformImpl::isReservedIPAddress( |
| } |
| blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { |
| - return new WebThreadImpl(name); |
| + scheduler::WebThreadImplForWorkerScheduler* thread = |
| + new scheduler::WebThreadImplForWorkerScheduler(name); |
| + thread->TaskRunner()->PostTask( |
| + FROM_HERE, base::Bind(&BlinkPlatformImpl::UpdateWebThreadTLS, |
| + base::Unretained(this), thread)); |
| + return thread; |
| } |
| blink::WebThread* BlinkPlatformImpl::currentThread() { |
| - WebThreadImplForMessageLoop* thread = |
| - static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get()); |
| - if (thread) |
| - return (thread); |
| - |
| - scoped_refptr<base::MessageLoopProxy> message_loop = |
| - base::MessageLoopProxy::current(); |
| - if (!message_loop.get()) |
| - return NULL; |
| - |
| - thread = new WebThreadImplForMessageLoop(message_loop.get()); |
| - current_thread_slot_.Set(thread); |
| - return thread; |
| + if (main_thread_->isCurrentThread()) |
| + return main_thread_.get(); |
| + return static_cast<blink::WebThread*>(current_thread_slot_.Get()); |
| } |
| void BlinkPlatformImpl::yieldCurrentThread() { |
| @@ -316,11 +313,9 @@ BlinkPlatformImpl::notificationManager() { |
| return &web_notification_manager_; |
| } |
| -// static |
| -void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
| - WebThreadImplForMessageLoop* impl = |
| - static_cast<WebThreadImplForMessageLoop*>(thread); |
| - delete impl; |
| +void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { |
| + DCHECK(!current_thread_slot_.Get()); |
| + current_thread_slot_.Set(thread); |
| } |
| } // namespace html_viewer |