Index: content/child/webthread_impl.cc |
diff --git a/content/child/webthread_impl.cc b/content/child/webthread_impl.cc |
index 572e5890bb53409078ac70da898081855c491450..7938e8c21884b3f2b39f14a0abd81b1beff69c72 100644 |
--- a/content/child/webthread_impl.cc |
+++ b/content/child/webthread_impl.cc |
@@ -11,6 +11,7 @@ |
#include "base/bind_helpers.h" |
#include "base/pending_task.h" |
#include "base/threading/platform_thread.h" |
+#include "content/child/scheduler/single_thread_idle_task_runner.h" |
#include "third_party/WebKit/public/platform/WebTraceLocation.h" |
namespace content { |
@@ -100,6 +101,13 @@ void WebThreadBase::RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task) { |
task->run(); |
} |
+// static |
+void WebThreadBase::RunWebThreadIdleTask( |
+ scoped_ptr<blink::WebThread::IdleTask> idle_task, |
+ base::TimeTicks deadline) { |
+ idle_task->run((deadline - base::TimeTicks()).InSecondsF()); |
+} |
+ |
void WebThreadBase::postTask(const blink::WebTraceLocation& location, |
Task* task) { |
postDelayedTask(location, task, 0); |
@@ -116,6 +124,25 @@ void WebThreadBase::postDelayedTask(const blink::WebTraceLocation& web_location, |
base::TimeDelta::FromMilliseconds(delay_ms)); |
} |
+void WebThreadBase::postIdleTask(const blink::WebTraceLocation& web_location, |
+ IdleTask* idle_task) { |
+ tracked_objects::Location location(web_location.functionName(), |
+ web_location.fileName(), -1, nullptr); |
+ IdleTaskRunner()->PostIdleTask( |
+ location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, |
+ base::Passed(make_scoped_ptr(idle_task)))); |
+} |
+ |
+void WebThreadBase::postIdleTaskAfterWakeup( |
+ const blink::WebTraceLocation& web_location, |
+ IdleTask* idle_task) { |
+ tracked_objects::Location location(web_location.functionName(), |
+ web_location.fileName(), -1, nullptr); |
+ IdleTaskRunner()->PostIdleTaskAfterWakeup( |
+ location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, |
+ base::Passed(make_scoped_ptr(idle_task)))); |
+} |
+ |
void WebThreadBase::enterRunLoop() { |
CHECK(isCurrentThread()); |
CHECK(MessageLoop()); |
@@ -134,25 +161,4 @@ bool WebThreadBase::isCurrentThread() const { |
return TaskRunner()->BelongsToCurrentThread(); |
} |
-blink::PlatformThreadId WebThreadImpl::threadId() const { |
- return thread_->thread_id(); |
-} |
- |
-WebThreadImpl::WebThreadImpl(const char* name) |
- : thread_(new base::Thread(name)) { |
- thread_->Start(); |
-} |
- |
-WebThreadImpl::~WebThreadImpl() { |
- thread_->Stop(); |
-} |
- |
-base::MessageLoop* WebThreadImpl::MessageLoop() const { |
- return nullptr; |
-} |
- |
-base::SingleThreadTaskRunner* WebThreadImpl::TaskRunner() const { |
- return thread_->message_loop_proxy().get(); |
-} |
- |
} // namespace content |