Chromium Code Reviews| Index: content/child/blink_platform_impl.cc |
| diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc |
| index 0b8777cdc495c4766262d7604c9983b54c16640e..08f71634fa841f977d4f5ebfbb2c1db23c3932e6 100644 |
| --- a/content/child/blink_platform_impl.cc |
| +++ b/content/child/blink_platform_impl.cc |
| @@ -13,7 +13,6 @@ |
| #include "base/files/file_path.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/singleton.h" |
| -#include "base/message_loop/message_loop.h" |
| #include "base/metrics/histogram.h" |
| #include "base/metrics/sparse_histogram.h" |
| #include "base/process/process_metrics.h" |
| @@ -418,7 +417,7 @@ BlinkPlatformImpl::BlinkPlatformImpl() |
| shared_timer_fire_time_(0.0), |
| shared_timer_fire_time_was_set_while_suspended_(false), |
| shared_timer_suspended_(0), |
| - current_thread_slot_(&DestroyCurrentThread) { |
| + current_thread_slot_() { |
| InternalInit(); |
| } |
| @@ -429,7 +428,7 @@ BlinkPlatformImpl::BlinkPlatformImpl( |
| shared_timer_fire_time_(0.0), |
| shared_timer_fire_time_was_set_while_suspended_(false), |
| shared_timer_suspended_(0), |
| - current_thread_slot_(&DestroyCurrentThread) { |
| + current_thread_slot_() { |
| // TODO(alexclarke): Use c++11 delegated constructors when allowed. |
| InternalInit(); |
| } |
| @@ -452,6 +451,11 @@ void BlinkPlatformImpl::InternalInit() { |
| } |
| } |
| +void BlinkPlatformImpl::UpdateWebThreadTLS(blink::WebThread* thread) { |
| + DCHECK(!current_thread_slot_.Get()); |
| + current_thread_slot_.Set(thread); |
| +} |
| + |
| BlinkPlatformImpl::~BlinkPlatformImpl() { |
| } |
| @@ -499,23 +503,15 @@ bool BlinkPlatformImpl::isReservedIPAddress( |
| } |
| blink::WebThread* BlinkPlatformImpl::createThread(const char* name) { |
| - return new WebThreadImpl(name); |
| + WebThreadImpl* thread = new WebThreadImpl(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::SingleThreadTaskRunner> task_runner = |
| - MainTaskRunnerForCurrentThread(); |
| - if (!task_runner.get()) |
| - return NULL; |
| - |
| - thread = new WebThreadImplForMessageLoop(task_runner); |
| - current_thread_slot_.Set(thread); |
| - return thread; |
| + return static_cast<blink::WebThread*>(current_thread_slot_.Get()); |
|
kinuko
2015/02/27 09:54:27
Hmm. By looking into the callsites in production c
sadrul
2015/03/01 10:21:38
it looks like it's used in some places to add task
kinuko
2015/03/02 06:08:17
They belong to main thread afaik. (I'm ok to keep
sadrul
2015/03/02 07:43:14
If this is only called on the main thread, then in
kinuko
2015/03/03 00:14:14
This is not really true, it's also called on the w
|
| } |
| void BlinkPlatformImpl::yieldCurrentThread() { |
| @@ -1258,13 +1254,6 @@ BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { |
| } |
| } |
| -// static |
| -void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
| - WebThreadImplForMessageLoop* impl = |
| - static_cast<WebThreadImplForMessageLoop*>(thread); |
| - delete impl; |
| -} |
| - |
| WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { |
| return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
| static_cast<ui::DomCode>(dom_code))); |