OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TASK_H_ | 5 #ifndef BASE_TASK_H_ |
6 #define BASE_TASK_H_ | 6 #define BASE_TASK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 obj_->Release(); | 210 obj_->Release(); |
211 } | 211 } |
212 virtual void Cancel() { | 212 virtual void Cancel() { |
213 obj_ = NULL; | 213 obj_ = NULL; |
214 } | 214 } |
215 | 215 |
216 private: | 216 private: |
217 const T* obj_; | 217 const T* obj_; |
218 }; | 218 }; |
219 | 219 |
| 220 // Equivalents for use by base::Bind(). |
| 221 template<typename T> |
| 222 void DeletePointer(T* obj) { |
| 223 delete obj; |
| 224 } |
| 225 |
| 226 template<typename T> |
| 227 void ReleasePointer(T* obj) { |
| 228 obj->Release(); |
| 229 } |
| 230 |
220 // RunnableMethodTraits -------------------------------------------------------- | 231 // RunnableMethodTraits -------------------------------------------------------- |
221 // | 232 // |
222 // This traits-class is used by RunnableMethod to manage the lifetime of the | 233 // This traits-class is used by RunnableMethod to manage the lifetime of the |
223 // callee object. By default, it is assumed that the callee supports AddRef | 234 // callee object. By default, it is assumed that the callee supports AddRef |
224 // and Release methods. A particular class can specialize this template to | 235 // and Release methods. A particular class can specialize this template to |
225 // define other lifetime management. For example, if the callee is known to | 236 // define other lifetime management. For example, if the callee is known to |
226 // live longer than the RunnableMethod object, then a RunnableMethodTraits | 237 // live longer than the RunnableMethod object, then a RunnableMethodTraits |
227 // struct could be defined with empty RetainCallee and ReleaseCallee methods. | 238 // struct could be defined with empty RetainCallee and ReleaseCallee methods. |
228 // | 239 // |
229 // The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way | 240 // The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 Task* task_; | 609 Task* task_; |
599 bool* should_leak_task_; | 610 bool* should_leak_task_; |
600 static bool kTaskLeakingDefault; | 611 static bool kTaskLeakingDefault; |
601 }; | 612 }; |
602 | 613 |
603 } // namespace subtle | 614 } // namespace subtle |
604 | 615 |
605 } // namespace base | 616 } // namespace base |
606 | 617 |
607 #endif // BASE_TASK_H_ | 618 #endif // BASE_TASK_H_ |
OLD | NEW |