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

Unified Diff: components/scheduler/child/scheduler_task_runner_delegate_impl.cc

Issue 987193002: Redirect the MessageLoop's task runner to the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 5 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: components/scheduler/child/scheduler_task_runner_delegate_impl.cc
diff --git a/components/scheduler/child/scheduler_task_runner_delegate_impl.cc b/components/scheduler/child/scheduler_task_runner_delegate_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..57df355e0bad1485bcf9f512162a6f190bf22f1a
--- /dev/null
+++ b/components/scheduler/child/scheduler_task_runner_delegate_impl.cc
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/scheduler/child/scheduler_task_runner_delegate_impl.h"
+
+namespace scheduler {
+
+// static
+scoped_refptr<SchedulerTaskRunnerDelegateImpl>
+SchedulerTaskRunnerDelegateImpl::Create(base::MessageLoop* message_loop) {
+ return make_scoped_refptr(new SchedulerTaskRunnerDelegateImpl(message_loop));
+}
+
+SchedulerTaskRunnerDelegateImpl::SchedulerTaskRunnerDelegateImpl(
+ base::MessageLoop* message_loop)
+ : message_loop_(message_loop),
+ message_loop_task_runner_(message_loop->task_runner()) {}
+
+SchedulerTaskRunnerDelegateImpl::~SchedulerTaskRunnerDelegateImpl() {
+ RestoreDefaultTaskRunner();
+}
+
+void SchedulerTaskRunnerDelegateImpl::SetDefaultTaskRunner(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ message_loop_->SetTaskRunner(task_runner);
+}
+
+void SchedulerTaskRunnerDelegateImpl::RestoreDefaultTaskRunner() {
+ if (base::MessageLoop::current() == message_loop_)
+ message_loop_->SetTaskRunner(message_loop_task_runner_);
+}
+
+bool SchedulerTaskRunnerDelegateImpl::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ return message_loop_task_runner_->PostDelayedTask(from_here, task, delay);
+}
+
+bool SchedulerTaskRunnerDelegateImpl::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) {
+ return message_loop_task_runner_->PostNonNestableDelayedTask(from_here, task,
+ delay);
+}
+
+bool SchedulerTaskRunnerDelegateImpl::RunsTasksOnCurrentThread() const {
+ return message_loop_task_runner_->RunsTasksOnCurrentThread();
+}
+
+bool SchedulerTaskRunnerDelegateImpl::IsNested() const {
+ return message_loop_->IsNested();
+}
+
+void SchedulerTaskRunnerDelegateImpl::AddTaskObserver(
+ base::MessageLoop::TaskObserver* task_observer) {
+ message_loop_->AddTaskObserver(task_observer);
+}
+
+void SchedulerTaskRunnerDelegateImpl::RemoveTaskObserver(
+ base::MessageLoop::TaskObserver* task_observer) {
+ message_loop_->RemoveTaskObserver(task_observer);
+}
+
+} // namespace scheduler

Powered by Google App Engine
This is Rietveld 408576698