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

Side by Side Diff: components/scheduler/base/task_queue.h

Issue 1461143003: Revert of Adds TimeDomains to the TaskQueueManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 5 #ifndef COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "components/scheduler/scheduler_export.h" 10 #include "components/scheduler/scheduler_export.h"
11 11
12 namespace scheduler { 12 namespace scheduler {
13 class TimeDomain;
14 13
15 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner { 14 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner {
16 public: 15 public:
17 TaskQueue() {} 16 TaskQueue() {}
18 17
19 // Unregisters the task queue after which no tasks posted to it will run and 18 // Unregisters the task queue after which no tasks posted to it will run and
20 // the TaskQueueManager's reference to it will be released soon. 19 // the TaskQueueManager's reference to it will be released soon.
21 virtual void UnregisterTaskQueue() = 0; 20 virtual void UnregisterTaskQueue() = 0;
22 21
23 // Post a delayed task at an absolute desired run time instead of a time 22 // Post a delayed task at an absolute desired run time instead of a time
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Options for constructing a TaskQueue. Once set the |name|, 95 // Options for constructing a TaskQueue. Once set the |name|,
97 // |should_monitor_quiescence| and |wakeup_policy| are immutable. The 96 // |should_monitor_quiescence| and |wakeup_policy| are immutable. The
98 // |pump_policy| can be mutated with |SetPumpPolicy()|. 97 // |pump_policy| can be mutated with |SetPumpPolicy()|.
99 struct Spec { 98 struct Spec {
100 // Note |name| must have application lifetime. 99 // Note |name| must have application lifetime.
101 explicit Spec(const char* name) 100 explicit Spec(const char* name)
102 : name(name), 101 : name(name),
103 should_monitor_quiescence(false), 102 should_monitor_quiescence(false),
104 pump_policy(TaskQueue::PumpPolicy::AUTO), 103 pump_policy(TaskQueue::PumpPolicy::AUTO),
105 wakeup_policy(TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES), 104 wakeup_policy(TaskQueue::WakeupPolicy::CAN_WAKE_OTHER_QUEUES),
106 time_domain(nullptr),
107 should_notify_observers(true) {} 105 should_notify_observers(true) {}
108 106
109 Spec SetShouldMonitorQuiescence(bool should_monitor) { 107 Spec SetShouldMonitorQuiescence(bool should_monitor) {
110 should_monitor_quiescence = should_monitor; 108 should_monitor_quiescence = should_monitor;
111 return *this; 109 return *this;
112 } 110 }
113 111
114 Spec SetPumpPolicy(PumpPolicy policy) { 112 Spec SetPumpPolicy(PumpPolicy policy) {
115 pump_policy = policy; 113 pump_policy = policy;
116 return *this; 114 return *this;
117 } 115 }
118 116
119 Spec SetWakeupPolicy(WakeupPolicy policy) { 117 Spec SetWakeupPolicy(WakeupPolicy policy) {
120 wakeup_policy = policy; 118 wakeup_policy = policy;
121 return *this; 119 return *this;
122 } 120 }
123 121
124 Spec SetShouldNotifyObservers(bool run_observers) { 122 Spec SetShouldNotifyObservers(bool run_observers) {
125 should_notify_observers = run_observers; 123 should_notify_observers = run_observers;
126 return *this; 124 return *this;
127 } 125 }
128 126
129 Spec SetTimeDomain(TimeDomain* domain) {
130 time_domain = domain;
131 return *this;
132 }
133
134 const char* name; 127 const char* name;
135 bool should_monitor_quiescence; 128 bool should_monitor_quiescence;
136 TaskQueue::PumpPolicy pump_policy; 129 TaskQueue::PumpPolicy pump_policy;
137 TaskQueue::WakeupPolicy wakeup_policy; 130 TaskQueue::WakeupPolicy wakeup_policy;
138 TimeDomain* time_domain;
139 bool should_notify_observers; 131 bool should_notify_observers;
140 }; 132 };
141 133
142 // Returns true if the queue priority is not 134 // Returns true if the queue priority is not
143 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the 135 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the
144 // thread this TaskQueue was created by. 136 // thread this TaskQueue was created by.
145 virtual bool IsQueueEnabled() const = 0; 137 virtual bool IsQueueEnabled() const = 0;
146 138
147 // Returns true if there no tasks in either the work or incoming task queue. 139 // Returns true if there no tasks in either the work or incoming task queue.
148 // Note that this function involves taking a lock, so calling it has some 140 // Note that this function involves taking a lock, so calling it has some
(...skipping 25 matching lines...) Expand all
174 // called on the thread this TaskQueue was created by. 166 // called on the thread this TaskQueue was created by.
175 virtual void PumpQueue() = 0; 167 virtual void PumpQueue() = 0;
176 168
177 // These functions can only be called on the same thread that the task queue 169 // These functions can only be called on the same thread that the task queue
178 // manager executes its tasks on. 170 // manager executes its tasks on.
179 virtual void AddTaskObserver( 171 virtual void AddTaskObserver(
180 base::MessageLoop::TaskObserver* task_observer) = 0; 172 base::MessageLoop::TaskObserver* task_observer) = 0;
181 virtual void RemoveTaskObserver( 173 virtual void RemoveTaskObserver(
182 base::MessageLoop::TaskObserver* task_observer) = 0; 174 base::MessageLoop::TaskObserver* task_observer) = 0;
183 175
184 // Removes the task queue from the previous TimeDomain and adds it to
185 // |domain|. This is a moderately expensive operation.
186 virtual void SetTimeDomain(const scoped_refptr<TimeDomain>& domain) = 0;
187
188 protected: 176 protected:
189 ~TaskQueue() override {} 177 ~TaskQueue() override {}
190 178
191 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 179 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
192 }; 180 };
193 181
194 } // namespace scheduler 182 } // namespace scheduler
195 183
196 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 184 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « components/scheduler/base/real_time_domain.cc ('k') | components/scheduler/base/task_queue_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698