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

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

Issue 2644553002: Refactor TimeDomain::MaybeAdvanceTime in preparation for DoWork deduping (Closed)
Patch Set: Rebased Created 3 years, 11 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"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 void OnBeginNestedMessageLoop() override; 169 void OnBeginNestedMessageLoop() override;
170 170
171 // Called by the task queue to register a new pending task. 171 // Called by the task queue to register a new pending task.
172 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); 172 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task);
173 173
174 // Use the selector to choose a pending task and run it. 174 // Use the selector to choose a pending task and run it.
175 void DoWork(base::TimeTicks run_time, bool from_main_thread); 175 void DoWork(base::TimeTicks run_time, bool from_main_thread);
176 176
177 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and 177 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and
178 // reloads any empty work queues. 178 // reloads any empty work queues.
179 void UpdateWorkQueues(LazyNow lazy_now); 179 void UpdateWorkQueues(LazyNow* lazy_now);
180 180
181 // Chooses the next work queue to service. Returns true if |out_queue| 181 // Chooses the next work queue to service. Returns true if |out_queue|
182 // indicates the queue from which the next task should be run, false to 182 // indicates the queue from which the next task should be run, false to
183 // avoid running any tasks. 183 // avoid running any tasks.
184 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue); 184 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue);
185 185
186 // Runs a single nestable task from the |queue|. On exit, |out_task| will
187 // contain the task which was executed. Non-nestable task are reposted on the
188 // run loop. The queue must not be empty.
189 enum class ProcessTaskResult { 186 enum class ProcessTaskResult {
190 DEFERRED, 187 DEFERRED,
191 EXECUTED, 188 EXECUTED,
192 TASK_QUEUE_MANAGER_DELETED 189 TASK_QUEUE_MANAGER_DELETED
193 }; 190 };
191
192 // Runs a single nestable task from the |queue|. On exit, |out_task| will
193 // contain the task which was executed. Non-nestable task are reposted on the
194 // run loop. The queue must not be empty. On exit |time_after_task| may get
195 // set (not guaranteed), sampling |real_time_domain()->Now()| immediately
196 // after running the task.
194 ProcessTaskResult ProcessTaskFromWorkQueue(internal::WorkQueue* work_queue, 197 ProcessTaskResult ProcessTaskFromWorkQueue(internal::WorkQueue* work_queue,
195 LazyNow*); 198 LazyNow time_before_task,
199 base::TimeTicks* time_after_task);
196 200
197 bool RunsTasksOnCurrentThread() const; 201 bool RunsTasksOnCurrentThread() const;
198 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 202 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
199 const base::Closure& task, 203 const base::Closure& task,
200 base::TimeDelta delay); 204 base::TimeDelta delay);
201 205
202 internal::EnqueueOrder GetNextSequenceNumber(); 206 internal::EnqueueOrder GetNextSequenceNumber();
203 207
204 // Calls MaybeAdvanceTime on all time domains and returns true if one of them 208 // Calls DelayTillNextTask on all time domains and returns the smallest delay
205 // was able to advance. 209 // requested if any.
206 bool TryAdvanceTimeDomains(); 210 base::Optional<base::TimeDelta> ComputeDelayTillNextTask(LazyNow* lazy_now);
207 211
208 void MaybeRecordTaskDelayHistograms( 212 void MaybeRecordTaskDelayHistograms(
209 const internal::TaskQueueImpl::Task& pending_task, 213 const internal::TaskQueueImpl::Task& pending_task,
210 const internal::TaskQueueImpl* queue); 214 const internal::TaskQueueImpl* queue);
211 215
212 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 216 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
213 AsValueWithSelectorResult(bool should_run, 217 AsValueWithSelectorResult(bool should_run,
214 internal::WorkQueue* selected_work_queue) const; 218 internal::WorkQueue* selected_work_queue) const;
215 219
216 std::set<TimeDomain*> time_domains_; 220 std::set<TimeDomain*> time_domains_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 scoped_refptr<DeletionSentinel> deletion_sentinel_; 263 scoped_refptr<DeletionSentinel> deletion_sentinel_;
260 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 264 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
261 265
262 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 266 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
263 }; 267 };
264 268
265 } // namespace scheduler 269 } // namespace scheduler
266 } // namespace blink 270 } // namespace blink
267 271
268 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ 272 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698