OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/worker_pool.h" | 5 #include "base/threading/worker_pool.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/debug/leak_annotations.h" | 11 #include "base/debug/leak_annotations.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
12 #include "base/threading/post_task_and_reply_impl.h" | 14 #include "base/threading/post_task_and_reply_impl.h" |
13 #include "base/tracked_objects.h" | 15 #include "base/tracked_objects.h" |
14 | 16 |
15 namespace base { | 17 namespace base { |
16 | 18 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 TaskRunnerHolder() { | 95 TaskRunnerHolder() { |
94 taskrunners_[0] = new WorkerPoolTaskRunner(false); | 96 taskrunners_[0] = new WorkerPoolTaskRunner(false); |
95 taskrunners_[1] = new WorkerPoolTaskRunner(true); | 97 taskrunners_[1] = new WorkerPoolTaskRunner(true); |
96 } | 98 } |
97 scoped_refptr<TaskRunner> taskrunners_[2]; | 99 scoped_refptr<TaskRunner> taskrunners_[2]; |
98 }; | 100 }; |
99 | 101 |
100 } // namespace | 102 } // namespace |
101 | 103 |
102 bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here, | 104 bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here, |
103 const Closure& task, | 105 Closure task, |
104 const Closure& reply, | 106 Closure reply, |
105 bool task_is_slow) { | 107 bool task_is_slow) { |
106 // Do not report PostTaskAndReplyRelay leaks in tests. There's nothing we can | 108 // Do not report PostTaskAndReplyRelay leaks in tests. There's nothing we can |
107 // do about them because WorkerPool doesn't have a flushing API. | 109 // do about them because WorkerPool doesn't have a flushing API. |
108 // http://crbug.com/248513 | 110 // http://crbug.com/248513 |
109 // http://crbug.com/290897 | 111 // http://crbug.com/290897 |
110 // Note: this annotation does not cover tasks posted through a TaskRunner. | 112 // Note: this annotation does not cover tasks posted through a TaskRunner. |
111 ANNOTATE_SCOPED_MEMORY_LEAK; | 113 ANNOTATE_SCOPED_MEMORY_LEAK; |
112 return PostTaskAndReplyWorkerPool(task_is_slow).PostTaskAndReply( | 114 return PostTaskAndReplyWorkerPool(task_is_slow) |
113 from_here, task, reply); | 115 .PostTaskAndReply(from_here, std::move(task), std::move(reply)); |
114 } | 116 } |
115 | 117 |
116 // static | 118 // static |
117 const scoped_refptr<TaskRunner>& | 119 const scoped_refptr<TaskRunner>& |
118 WorkerPool::GetTaskRunner(bool tasks_are_slow) { | 120 WorkerPool::GetTaskRunner(bool tasks_are_slow) { |
119 static auto task_runner_holder = new TaskRunnerHolder(); | 121 static auto task_runner_holder = new TaskRunnerHolder(); |
120 return task_runner_holder->taskrunners_[tasks_are_slow]; | 122 return task_runner_holder->taskrunners_[tasks_are_slow]; |
121 } | 123 } |
122 | 124 |
123 } // namespace base | 125 } // namespace base |
OLD | NEW |