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

Side by Side Diff: third_party/WebKit/public/platform/scheduler/base/task_queue.h

Issue 2437003002: [scheduler] Add type to scheduler::TaskQueue (Closed)
Patch Set: fix windows compilation Created 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/optional.h" 10 #include "base/optional.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // Queues with normal priority are the default. 47 // Queues with normal priority are the default.
48 NORMAL_PRIORITY, 48 NORMAL_PRIORITY,
49 // Queues with best effort priority will only be run if all other queues are 49 // Queues with best effort priority will only be run if all other queues are
50 // empty. They can be starved by the other queues. 50 // empty. They can be starved by the other queues.
51 BEST_EFFORT_PRIORITY, 51 BEST_EFFORT_PRIORITY,
52 // Must be the last entry. 52 // Must be the last entry.
53 QUEUE_PRIORITY_COUNT, 53 QUEUE_PRIORITY_COUNT,
54 FIRST_QUEUE_PRIORITY = CONTROL_PRIORITY, 54 FIRST_QUEUE_PRIORITY = CONTROL_PRIORITY,
55 }; 55 };
56 56
57 enum class QueueType {
58 // Keep TaskQueue::NameForQueueType in sync.
59 // This enum is used for a histogram and it should not be re-numbered.
60 CONTROL = 0,
61 DEFAULT = 1,
62 DEFAULT_LOADING = 2,
63 DEFAULT_TIMER = 3,
64 UNTHROTTLED = 4,
65 FRAME_LOADING = 5,
66 FRAME_TIMER = 6,
67 FRAME_UNTHROTTLED = 7,
68 COMPOSITOR = 8,
69 IDLE = 9,
70 TEST = 10,
71
72 COUNT = 11
73 };
74
75 // Returns name of the given queue type. Returned string has application
76 // lifetime.
77 static const char* NameForQueueType(QueueType queue_type);
78
57 // Options for constructing a TaskQueue. Once set the |name| and 79 // Options for constructing a TaskQueue. Once set the |name| and
58 // |should_monitor_quiescence| are immutable. 80 // |should_monitor_quiescence| are immutable.
59 struct Spec { 81 struct Spec {
60 // Note |name| must have application lifetime. 82 explicit Spec(QueueType type)
61 explicit Spec(const char* name) 83 : type(type),
62 : name(name),
63 should_monitor_quiescence(false), 84 should_monitor_quiescence(false),
64 time_domain(nullptr), 85 time_domain(nullptr),
65 should_notify_observers(true), 86 should_notify_observers(true),
66 should_report_when_execution_blocked(false) {} 87 should_report_when_execution_blocked(false) {}
67 88
68 Spec SetShouldMonitorQuiescence(bool should_monitor) { 89 Spec SetShouldMonitorQuiescence(bool should_monitor) {
69 should_monitor_quiescence = should_monitor; 90 should_monitor_quiescence = should_monitor;
70 return *this; 91 return *this;
71 } 92 }
72 93
73 Spec SetShouldNotifyObservers(bool run_observers) { 94 Spec SetShouldNotifyObservers(bool run_observers) {
74 should_notify_observers = run_observers; 95 should_notify_observers = run_observers;
75 return *this; 96 return *this;
76 } 97 }
77 98
78 Spec SetTimeDomain(TimeDomain* domain) { 99 Spec SetTimeDomain(TimeDomain* domain) {
79 time_domain = domain; 100 time_domain = domain;
80 return *this; 101 return *this;
81 } 102 }
82 103
83 // See TaskQueueManager::Observer::OnTriedToExecuteBlockedTask. 104 // See TaskQueueManager::Observer::OnTriedToExecuteBlockedTask.
84 Spec SetShouldReportWhenExecutionBlocked(bool should_report) { 105 Spec SetShouldReportWhenExecutionBlocked(bool should_report) {
85 should_report_when_execution_blocked = should_report; 106 should_report_when_execution_blocked = should_report;
86 return *this; 107 return *this;
87 } 108 }
88 109
89 const char* name; 110 QueueType type;
90 bool should_monitor_quiescence; 111 bool should_monitor_quiescence;
91 TimeDomain* time_domain; 112 TimeDomain* time_domain;
92 bool should_notify_observers; 113 bool should_notify_observers;
93 bool should_report_when_execution_blocked; 114 bool should_report_when_execution_blocked;
94 }; 115 };
95 116
96 // Enable or disable task execution for this queue. NOTE this must be called 117 // Enable or disable task execution for this queue. NOTE this must be called
97 // on the thread this TaskQueue was created by. 118 // on the thread this TaskQueue was created by.
98 virtual void SetQueueEnabled(bool enabled) = 0; 119 virtual void SetQueueEnabled(bool enabled) = 0;
99 120
100 // NOTE this must be called on the thread this TaskQueue was created by. 121 // NOTE this must be called on the thread this TaskQueue was created by.
101 virtual bool IsQueueEnabled() const = 0; 122 virtual bool IsQueueEnabled() const = 0;
102 123
103 // Returns true if the queue is completely empty. 124 // Returns true if the queue is completely empty.
104 virtual bool IsEmpty() const = 0; 125 virtual bool IsEmpty() const = 0;
105 126
106 // Returns the number of pending tasks in the queue. 127 // Returns the number of pending tasks in the queue.
107 virtual size_t GetNumberOfPendingTasks() const = 0; 128 virtual size_t GetNumberOfPendingTasks() const = 0;
108 129
109 // Returns true if the queue has work that's ready to execute now. 130 // Returns true if the queue has work that's ready to execute now.
110 // NOTE: this must be called on the thread this TaskQueue was created by. 131 // NOTE: this must be called on the thread this TaskQueue was created by.
111 virtual bool HasPendingImmediateWork() const = 0; 132 virtual bool HasPendingImmediateWork() const = 0;
112 133
113 // Returns requested run time of next delayed task, which is not ready 134 // Returns requested run time of next delayed task, which is not ready
114 // to run. If there are no such tasks, returns base::nullopt. 135 // to run. If there are no such tasks, returns base::nullopt.
115 // NOTE: this must be called on the thread this TaskQueue was created by. 136 // NOTE: this must be called on the thread this TaskQueue was created by.
116 virtual base::Optional<base::TimeTicks> GetNextScheduledWakeUp() = 0; 137 virtual base::Optional<base::TimeTicks> GetNextScheduledWakeUp() = 0;
117 138
118 // Can be called on any thread. 139 // Can be called on any thread.
140 virtual QueueType GetQueueType() const = 0;
141
142 // Can be called on any thread.
119 virtual const char* GetName() const = 0; 143 virtual const char* GetName() const = 0;
120 144
121 // Set the priority of the queue to |priority|. NOTE this must be called on 145 // Set the priority of the queue to |priority|. NOTE this must be called on
122 // the thread this TaskQueue was created by. 146 // the thread this TaskQueue was created by.
123 virtual void SetQueuePriority(QueuePriority priority) = 0; 147 virtual void SetQueuePriority(QueuePriority priority) = 0;
124 148
125 // Returns the current queue priority. 149 // Returns the current queue priority.
126 virtual QueuePriority GetQueuePriority() const = 0; 150 virtual QueuePriority GetQueuePriority() const = 0;
127 151
128 // These functions can only be called on the same thread that the task queue 152 // These functions can only be called on the same thread that the task queue
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 protected: 185 protected:
162 ~TaskQueue() override {} 186 ~TaskQueue() override {}
163 187
164 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 188 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
165 }; 189 };
166 190
167 } // namespace scheduler 191 } // namespace scheduler
168 } // namespace blink 192 } // namespace blink
169 193
170 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 194 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698