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

Side by Side Diff: content/renderer/scheduler/renderer_scheduler_selector.h

Issue 664963002: content: Add RendererScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_
7
8 #include "base/task/task_queue_selector.h"
9 #include "base/threading/thread_checker.h"
10
11 namespace content {
12
13 class RendererSchedulerSelector : public base::TaskQueueSelector {
14 public:
15 enum QueuePriority {
16 kControlPriority,
17 kHighPriority,
18 kNormalPriority,
19 kBestEffortPriority,
20 // Must be the last entry.
21 kQueuePriorityCount,
22 };
23
24 RendererSchedulerSelector();
25 virtual ~RendererSchedulerSelector();
26
27 // Set the priority of |queue_id| to |set_priority|.
28 void SetQueuePriority(size_t queue_id, QueuePriority set_priority);
29
30 // Enable the |queue_id| with a priority of |priority|.
31 void EnableQueue(size_t queue_id, QueuePriority priority);
32
33 // Disable the |queue_id|.
34 void DisableQueue(size_t queue_id);
35
36 // TaskQueueSelector implementation:
37 virtual void RegisterWorkQueues(
38 const std::vector<const base::TaskQueue*>& work_queues) override;
39 virtual bool SelectWorkQueueToService(size_t* out_queue_index) override;
40
41 private:
42 // Return true if |out_queue_index| indicates the index of the queue with
43 // the oldest pending task from the set of queues of |priority|, or
44 // false if all queues of that priority are empty.
45 bool ChooseOldestWithPriority(
46 QueuePriority priority, size_t* out_queue_index);
47
48 // Returns true if |out_queue_index| indicates the index of the control queue,
49 // or false if there is no control queue.
50 bool ControlQueueId(size_t* out_queue_index);
51
52 // Returns true if |queue_id| is enabled with the given |priority|.
53 bool QueueEnabledWithPriority(size_t queue_id, QueuePriority priority);
54
55 QueuePriority NextPriorty(QueuePriority priority);
56
57 base::ThreadChecker main_thread_checker_;
58 std::vector<const base::TaskQueue*> work_queues_;
59 size_t queue_priorities_[kQueuePriorityCount];
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698