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

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

Issue 922733002: scheduler: Implement task observers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/pending_task.h" 13 #include "base/pending_task.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
16 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
17 18
18 namespace base { 19 namespace base {
19 namespace trace_event { 20 namespace trace_event {
20 class ConvertableToTraceFormat; 21 class ConvertableToTraceFormat;
21 class TracedValue; 22 class TracedValue;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Set the name |queue_index| for tracing purposes. |name| must be a pointer 84 // Set the name |queue_index| for tracing purposes. |name| must be a pointer
84 // to a static string. 85 // to a static string.
85 void SetQueueName(size_t queue_index, const char* name); 86 void SetQueueName(size_t queue_index, const char* name);
86 87
87 // Set the number of tasks executed in a single invocation of the task queue 88 // Set the number of tasks executed in a single invocation of the task queue
88 // manager. Increasing the batch size can reduce the overhead of yielding 89 // manager. Increasing the batch size can reduce the overhead of yielding
89 // back to the main message loop -- at the cost of potentially delaying other 90 // back to the main message loop -- at the cost of potentially delaying other
90 // tasks posted to the main loop. The batch size is 1 by default. 91 // tasks posted to the main loop. The batch size is 1 by default.
91 void SetWorkBatchSize(int work_batch_size); 92 void SetWorkBatchSize(int work_batch_size);
92 93
94 // These functions can only be called on the same thread that the task queue
95 // manager executes its tasks on.
96 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer);
97 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer);
98
93 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); 99 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source);
94 100
95 private: 101 private:
96 friend class internal::TaskQueue; 102 friend class internal::TaskQueue;
97 103
98 // Called by the task queue to register a new pending task and allocate a 104 // Called by the task queue to register a new pending task and allocate a
99 // sequence number for it. 105 // sequence number for it.
100 void DidQueueTask(base::PendingTask* pending_task); 106 void DidQueueTask(base::PendingTask* pending_task);
101 107
102 // Post a task to call DoWork() on the main task runner. Only one pending 108 // Post a task to call DoWork() on the main task runner. Only one pending
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 base::WeakPtr<TaskQueueManager> task_queue_manager_weak_ptr_; 154 base::WeakPtr<TaskQueueManager> task_queue_manager_weak_ptr_;
149 155
150 // The pending_dowork_count_ is only tracked on the main thread since that's 156 // The pending_dowork_count_ is only tracked on the main thread since that's
151 // where re-entrant problems happen. 157 // where re-entrant problems happen.
152 int pending_dowork_count_; 158 int pending_dowork_count_;
153 159
154 int work_batch_size_; 160 int work_batch_size_;
155 161
156 scoped_refptr<cc::TestNowSource> time_source_; 162 scoped_refptr<cc::TestNowSource> time_source_;
157 163
164 ObserverList<base::MessageLoop::TaskObserver> task_observers_;
165
158 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 166 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
159 167
160 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 168 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
161 }; 169 };
162 170
163 } // namespace content 171 } // namespace content
164 172
165 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ 173 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698