| 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 // ============================================================================ | 5 // ============================================================================ |
| 6 // **************************************************************************** | 6 // **************************************************************************** |
| 7 // * THIS HEADER IS DEPRECATED, SEE base/callback.h FOR NEW IMPLEMENTATION * | 7 // * THIS HEADER IS DEPRECATED, SEE base/callback.h FOR NEW IMPLEMENTATION * |
| 8 // **************************************************************************** | 8 // **************************************************************************** |
| 9 // ============================================================================ | 9 // ============================================================================ |
| 10 // ============================================================================ | 10 // ============================================================================ |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 Method meth_; | 198 Method meth_; |
| 199 Params params_; | 199 Params params_; |
| 200 | 200 |
| 201 DISALLOW_COPY_AND_ASSIGN(RunnableMethod); | 201 DISALLOW_COPY_AND_ASSIGN(RunnableMethod); |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 base::WeakPtrFactory<T> weak_factory_; | 205 base::WeakPtrFactory<T> weak_factory_; |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 // General task implementations ------------------------------------------------ | 208 // Delete helper for use with base::Bind(). |
| 209 | |
| 210 // Task to delete an object | |
| 211 template<class T> | |
| 212 class DeleteTask : public CancelableTask { | |
| 213 public: | |
| 214 explicit DeleteTask(const T* obj) : obj_(obj) { | |
| 215 } | |
| 216 virtual void Run() { | |
| 217 delete obj_; | |
| 218 } | |
| 219 virtual void Cancel() { | |
| 220 obj_ = NULL; | |
| 221 } | |
| 222 | |
| 223 private: | |
| 224 const T* obj_; | |
| 225 }; | |
| 226 | |
| 227 // Equivalents for use by base::Bind(). | |
| 228 template<typename T> | 209 template<typename T> |
| 229 void DeletePointer(T* obj) { | 210 void DeletePointer(T* obj) { |
| 230 delete obj; | 211 delete obj; |
| 231 } | 212 } |
| 232 | 213 |
| 233 // RunnableMethodTraits -------------------------------------------------------- | 214 // RunnableMethodTraits -------------------------------------------------------- |
| 234 // | 215 // |
| 235 // This traits-class is used by RunnableMethod to manage the lifetime of the | 216 // This traits-class is used by RunnableMethod to manage the lifetime of the |
| 236 // callee object. By default, it is assumed that the callee supports AddRef | 217 // callee object. By default, it is assumed that the callee supports AddRef |
| 237 // and Release methods. A particular class can specialize this template to | 218 // and Release methods. A particular class can specialize this template to |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 Task* task_; | 597 Task* task_; |
| 617 bool* should_leak_task_; | 598 bool* should_leak_task_; |
| 618 static bool kTaskLeakingDefault; | 599 static bool kTaskLeakingDefault; |
| 619 }; | 600 }; |
| 620 | 601 |
| 621 } // namespace subtle | 602 } // namespace subtle |
| 622 | 603 |
| 623 } // namespace base | 604 } // namespace base |
| 624 | 605 |
| 625 #endif // BASE_TASK_H_ | 606 #endif // BASE_TASK_H_ |
| OLD | NEW |