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

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: Fix bug in calculating remaining_compositor_priority_time Created 6 years, 1 month 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/threading/thread_checker.h"
9 #include "content/renderer/scheduler/task_queue_selector.h"
10
11 namespace content {
12
13 class RendererSchedulerSelector : public TaskQueueSelector {
14 public:
15 enum QueuePriority {
16 kControlPriority,
17 kHighPriority,
18 kNormalPriority,
19 kBestEffortPriority,
20 // Must be the last entry.
21 kQueuePriorityCount,
22 kFirstQueuePriority = kControlPriority,
23 };
24
25 RendererSchedulerSelector();
26 virtual ~RendererSchedulerSelector();
27
28 // Set the priority of |queue_index| to |set_priority|.
29 void SetQueuePriority(size_t queue_index, QueuePriority priority);
30
31 // Enable the |queue_index| with a priority of |priority|. By default all
32 // queues are enabled with normal priority.
33 void EnableQueue(size_t queue_index, QueuePriority priority);
34
35 // Disable the |queue_index|.
36 void DisableQueue(size_t queue_index);
37
38 // TaskQueueSelector implementation:
39 virtual void RegisterWorkQueues(
40 const std::vector<const base::TaskQueue*>& work_queues) override;
41 virtual bool SelectWorkQueueToService(size_t* out_queue_index) override;
42
43 private:
44 // Return true if |out_queue_index| indicates the index of the queue with
45 // the oldest pending task from the set of queues of |priority|, or
46 // false if all queues of that priority are empty.
47 bool ChooseOldestWithPriority(QueuePriority priority,
48 size_t* out_queue_index) const;
49
50 // Returns true if |queue_index| is enabled with the given |priority|.
51 bool QueueEnabledWithPriority(
52 size_t queue_index, QueuePriority priority) const;
53
54 size_t PrioritiesMaskFromQueueIndex(size_t queue_index) const;
55
56 // Number of high priority tasks which can be run before a normal priority
57 // task should be selected to prevent starvation.
58 // TODO(rmcilroy): Check if this is a good value.
59 static const int kMaxStarvationTasks = 5;
60
61 base::ThreadChecker main_thread_checker_;
62 std::vector<const base::TaskQueue*> work_queues_;
63 size_t queue_priorities_[kQueuePriorityCount];
64 int normal_queue_starvation_count_;
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698