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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 scoped_refptr<TaskRunner> taskrunners_[2]; | 98 scoped_refptr<TaskRunner> taskrunners_[2]; |
99 }; | 99 }; |
100 | 100 |
101 base::LazyInstance<TaskRunnerHolder>::Leaky | 101 base::LazyInstance<TaskRunnerHolder>::Leaky |
102 g_taskrunners = LAZY_INSTANCE_INITIALIZER; | 102 g_taskrunners = LAZY_INSTANCE_INITIALIZER; |
103 | 103 |
104 } // namespace | 104 } // namespace |
105 | 105 |
106 bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here, | 106 bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here, |
107 const Closure& task, | 107 Closure task, |
108 const Closure& reply, | 108 Closure reply, |
109 bool task_is_slow) { | 109 bool task_is_slow) { |
110 // Do not report PostTaskAndReplyRelay leaks in tests. There's nothing we can | 110 // Do not report PostTaskAndReplyRelay leaks in tests. There's nothing we can |
111 // do about them because WorkerPool doesn't have a flushing API. | 111 // do about them because WorkerPool doesn't have a flushing API. |
112 // http://crbug.com/248513 | 112 // http://crbug.com/248513 |
113 // http://crbug.com/290897 | 113 // http://crbug.com/290897 |
114 // Note: this annotation does not cover tasks posted through a TaskRunner. | 114 // Note: this annotation does not cover tasks posted through a TaskRunner. |
115 ANNOTATE_SCOPED_MEMORY_LEAK; | 115 ANNOTATE_SCOPED_MEMORY_LEAK; |
116 return PostTaskAndReplyWorkerPool(task_is_slow).PostTaskAndReply( | 116 return PostTaskAndReplyWorkerPool(task_is_slow) |
117 from_here, task, reply); | 117 .PostTaskAndReply(from_here, std::move(task), std::move(reply)); |
118 } | 118 } |
119 | 119 |
120 // static | 120 // static |
121 const scoped_refptr<TaskRunner>& | 121 const scoped_refptr<TaskRunner>& |
122 WorkerPool::GetTaskRunner(bool tasks_are_slow) { | 122 WorkerPool::GetTaskRunner(bool tasks_are_slow) { |
123 return g_taskrunners.Get().taskrunners_[tasks_are_slow]; | 123 return g_taskrunners.Get().taskrunners_[tasks_are_slow]; |
124 } | 124 } |
125 | 125 |
126 } // namespace base | 126 } // namespace base |
OLD | NEW |