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

Side by Side Diff: components/scheduler/child/task_queue_manager.h

Issue 1223163006: Implement PostDelayedTaskAt for guaranteed timer ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing include to IdleHelperTest. Created 5 years, 5 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 2014 The Chromium Authors. All rights reserved. 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 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 CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ 5 #ifndef CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_
6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ 6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_
7 7
8 #include "base/atomic_sequence_num.h" 8 #include "base/atomic_sequence_num.h"
9 #include "base/debug/task_annotator.h" 9 #include "base/debug/task_annotator.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/pending_task.h" 13 #include "base/pending_task.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
16 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
17 #include "components/scheduler/child/task_queue_selector.h" 16 #include "components/scheduler/child/task_queue_selector.h"
18 #include "components/scheduler/scheduler_export.h" 17 #include "components/scheduler/scheduler_export.h"
19 18
20 namespace base { 19 namespace base {
21 namespace trace_event { 20 namespace trace_event {
22 class ConvertableToTraceFormat; 21 class ConvertableToTraceFormat;
23 class TracedValue; 22 class TracedValue;
24 } 23 }
25 class TickClock; 24 class TickClock;
26 } 25 }
27 26
28 namespace scheduler { 27 namespace scheduler {
28 class TaskQueue;
29 namespace internal { 29 namespace internal {
30 class LazyNow; 30 class LazyNow;
31 class TaskQueue; 31 class TaskQueueImpl;
32 } 32 }
33 class NestableSingleThreadTaskRunner; 33 class NestableSingleThreadTaskRunner;
34 class TaskQueueSelector; 34 class TaskQueueSelector;
35 35
36 // The task queue manager provides N task queues and a selector interface for 36 // The task queue manager provides N task queues and a selector interface for
37 // choosing which task queue to service next. Each task queue consists of two 37 // choosing which task queue to service next. Each task queue consists of two
38 // sub queues: 38 // sub queues:
39 // 39 //
40 // 1. Incoming task queue. Tasks that are posted get immediately appended here. 40 // 1. Incoming task queue. Tasks that are posted get immediately appended here.
41 // When a task is appended into an empty incoming queue, the task manager 41 // When a task is appended into an empty incoming queue, the task manager
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // lifetime (statics or literals). They may not include " chars. 100 // lifetime (statics or literals). They may not include " chars.
101 TaskQueueManager( 101 TaskQueueManager(
102 size_t task_queue_count, 102 size_t task_queue_count,
103 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner, 103 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner,
104 TaskQueueSelector* selector, 104 TaskQueueSelector* selector,
105 const char* disabled_by_default_tracing_category, 105 const char* disabled_by_default_tracing_category,
106 const char* disabled_by_default_verbose_tracing_category); 106 const char* disabled_by_default_verbose_tracing_category);
107 ~TaskQueueManager() override; 107 ~TaskQueueManager() override;
108 108
109 // Returns the task runner which targets the queue selected by |queue_index|. 109 // Returns the task runner which targets the queue selected by |queue_index|.
110 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue( 110 scoped_refptr<TaskQueue> TaskRunnerForQueue(size_t queue_index) const;
111 size_t queue_index) const;
112 111
113 // Sets the pump policy for the |queue_index| to |pump_policy|. By 112 // Sets the pump policy for the |queue_index| to |pump_policy|. By
114 // default queues are created with AUTO_PUMP_POLICY. 113 // default queues are created with AUTO_PUMP_POLICY.
115 void SetPumpPolicy(size_t queue_index, PumpPolicy pump_policy); 114 void SetPumpPolicy(size_t queue_index, PumpPolicy pump_policy);
116 115
117 // Sets the wakeup policy for the |queue_index| to |wakeup_policy|. By 116 // Sets the wakeup policy for the |queue_index| to |wakeup_policy|. By
118 // default queues are created with CAN_WAKE_OTHER_QUEUES. 117 // default queues are created with CAN_WAKE_OTHER_QUEUES.
119 void SetWakeupPolicy(size_t queue_index, WakeupPolicy wakeup_policy); 118 void SetWakeupPolicy(size_t queue_index, WakeupPolicy wakeup_policy);
120 119
121 // Reloads new tasks from the incoming queue for |queue_index| into the work 120 // Reloads new tasks from the incoming queue for |queue_index| into the work
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 161
163 // Returns a bitmap where a bit is set iff a task on the corresponding queue 162 // Returns a bitmap where a bit is set iff a task on the corresponding queue
164 // was run since the last call to GetAndClearTaskWasRunOnQueueBitmap. 163 // was run since the last call to GetAndClearTaskWasRunOnQueueBitmap.
165 uint64 GetAndClearTaskWasRunOnQueueBitmap(); 164 uint64 GetAndClearTaskWasRunOnQueueBitmap();
166 165
167 private: 166 private:
168 // TaskQueueSelector::Observer implementation: 167 // TaskQueueSelector::Observer implementation:
169 void OnTaskQueueEnabled() override; 168 void OnTaskQueueEnabled() override;
170 169
171 friend class internal::LazyNow; 170 friend class internal::LazyNow;
172 friend class internal::TaskQueue; 171 friend class internal::TaskQueueImpl;
173 friend class TaskQueueManagerTest; 172 friend class TaskQueueManagerTest;
174 173
175 class DeletionSentinel : public base::RefCounted<DeletionSentinel> { 174 class DeletionSentinel : public base::RefCounted<DeletionSentinel> {
176 private: 175 private:
177 friend class base::RefCounted<DeletionSentinel>; 176 friend class base::RefCounted<DeletionSentinel>;
178 ~DeletionSentinel() {} 177 ~DeletionSentinel() {}
179 }; 178 };
180 179
181 // Called by the task queue to register a new pending task. 180 // Called by the task queue to register a new pending task.
182 void DidQueueTask(const base::PendingTask& pending_task); 181 void DidQueueTask(const base::PendingTask& pending_task);
(...skipping 29 matching lines...) Expand all
212 bool has_previous_task, 211 bool has_previous_task,
213 base::PendingTask* previous_task); 212 base::PendingTask* previous_task);
214 213
215 bool RunsTasksOnCurrentThread() const; 214 bool RunsTasksOnCurrentThread() const;
216 bool PostDelayedTask(const tracked_objects::Location& from_here, 215 bool PostDelayedTask(const tracked_objects::Location& from_here,
217 const base::Closure& task, 216 const base::Closure& task,
218 base::TimeDelta delay); 217 base::TimeDelta delay);
219 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 218 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
220 const base::Closure& task, 219 const base::Closure& task,
221 base::TimeDelta delay); 220 base::TimeDelta delay);
222 internal::TaskQueue* Queue(size_t queue_index) const; 221 internal::TaskQueueImpl* Queue(size_t queue_index) const;
223 222
224 base::TimeTicks Now() const; 223 base::TimeTicks Now() const;
225 224
226 int GetNextSequenceNumber(); 225 int GetNextSequenceNumber();
227 226
228 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 227 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
229 AsValueWithSelectorResult(bool should_run, size_t selected_queue) const; 228 AsValueWithSelectorResult(bool should_run, size_t selected_queue) const;
230 static const char* PumpPolicyToString(PumpPolicy pump_policy); 229 static const char* PumpPolicyToString(PumpPolicy pump_policy);
231 static const char* WakeupPolicyToString(WakeupPolicy wakeup_policy); 230 static const char* WakeupPolicyToString(WakeupPolicy wakeup_policy);
232 231
233 std::vector<scoped_refptr<internal::TaskQueue>> queues_; 232 std::vector<scoped_refptr<internal::TaskQueueImpl>> queues_;
234 base::AtomicSequenceNumber task_sequence_num_; 233 base::AtomicSequenceNumber task_sequence_num_;
235 base::debug::TaskAnnotator task_annotator_; 234 base::debug::TaskAnnotator task_annotator_;
236 235
237 base::ThreadChecker main_thread_checker_; 236 base::ThreadChecker main_thread_checker_;
238 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner_; 237 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner_;
239 TaskQueueSelector* selector_; 238 TaskQueueSelector* selector_;
240 239
241 base::Closure do_work_from_main_thread_closure_; 240 base::Closure do_work_from_main_thread_closure_;
242 base::Closure do_work_from_other_thread_closure_; 241 base::Closure do_work_from_other_thread_closure_;
243 242
(...skipping 13 matching lines...) Expand all
257 256
258 scoped_refptr<DeletionSentinel> deletion_sentinel_; 257 scoped_refptr<DeletionSentinel> deletion_sentinel_;
259 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 258 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
260 259
261 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 260 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
262 }; 261 };
263 262
264 } // namespace scheduler 263 } // namespace scheduler
265 264
266 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ 265 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_
OLDNEW
« no previous file with comments | « components/scheduler/child/task_queue.h ('k') | components/scheduler/child/task_queue_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698