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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h

Issue 2818533003: Make nesting/running states a RunLoop rather than a MessageLoop concept. (Closed)
Patch Set: still need to check MessageLoop::current() in Mojo's RunLoopNestingObserver::GetForThread() Created 3 years, 7 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
11 #include "base/cancelable_callback.h" 11 #include "base/cancelable_callback.h"
12 #include "base/debug/task_annotator.h" 12 #include "base/debug/task_annotator.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/pending_task.h" 16 #include "base/pending_task.h"
17 #include "base/run_loop.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
19 #include "platform/scheduler/base/enqueue_order.h" 20 #include "platform/scheduler/base/enqueue_order.h"
20 #include "platform/scheduler/base/moveable_auto_lock.h" 21 #include "platform/scheduler/base/moveable_auto_lock.h"
21 #include "platform/scheduler/base/task_queue_impl.h" 22 #include "platform/scheduler/base/task_queue_impl.h"
22 #include "platform/scheduler/base/task_queue_selector.h" 23 #include "platform/scheduler/base/task_queue_selector.h"
23 24
24 namespace base { 25 namespace base {
25 namespace trace_event { 26 namespace trace_event {
26 class ConvertableToTraceFormat; 27 class ConvertableToTraceFormat;
(...skipping 19 matching lines...) Expand all
46 // 1. Incoming task queue. Tasks that are posted get immediately appended here. 47 // 1. Incoming task queue. Tasks that are posted get immediately appended here.
47 // When a task is appended into an empty incoming queue, the task manager 48 // When a task is appended into an empty incoming queue, the task manager
48 // work function (DoWork) is scheduled to run on the main task runner. 49 // work function (DoWork) is scheduled to run on the main task runner.
49 // 50 //
50 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from 51 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from
51 // the incoming task queue (if any) are moved here. The work queues are 52 // the incoming task queue (if any) are moved here. The work queues are
52 // registered with the selector as input to the scheduling decision. 53 // registered with the selector as input to the scheduling decision.
53 // 54 //
54 class PLATFORM_EXPORT TaskQueueManager 55 class PLATFORM_EXPORT TaskQueueManager
55 : public internal::TaskQueueSelector::Observer, 56 : public internal::TaskQueueSelector::Observer,
56 public base::MessageLoop::NestingObserver { 57 public base::RunLoop::NestingObserver {
57 public: 58 public:
58 // Create a task queue manager where |delegate| identifies the thread 59 // Create a task queue manager where |delegate| identifies the thread
59 // on which where the tasks are eventually run. Category strings must have 60 // on which where the tasks are eventually run. Category strings must have
60 // application lifetime (statics or literals). They may not include " chars. 61 // application lifetime (statics or literals). They may not include " chars.
61 explicit TaskQueueManager(scoped_refptr<TaskQueueManagerDelegate> delegate); 62 explicit TaskQueueManager(scoped_refptr<TaskQueueManagerDelegate> delegate);
62 ~TaskQueueManager() override; 63 ~TaskQueueManager() override;
63 64
64 // Requests that a task to process work is posted on the main task runner. 65 // Requests that a task to process work is posted on the main task runner.
65 // These tasks are de-duplicated in two buckets: main-thread and all other 66 // These tasks are de-duplicated in two buckets: main-thread and all other
66 // threads. This distinction is done to reduce the overehead from locks, we 67 // threads. This distinction is done to reduce the overehead from locks, we
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 }; 227 };
227 228
228 // Unregisters a TaskQueue previously created by |NewTaskQueue()|. 229 // Unregisters a TaskQueue previously created by |NewTaskQueue()|.
229 void UnregisterTaskQueue(scoped_refptr<internal::TaskQueueImpl> task_queue); 230 void UnregisterTaskQueue(scoped_refptr<internal::TaskQueueImpl> task_queue);
230 231
231 // TaskQueueSelector::Observer implementation: 232 // TaskQueueSelector::Observer implementation:
232 void OnTaskQueueEnabled(internal::TaskQueueImpl* queue) override; 233 void OnTaskQueueEnabled(internal::TaskQueueImpl* queue) override;
233 void OnTriedToSelectBlockedWorkQueue( 234 void OnTriedToSelectBlockedWorkQueue(
234 internal::WorkQueue* work_queue) override; 235 internal::WorkQueue* work_queue) override;
235 236
236 // base::MessageLoop::NestingObserver implementation: 237 // base::RunLoop::NestingObserver implementation:
237 void OnBeginNestedMessageLoop() override; 238 void OnBeginNestedRunLoop() override;
238 239
239 // Called by the task queue to register a new pending task. 240 // Called by the task queue to register a new pending task.
240 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); 241 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task);
241 242
242 // Use the selector to choose a pending task and run it. 243 // Use the selector to choose a pending task and run it.
243 void DoWork(bool delayed); 244 void DoWork(bool delayed);
244 245
245 // Post a DoWork continuation if |next_delay| is not empty. 246 // Post a DoWork continuation if |next_delay| is not empty.
246 void PostDoWorkContinuationLocked(base::Optional<NextTaskDelay> next_delay, 247 void PostDoWorkContinuationLocked(base::Optional<NextTaskDelay> next_delay,
247 LazyNow* lazy_now, 248 LazyNow* lazy_now,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 scoped_refptr<DeletionSentinel> deletion_sentinel_; 376 scoped_refptr<DeletionSentinel> deletion_sentinel_;
376 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 377 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
377 378
378 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 379 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
379 }; 380 };
380 381
381 } // namespace scheduler 382 } // namespace scheduler
382 } // namespace blink 383 } // namespace blink
383 384
384 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ 385 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698