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

Unified Diff: base/task_scheduler/utils.cc

Issue 1704113002: TaskScheduler [6] SchedulerWorkerThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s_4_shutdown
Patch Set: CR from robliao Created 4 years, 9 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: base/task_scheduler/utils.cc
diff --git a/base/task_scheduler/utils.cc b/base/task_scheduler/utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..560b779dd580fb4596968eaaf515b5e440a7ce4c
--- /dev/null
+++ b/base/task_scheduler/utils.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/task_scheduler/utils.h"
+
+#include "base/bind.h"
+#include "base/task_scheduler/priority_queue.h"
+#include "base/task_scheduler/task_tracker.h"
+
+namespace base {
+namespace internal {
+
+namespace {
+
+void PostTaskCallback(scoped_refptr<Sequence> sequence,
+ PriorityQueue* priority_queue,
+ scoped_ptr<Task> task) {
+ if (sequence->PushTask(std::move(task))) {
+ // |sequence| was empty before |task| was inserted into it. That means that
+ // |sequence| must be inserted in |priority_queue|.
+ SequenceSortKey sequence_sort_key = sequence->GetSortKey();
gab 2016/03/21 19:11:53 const
fdoray 2016/03/24 19:21:09 Done.
+ priority_queue->BeginTransaction()->Push(make_scoped_ptr(
+ new PriorityQueue::SequenceAndSortKey(sequence, sequence_sort_key)));
gab 2016/03/21 19:11:53 std::move(sequence) Not sure whether compiler can
fdoray 2016/03/24 19:21:09 Done.
+ }
+}
+
+} // namespace
+
+void PostTaskHelper(scoped_ptr<Task> task,
+ scoped_refptr<Sequence> sequence,
+ PriorityQueue* priority_queue,
+ TaskTracker* task_tracker) {
+ DCHECK(task.get());
gab 2016/03/21 19:11:53 No .get() for bool operations here and below
fdoray 2016/03/24 19:21:09 Done.
+ DCHECK(sequence.get());
+ DCHECK(priority_queue);
+ DCHECK(task_tracker);
+
+ task_tracker->PostTask(Bind(&PostTaskCallback, sequence, priority_queue),
gab 2016/03/21 19:11:53 std::move(sequence)
fdoray 2016/03/24 19:21:09 Done.
+ std::move(task));
+}
+
+} // namespace internal
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698