Chromium Code Reviews| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 TaskRunnerHolder() { | 93 TaskRunnerHolder() { |
| 94 taskrunners_[0] = new WorkerPoolTaskRunner(false); | 94 taskrunners_[0] = new WorkerPoolTaskRunner(false); |
| 95 taskrunners_[1] = new WorkerPoolTaskRunner(true); | 95 taskrunners_[1] = new WorkerPoolTaskRunner(true); |
| 96 } | 96 } |
| 97 scoped_refptr<TaskRunner> taskrunners_[2]; | 97 scoped_refptr<TaskRunner> taskrunners_[2]; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace | 100 } // namespace |
| 101 | 101 |
| 102 bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here, | 102 bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here, |
| 103 const Closure& task, | 103 Closure task, |
| 104 const Closure& reply, | 104 Closure reply, |
| 105 bool task_is_slow) { | 105 bool task_is_slow) { |
| 106 // Do not report PostTaskAndReplyRelay leaks in tests. There's nothing we can | 106 // Do not report PostTaskAndReplyRelay leaks in tests. There's nothing we can |
| 107 // do about them because WorkerPool doesn't have a flushing API. | 107 // do about them because WorkerPool doesn't have a flushing API. |
| 108 // http://crbug.com/248513 | 108 // http://crbug.com/248513 |
| 109 // http://crbug.com/290897 | 109 // http://crbug.com/290897 |
| 110 // Note: this annotation does not cover tasks posted through a TaskRunner. | 110 // Note: this annotation does not cover tasks posted through a TaskRunner. |
| 111 ANNOTATE_SCOPED_MEMORY_LEAK; | 111 ANNOTATE_SCOPED_MEMORY_LEAK; |
| 112 return PostTaskAndReplyWorkerPool(task_is_slow).PostTaskAndReply( | 112 return PostTaskAndReplyWorkerPool(task_is_slow) |
| 113 from_here, task, reply); | 113 .PostTaskAndReply(from_here, std::move(task), std::move(reply)); |
|
gab
2017/02/07 15:46:08
#include <utility>
tzik
2017/02/08 01:39:32
Done.
| |
| 114 } | 114 } |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 const scoped_refptr<TaskRunner>& | 117 const scoped_refptr<TaskRunner>& |
| 118 WorkerPool::GetTaskRunner(bool tasks_are_slow) { | 118 WorkerPool::GetTaskRunner(bool tasks_are_slow) { |
| 119 static auto task_runner_holder = new TaskRunnerHolder(); | 119 static auto task_runner_holder = new TaskRunnerHolder(); |
| 120 return task_runner_holder->taskrunners_[tasks_are_slow]; | 120 return task_runner_holder->taskrunners_[tasks_are_slow]; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace base | 123 } // namespace base |
| OLD | NEW |