Index: content/child/webthread_impl.cc |
diff --git a/content/child/webthread_impl.cc b/content/child/webthread_impl.cc |
index 2e30a648b80f8a4e5ea38aad65c61c36ea026500..373da1c2675aa1ac75340dea4d62af3913472132 100644 |
--- a/content/child/webthread_impl.cc |
+++ b/content/child/webthread_impl.cc |
@@ -66,11 +66,6 @@ void WebThreadBase::RemoveTaskObserverInternal( |
base::MessageLoop::current()->RemoveTaskObserver(observer); |
} |
-WebThreadImpl::WebThreadImpl(const char* name) |
- : thread_(new base::Thread(name)) { |
- thread_->Start(); |
-} |
- |
// RunWebThreadTask takes the ownership of |task| from base::Closure and |
// deletes it on the first invocation of the closure for thread-safety. |
// base::Closure made from RunWebThreadTask is copyable but Closure::Run |
@@ -100,114 +95,79 @@ void WebThreadBase::RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task) { |
task->run(); |
} |
-void WebThreadImpl::postTask(Task* task) { |
- postDelayedTask(task, 0); |
-} |
- |
-void WebThreadImpl::postTask(const blink::WebTraceLocation& location, |
+void WebThreadBase::postTask(const blink::WebTraceLocation& location, |
Task* task) { |
postDelayedTask(location, task, 0); |
} |
-void WebThreadImpl::postDelayedTask(Task* task, long long delay_ms) { |
- thread_->message_loop()->PostDelayedTask( |
- FROM_HERE, |
- base::Bind(RunWebThreadTask, base::Passed(make_scoped_ptr(task))), |
- base::TimeDelta::FromMilliseconds(delay_ms)); |
-} |
- |
-void WebThreadImpl::postDelayedTask(const blink::WebTraceLocation& web_location, |
+void WebThreadBase::postDelayedTask(const blink::WebTraceLocation& web_location, |
Task* task, |
long long delay_ms) { |
tracked_objects::Location location(web_location.functionName(), |
web_location.fileName(), -1, nullptr); |
- thread_->message_loop()->PostDelayedTask( |
+ TaskRunner()->PostDelayedTask( |
location, |
base::Bind(RunWebThreadTask, base::Passed(make_scoped_ptr(task))), |
base::TimeDelta::FromMilliseconds(delay_ms)); |
} |
-void WebThreadImpl::enterRunLoop() { |
+void WebThreadBase::enterRunLoop() { |
CHECK(isCurrentThread()); |
- CHECK(!thread_->message_loop()->is_running()); // We don't support nesting. |
- thread_->message_loop()->Run(); |
+ CHECK(!MessageLoop()->is_running()); // We don't support nesting. |
+ MessageLoop()->Run(); |
} |
-void WebThreadImpl::exitRunLoop() { |
+void WebThreadBase::exitRunLoop() { |
CHECK(isCurrentThread()); |
- CHECK(thread_->message_loop()->is_running()); |
- thread_->message_loop()->Quit(); |
+ CHECK(MessageLoop()->is_running()); |
+ MessageLoop()->Quit(); |
} |
-bool WebThreadImpl::isCurrentThread() const { |
- return thread_->thread_id() == base::PlatformThread::CurrentId(); |
+bool WebThreadBase::isCurrentThread() const { |
+ return TaskRunner()->BelongsToCurrentThread(); |
} |
blink::PlatformThreadId WebThreadImpl::threadId() const { |
return thread_->thread_id(); |
} |
-WebThreadImpl::~WebThreadImpl() { |
- thread_->Stop(); |
-} |
- |
-WebThreadImplForMessageLoop::WebThreadImplForMessageLoop( |
- scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner) |
- : owning_thread_task_runner_(owning_thread_task_runner), |
- thread_id_(base::PlatformThread::CurrentId()) { |
+WebThreadImpl::WebThreadImpl(const char* name) |
+ : thread_(new base::Thread(name)) { |
+ thread_->Start(); |
} |
-void WebThreadImplForMessageLoop::postTask(Task* task) { |
- postDelayedTask(task, 0); |
+WebThreadImpl::~WebThreadImpl() { |
+ thread_->Stop(); |
} |
-void WebThreadImplForMessageLoop::postTask( |
- const blink::WebTraceLocation& location, |
- Task* task) { |
- postDelayedTask(location, task, 0); |
+base::MessageLoop* WebThreadImpl::MessageLoop() const { |
+ return thread_->message_loop(); |
} |
-void WebThreadImplForMessageLoop::postDelayedTask(Task* task, |
- long long delay_ms) { |
- owning_thread_task_runner_->PostDelayedTask( |
- FROM_HERE, |
- base::Bind(RunWebThreadTask, base::Passed(make_scoped_ptr(task))), |
- base::TimeDelta::FromMilliseconds(delay_ms)); |
+base::SingleThreadTaskRunner* WebThreadImpl::TaskRunner() const { |
+ return thread_->message_loop_proxy().get(); |
} |
-void WebThreadImplForMessageLoop::postDelayedTask( |
- const blink::WebTraceLocation& web_location, |
- Task* task, |
- long long delay_ms) { |
- tracked_objects::Location location(web_location.functionName(), |
- web_location.fileName(), -1, nullptr); |
- owning_thread_task_runner_->PostDelayedTask( |
- location, |
- base::Bind(RunWebThreadTask, base::Passed(make_scoped_ptr(task))), |
- base::TimeDelta::FromMilliseconds(delay_ms)); |
+WebThreadImplForMessageLoop::WebThreadImplForMessageLoop( |
+ scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner) |
+ : owning_thread_task_runner_(owning_thread_task_runner), |
+ thread_id_(base::PlatformThread::CurrentId()) { |
} |
-void WebThreadImplForMessageLoop::enterRunLoop() { |
- CHECK(isCurrentThread()); |
- // We don't support nesting. |
- CHECK(!base::MessageLoop::current()->is_running()); |
- base::MessageLoop::current()->Run(); |
+blink::PlatformThreadId WebThreadImplForMessageLoop::threadId() const { |
+ return thread_id_; |
} |
-void WebThreadImplForMessageLoop::exitRunLoop() { |
- CHECK(isCurrentThread()); |
- CHECK(base::MessageLoop::current()->is_running()); |
- base::MessageLoop::current()->Quit(); |
+WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() { |
} |
-bool WebThreadImplForMessageLoop::isCurrentThread() const { |
- return owning_thread_task_runner_->BelongsToCurrentThread(); |
+base::MessageLoop* WebThreadImplForMessageLoop::MessageLoop() const { |
+ DCHECK(isCurrentThread()); |
+ return base::MessageLoop::current(); |
} |
-blink::PlatformThreadId WebThreadImplForMessageLoop::threadId() const { |
- return thread_id_; |
+base::SingleThreadTaskRunner* WebThreadImplForMessageLoop::TaskRunner() const { |
+ return owning_thread_task_runner_.get(); |
} |
-WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {} |
- |
} // namespace content |