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

Side by Side Diff: base/task_scheduler/post_task.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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
« no previous file with comments | « base/task_scheduler/post_task.h ('k') | base/task_scheduler/scheduler_worker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "base/task_scheduler/post_task.h" 5 #include "base/task_scheduler/post_task.h"
6 6
7 #include "base/callback.h"
7 #include "base/task_scheduler/task_scheduler.h" 8 #include "base/task_scheduler/task_scheduler.h"
8 #include "base/threading/post_task_and_reply_impl.h" 9 #include "base/threading/post_task_and_reply_impl.h"
9 10
10 namespace base { 11 namespace base {
11 12
12 namespace { 13 namespace {
13 14
14 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl { 15 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl {
15 public: 16 public:
16 explicit PostTaskAndReplyTaskRunner(TaskTraits traits) 17 explicit PostTaskAndReplyTaskRunner(TaskTraits traits)
17 : traits_(traits) {} 18 : traits_(traits) {}
18 19
19 private: 20 private:
20 bool PostTask(const tracked_objects::Location& from_here, 21 bool PostTask(const tracked_objects::Location& from_here,
21 const Closure& task) override { 22 OnceClosure task) override {
22 PostTaskWithTraits(from_here, traits_, task); 23 PostTaskWithTraits(from_here, traits_, std::move(task));
23 return true; 24 return true;
24 } 25 }
25 26
26 const TaskTraits traits_; 27 const TaskTraits traits_;
27 }; 28 };
28 29
29 30
30 } // namespace 31 } // namespace
31 32
32 void PostTask(const tracked_objects::Location& from_here, const Closure& task) { 33 void PostTask(const tracked_objects::Location& from_here, OnceClosure task) {
33 PostTaskWithTraits(from_here, TaskTraits(), task); 34 PostTaskWithTraits(from_here, TaskTraits(), std::move(task));
34 } 35 }
35 36
36 void PostTaskAndReply(const tracked_objects::Location& from_here, 37 void PostTaskAndReply(const tracked_objects::Location& from_here,
37 const Closure& task, 38 OnceClosure task,
38 const Closure& reply) { 39 OnceClosure reply) {
39 PostTaskWithTraitsAndReply(from_here, TaskTraits(), task, reply); 40 PostTaskWithTraitsAndReply(from_here, TaskTraits(),
41 std::move(task), std::move(reply));
40 } 42 }
41 43
42 void PostTaskWithTraits(const tracked_objects::Location& from_here, 44 void PostTaskWithTraits(const tracked_objects::Location& from_here,
43 TaskTraits traits, 45 TaskTraits traits,
44 const Closure& task) { 46 OnceClosure task) {
45 TaskScheduler::GetInstance()->PostTaskWithTraits(from_here, traits, task); 47 TaskScheduler::GetInstance()->PostTaskWithTraits(from_here, traits,
48 std::move(task));
46 } 49 }
47 50
48 void PostTaskWithTraitsAndReply(const tracked_objects::Location& from_here, 51 void PostTaskWithTraitsAndReply(const tracked_objects::Location& from_here,
49 TaskTraits traits, 52 TaskTraits traits,
50 const Closure& task, 53 OnceClosure task,
51 const Closure& reply) { 54 OnceClosure reply) {
52 PostTaskAndReplyTaskRunner(traits).PostTaskAndReply(from_here, task, reply); 55 PostTaskAndReplyTaskRunner(traits).PostTaskAndReply(
56 from_here, std::move(task), std::move(reply));
53 } 57 }
54 58
55 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( 59 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
56 TaskTraits traits, 60 TaskTraits traits,
57 ExecutionMode execution_mode) { 61 ExecutionMode execution_mode) {
58 return TaskScheduler::GetInstance()->CreateTaskRunnerWithTraits( 62 return TaskScheduler::GetInstance()->CreateTaskRunnerWithTraits(
59 traits, execution_mode); 63 traits, execution_mode);
60 } 64 }
61 65
62 } // namespace base 66 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/post_task.h ('k') | base/task_scheduler/scheduler_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698