Chromium Code Reviews| Index: content/renderer/scheduler/renderer_scheduler_selector.h |
| diff --git a/content/renderer/scheduler/renderer_scheduler_selector.h b/content/renderer/scheduler/renderer_scheduler_selector.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4cd59a0a3b971d4ecacce82324c62656da7e4657 |
| --- /dev/null |
| +++ b/content/renderer/scheduler/renderer_scheduler_selector.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2014 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. |
| + |
| +#ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_ |
| +#define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_ |
| + |
| +#include "base/task/task_queue_selector.h" |
| +#include "base/threading/thread_checker.h" |
| + |
| +namespace content { |
| + |
| +class RendererSchedulerSelector : public base::TaskQueueSelector { |
| + public: |
| + enum QueuePriority { |
| + kControlPriority, |
| + kHighPriority, |
| + kNormalPriority, |
| + kBestEffortPriority, |
| + // Must be the last entry. |
| + kQueuePriorityCount, |
| + }; |
| + |
| + RendererSchedulerSelector(); |
| + virtual ~RendererSchedulerSelector(); |
| + |
| + // Set the priority of |queue_id| to |set_priority|. |
| + void SetQueuePriority(size_t queue_id, QueuePriority set_priority); |
| + |
| + // Enable the |queue_id| with a priority of |priority|. |
|
Sami
2014/10/20 13:31:09
Are all queues enabled or disabled by default? Pro
petrcermak
2014/10/20 17:43:36
This is explained on renderer_scheduler_selector.c
rmcilroy
2014/10/21 17:21:28
Done.
|
| + void EnableQueue(size_t queue_id, QueuePriority priority); |
| + |
| + // Disable the |queue_id|. |
| + void DisableQueue(size_t queue_id); |
| + |
| + // TaskQueueSelector implementation: |
| + virtual void RegisterWorkQueues( |
| + const std::vector<const base::TaskQueue*>& work_queues) override; |
| + virtual bool SelectWorkQueueToService(size_t* out_queue_index) override; |
|
petrcermak
2014/10/20 17:43:36
Why is the queue index called "queue_id" when it's
rmcilroy
2014/10/21 17:21:28
Good catch. Changed all to queue_index
|
| + |
| + private: |
| + // Return true if |out_queue_index| indicates the index of the queue with |
| + // the oldest pending task from the set of queues of |priority|, or |
| + // false if all queues of that priority are empty. |
| + bool ChooseOldestWithPriority( |
| + QueuePriority priority, size_t* out_queue_index); |
| + |
| + // Returns true if |out_queue_index| indicates the index of the control queue, |
| + // or false if there is no control queue. |
| + bool ControlQueueId(size_t* out_queue_index); |
|
Sami
2014/10/20 13:31:09
Unused?
rmcilroy
2014/10/21 17:21:28
Removed, thanks.
|
| + |
| + // Returns true if |queue_id| is enabled with the given |priority|. |
| + bool QueueEnabledWithPriority(size_t queue_id, QueuePriority priority); |
|
Sami
2014/10/20 13:31:09
nit: const
rmcilroy
2014/10/21 17:21:28
Done.
|
| + |
| + QueuePriority NextPriorty(QueuePriority priority); |
|
Sami
2014/10/20 13:31:09
typo: Priority
|
| + |
| + base::ThreadChecker main_thread_checker_; |
| + std::vector<const base::TaskQueue*> work_queues_; |
| + size_t queue_priorities_[kQueuePriorityCount]; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_ |