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

Unified Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc

Issue 2386653002: Replace base::Callback with base::OnceCallback in base::PendingTask (Closed)
Patch Set: move UnsafeConvertOnceClosureToRepeating Created 4 years, 2 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
« no previous file with comments | « components/timers/alarm_timer_chromeos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
index 7def64ac93093b72ead7c15b75b697fc0de71f4e..a417cae0f9f0e4f0d5da59a5a557283319d86ca5 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
@@ -38,6 +38,16 @@ void RecordImmediateTaskQueueingDuration(tracked_objects::Duration duration) {
double MonotonicTimeInSeconds(base::TimeTicks timeTicks) {
return (timeTicks - base::TimeTicks()).InSecondsF();
}
+
+// Converts a OnceClosure to a RepeatingClosure. It hits CHECK failure to run
+// the resulting RepeatingClosure more than once.
+// TODO(tzik): This will be unneeded after the Closure-to-OnceClosure migration
+// on TaskRunner finished. Remove it once it gets unneeded.
+base::RepeatingClosure UnsafeConvertOnceClosureToRepeating(
+ base::OnceClosure cb) {
+ return base::BindRepeating([](base::OnceClosure cb) { std::move(cb).Run(); },
+ base::Passed(&cb));
+}
}
TaskQueueManager::TaskQueueManager(
@@ -319,8 +329,11 @@ TaskQueueManager::ProcessTaskResult TaskQueueManager::ProcessTaskFromWorkQueue(
// arbitrarily delayed so the additional delay should not be a problem.
// TODO(skyostil): Figure out a way to not forget which task queue the
// task is associated with. See http://crbug.com/522843.
- delegate_->PostNonNestableTask(pending_task.posted_from,
- std::move(pending_task.task));
+ // TODO(tzik): Remove base::UnsafeConvertOnceClosureToRepeating once
+ // TaskRunners have migrated to OnceClosure.
+ delegate_->PostNonNestableTask(
+ pending_task.posted_from,
+ UnsafeConvertOnceClosureToRepeating(std::move(pending_task.task)));
return ProcessTaskResult::DEFERRED;
}
@@ -341,7 +354,7 @@ TaskQueueManager::ProcessTaskResult TaskQueueManager::ProcessTaskFromWorkQueue(
internal::TaskQueueImpl* prev_executing_task_queue =
currently_executing_task_queue_;
currently_executing_task_queue_ = queue;
- task_annotator_.RunTask("TaskQueueManager::PostTask", pending_task);
+ task_annotator_.RunTask("TaskQueueManager::PostTask", &pending_task);
// Detect if the TaskQueueManager just got deleted. If this happens we must
// not access any member variables after this point.
if (protect->HasOneRef())
« no previous file with comments | « components/timers/alarm_timer_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698