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 #ifndef BASE_SEQUENCED_TASK_RUNNER_H_ | 5 #ifndef BASE_SEQUENCED_TASK_RUNNER_H_ |
6 #define BASE_SEQUENCED_TASK_RUNNER_H_ | 6 #define BASE_SEQUENCED_TASK_RUNNER_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/sequenced_task_runner_helpers.h" | 9 #include "base/sequenced_task_runner_helpers.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 struct BASE_EXPORT OnTaskRunnerDeleter { | 157 struct BASE_EXPORT OnTaskRunnerDeleter { |
158 explicit OnTaskRunnerDeleter(scoped_refptr<SequencedTaskRunner> task_runner); | 158 explicit OnTaskRunnerDeleter(scoped_refptr<SequencedTaskRunner> task_runner); |
159 ~OnTaskRunnerDeleter(); | 159 ~OnTaskRunnerDeleter(); |
160 | 160 |
161 OnTaskRunnerDeleter(OnTaskRunnerDeleter&&); | 161 OnTaskRunnerDeleter(OnTaskRunnerDeleter&&); |
162 OnTaskRunnerDeleter& operator=(OnTaskRunnerDeleter&&); | 162 OnTaskRunnerDeleter& operator=(OnTaskRunnerDeleter&&); |
163 | 163 |
164 template <typename T> | 164 template <typename T> |
165 void operator()(const T* ptr) { | 165 void operator()(const T* ptr) { |
166 if (task_runner_->RunsTasksOnCurrentThread()) | 166 if (ptr) |
167 delete ptr; | |
168 else if (ptr) | |
169 task_runner_->DeleteSoon(FROM_HERE, ptr); | 167 task_runner_->DeleteSoon(FROM_HERE, ptr); |
170 } | 168 } |
171 | 169 |
172 scoped_refptr<SequencedTaskRunner> task_runner_; | 170 scoped_refptr<SequencedTaskRunner> task_runner_; |
173 }; | 171 }; |
174 | 172 |
175 } // namespace base | 173 } // namespace base |
176 | 174 |
177 #endif // BASE_SEQUENCED_TASK_RUNNER_H_ | 175 #endif // BASE_SEQUENCED_TASK_RUNNER_H_ |
OLD | NEW |