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

Unified Diff: third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc

Issue 2806623004: Worker: Introduce per-global-scope task scheduler (Closed)
Patch Set: remove WorkerTaskRunners Created 3 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: third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc b/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
index dbfc73ef79be4c1ca44deb429f80fb8e79036f1d..8b147d35872d356d8cb4eebea381577b9e6dfed4 100644
--- a/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
+++ b/third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
@@ -9,125 +9,21 @@
#include "base/callback.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h"
+#include "platform/scheduler/child/scheduler_helper.h"
+#include "platform/scheduler/child/scheduler_tqm_delegate.h"
namespace blink {
namespace scheduler {
-// TODO(scheduler-dev): Get rid of this asap!
-namespace {
-class CompositorWorkerTaskRunnerWrapper : public TaskQueue {
- public:
- explicit CompositorWorkerTaskRunnerWrapper(
- scoped_refptr<base::SingleThreadTaskRunner> task_runner)
- : task_runner_(task_runner) {}
-
- // TaskQueue implementation:
- void UnregisterTaskQueue() override { NOTREACHED(); }
-
- bool RunsTasksOnCurrentThread() const override {
- return task_runner_->RunsTasksOnCurrentThread();
- }
-
- bool PostDelayedTask(const tracked_objects::Location& from_here,
- base::OnceClosure task,
- base::TimeDelta delay) override {
- return task_runner_->PostDelayedTask(from_here, std::move(task), delay);
- }
-
- bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- base::OnceClosure task,
- base::TimeDelta delay) override {
- return task_runner_->PostNonNestableDelayedTask(from_here, std::move(task),
- delay);
- }
-
- std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() override {
- NOTREACHED();
- return nullptr;
- }
-
- void InsertFence(InsertFencePosition position) override { NOTREACHED(); }
-
- void RemoveFence() override { NOTREACHED(); }
-
- bool BlockedByFence() const override {
- NOTREACHED();
- return false;
- }
-
- bool IsQueueEnabled() const override {
- NOTREACHED();
- return true;
- }
-
- bool IsEmpty() const override {
- NOTREACHED();
- return false;
- };
-
- size_t GetNumberOfPendingTasks() const override {
- NOTREACHED();
- return 0;
- };
-
- bool HasPendingImmediateWork() const override {
- NOTREACHED();
- return false;
- };
-
- base::Optional<base::TimeTicks> GetNextScheduledWakeUp() override {
- NOTREACHED();
- return base::nullopt;
- }
-
- const char* GetName() const override {
- NOTREACHED();
- return nullptr;
- };
-
- QueueType GetQueueType() const override {
- NOTREACHED();
- return QueueType::DEFAULT;
- }
-
- void SetQueuePriority(QueuePriority priority) override { NOTREACHED(); }
-
- QueuePriority GetQueuePriority() const override {
- NOTREACHED();
- return QueuePriority::NORMAL_PRIORITY;
- };
-
- void AddTaskObserver(
- base::MessageLoop::TaskObserver* task_observer) override {
- NOTREACHED();
- }
-
- void RemoveTaskObserver(
- base::MessageLoop::TaskObserver* task_observer) override {
- NOTREACHED();
- }
-
- void SetTimeDomain(TimeDomain* domain) override { NOTREACHED(); }
-
- TimeDomain* GetTimeDomain() const override {
- return nullptr;
- }
-
- void SetBlameContext(base::trace_event::BlameContext*) override {
- NOTREACHED();
- }
-
- void SetObserver(Observer* observer) override { NOTREACHED(); }
-
- private:
- ~CompositorWorkerTaskRunnerWrapper() override {}
-
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
-};
-} // namespace
-
-CompositorWorkerScheduler::CompositorWorkerScheduler(base::Thread* thread)
- : thread_(thread) {}
+CompositorWorkerScheduler::CompositorWorkerScheduler(
+ base::Thread* thread,
+ scoped_refptr<SchedulerTqmDelegate> main_task_runner)
+ : thread_(thread),
+ helper_(new SchedulerHelper(
+ main_task_runner,
+ "compositor.scheduler",
+ TRACE_DISABLED_BY_DEFAULT("compositor.scheduler"),
+ TRACE_DISABLED_BY_DEFAULT("compositor.scheduler.debug"))) {}
CompositorWorkerScheduler::~CompositorWorkerScheduler() {}
@@ -136,8 +32,7 @@ void CompositorWorkerScheduler::Init() {}
scoped_refptr<TaskQueue> CompositorWorkerScheduler::DefaultTaskRunner() {
// TODO(sad): Implement a more robust scheduler that can do idle tasks for GC
// without regressing performance of the rest of the system.
- return make_scoped_refptr(
- new CompositorWorkerTaskRunnerWrapper(thread_->task_runner()));
+ return helper_->DefaultTaskRunner();
}
scoped_refptr<scheduler::SingleThreadIdleTaskRunner>
@@ -160,16 +55,26 @@ bool CompositorWorkerScheduler::ShouldYieldForHighPriorityWork() {
void CompositorWorkerScheduler::AddTaskObserver(
base::MessageLoop::TaskObserver* task_observer) {
- thread_->message_loop()->AddTaskObserver(task_observer);
+ helper_->AddTaskObserver(task_observer);
}
void CompositorWorkerScheduler::RemoveTaskObserver(
base::MessageLoop::TaskObserver* task_observer) {
- thread_->message_loop()->RemoveTaskObserver(task_observer);
+ helper_->RemoveTaskObserver(task_observer);
}
void CompositorWorkerScheduler::Shutdown() {}
+scoped_refptr<TaskQueue> CompositorWorkerScheduler::NewUnthrottledTaskRunner(
+ TaskQueue::QueueType queue_type) {
+ helper_->CheckOnValidThread();
+ scoped_refptr<TaskQueue> unthrottled_task_queue(
+ helper_->NewTaskQueue(TaskQueue::Spec(queue_type)
+ .SetShouldMonitorQuiescence(true)
+ .SetTimeDomain(nullptr)));
+ return unthrottled_task_queue;
+}
+
void CompositorWorkerScheduler::OnIdleTaskPosted() {}
base::TimeTicks CompositorWorkerScheduler::WillProcessIdleTask() {

Powered by Google App Engine
This is Rietveld 408576698