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

Unified 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: Added comment about callback counts. 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/scheduler/task_queue_manager.h
diff --git a/content/renderer/scheduler/task_queue_manager.h b/content/renderer/scheduler/task_queue_manager.h
index 77bb2bfaf5c0a7cd48176118d0a307c6456021c8..002fe884392d34c266fe8a704ef46a585e3a975e 100644
--- a/content/renderer/scheduler/task_queue_manager.h
+++ b/content/renderer/scheduler/task_queue_manager.h
@@ -9,6 +9,7 @@
#include "base/debug/task_annotator.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/pending_task.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
@@ -90,6 +91,11 @@ class CONTENT_EXPORT TaskQueueManager {
// tasks posted to the main loop. The batch size is 1 by default.
void SetWorkBatchSize(int work_batch_size);
+ // These functions can only be called on the same thread that the task queue
+ // manager executes its tasks on.
+ void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer);
+ void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer);
+
void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source);
private:
@@ -119,9 +125,10 @@ class CONTENT_EXPORT TaskQueueManager {
bool SelectWorkQueueToService(size_t* out_queue_index);
// Runs a single nestable task from the work queue designated by
- // |queue_index|. Non-nestable task are reposted on the run loop.
- // The queue must not be empty.
- void ProcessTaskFromWorkQueue(size_t queue_index);
+ // |queue_index|. |first_task_in_batch| should be true if this the first task
+ // we are executing in the current work batch. Non-nestable task are reposted
+ // on the run loop. The queue must not be empty.
+ void ProcessTaskFromWorkQueue(size_t queue_index, bool first_task_in_batch);
bool RunsTasksOnCurrentThread() const;
bool PostDelayedTask(const tracked_objects::Location& from_here,
@@ -155,6 +162,11 @@ class CONTENT_EXPORT TaskQueueManager {
scoped_refptr<cc::TestNowSource> time_source_;
+ ObserverList<base::MessageLoop::TaskObserver> task_observers_;
+
+ // Previously executed task. Only valid during a call to DoWork().
+ base::PendingTask previous_task_;
+
base::WeakPtrFactory<TaskQueueManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);

Powered by Google App Engine
This is Rietveld 408576698