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

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

Issue 1098033002: Remove dependency on cc::TestNowSource from scheduler code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 5 years, 8 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" 14 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "content/child/scheduler/task_queue_selector.h" 17 #include "content/child/scheduler/task_queue_selector.h"
18 #include "content/child/scheduler/time_source.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 20
20 namespace base { 21 namespace base {
21 namespace trace_event { 22 namespace trace_event {
22 class ConvertableToTraceFormat; 23 class ConvertableToTraceFormat;
23 class TracedValue; 24 class TracedValue;
24 } 25 }
25 } 26 }
26 27
27 namespace cc {
28 class TestNowSource;
29 }
30
31 namespace content { 28 namespace content {
32 namespace internal { 29 namespace internal {
33 class LazyNow; 30 class LazyNow;
34 class TaskQueue; 31 class TaskQueue;
35 } 32 }
33 class NestableSingleThreadTaskRunner;
36 class TaskQueueSelector; 34 class TaskQueueSelector;
37 class NestableSingleThreadTaskRunner; 35 class TimeSource;
38 36
39 // The task queue manager provides N task queues and a selector interface for 37 // The task queue manager provides N task queues and a selector interface for
40 // choosing which task queue to service next. Each task queue consists of two 38 // choosing which task queue to service next. Each task queue consists of two
41 // sub queues: 39 // sub queues:
42 // 40 //
43 // 1. Incoming task queue. Tasks that are posted get immediately appended here. 41 // 1. Incoming task queue. Tasks that are posted get immediately appended here.
44 // When a task is appended into an empty incoming queue, the task manager 42 // When a task is appended into an empty incoming queue, the task manager
45 // work function (DoWork) is scheduled to run on the main task runner. 43 // work function (DoWork) is scheduled to run on the main task runner.
46 // 44 //
47 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from 45 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // manager. Increasing the batch size can reduce the overhead of yielding 115 // manager. Increasing the batch size can reduce the overhead of yielding
118 // back to the main message loop -- at the cost of potentially delaying other 116 // back to the main message loop -- at the cost of potentially delaying other
119 // tasks posted to the main loop. The batch size is 1 by default. 117 // tasks posted to the main loop. The batch size is 1 by default.
120 void SetWorkBatchSize(int work_batch_size); 118 void SetWorkBatchSize(int work_batch_size);
121 119
122 // These functions can only be called on the same thread that the task queue 120 // These functions can only be called on the same thread that the task queue
123 // manager executes its tasks on. 121 // manager executes its tasks on.
124 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); 122 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer);
125 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); 123 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer);
126 124
127 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); 125 void SetTimeSourceForTesting(scoped_ptr<TimeSource> time_source);
128 126
129 // Returns a bitmap where a bit is set iff a task on the corresponding queue 127 // Returns a bitmap where a bit is set iff a task on the corresponding queue
130 // was run since the last call to GetAndClearTaskWasRunOnQueueBitmap. 128 // was run since the last call to GetAndClearTaskWasRunOnQueueBitmap.
131 uint64 GetAndClearTaskWasRunOnQueueBitmap(); 129 uint64 GetAndClearTaskWasRunOnQueueBitmap();
132 130
133 private: 131 private:
134 // TaskQueueSelector::Observer implementation: 132 // TaskQueueSelector::Observer implementation:
135 void OnTaskQueueEnabled() override; 133 void OnTaskQueueEnabled() override;
136 134
137 friend class internal::LazyNow; 135 friend class internal::LazyNow;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 base::Closure do_work_from_other_thread_closure_; 202 base::Closure do_work_from_other_thread_closure_;
205 203
206 uint64 task_was_run_bitmap_; 204 uint64 task_was_run_bitmap_;
207 205
208 // The pending_dowork_count_ is only tracked on the main thread since that's 206 // The pending_dowork_count_ is only tracked on the main thread since that's
209 // where re-entrant problems happen. 207 // where re-entrant problems happen.
210 int pending_dowork_count_; 208 int pending_dowork_count_;
211 209
212 int work_batch_size_; 210 int work_batch_size_;
213 211
214 scoped_refptr<cc::TestNowSource> time_source_; 212 scoped_ptr<TimeSource> time_source_;
215 213
216 ObserverList<base::MessageLoop::TaskObserver> task_observers_; 214 ObserverList<base::MessageLoop::TaskObserver> task_observers_;
217 215
218 const char* disabled_by_default_tracing_category_; 216 const char* disabled_by_default_tracing_category_;
219 217
220 scoped_refptr<DeletionSentinel> deletion_sentinel_; 218 scoped_refptr<DeletionSentinel> deletion_sentinel_;
221 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 219 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
222 220
223 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 221 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
224 }; 222 };
225 223
226 } // namespace content 224 } // namespace content
227 225
228 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ 226 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_
OLDNEW
« no previous file with comments | « content/child/scheduler/scheduler_helper_unittest.cc ('k') | content/child/scheduler/task_queue_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698