Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Unified Diff: content/child/webthread_impl.cc

Issue 1033643004: Add a WorkerScheduler and a WebThreadImplForWorker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make WebThreadImplForWorkerSchedulerTest::TestTaskObserver less verbose Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698