Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: base/task.h

Issue 9022034: Convert various ReleaseSoon methods to use base::Bind() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/message_loop_proxy.cc ('k') | chrome/browser/sync/glue/http_bridge_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 delete obj_; 217 delete obj_;
218 } 218 }
219 virtual void Cancel() { 219 virtual void Cancel() {
220 obj_ = NULL; 220 obj_ = NULL;
221 } 221 }
222 222
223 private: 223 private:
224 const T* obj_; 224 const T* obj_;
225 }; 225 };
226 226
227 // Task to Release() an object
228 template<class T>
229 class ReleaseTask : public CancelableTask {
230 public:
231 explicit ReleaseTask(const T* obj) : obj_(obj) {
232 }
233 virtual void Run() {
234 if (obj_)
235 obj_->Release();
236 }
237 virtual void Cancel() {
238 obj_ = NULL;
239 }
240
241 private:
242 const T* obj_;
243 };
244
245 // Equivalents for use by base::Bind(). 227 // Equivalents for use by base::Bind().
246 template<typename T> 228 template<typename T>
247 void DeletePointer(T* obj) { 229 void DeletePointer(T* obj) {
248 delete obj; 230 delete obj;
249 } 231 }
250 232
251 template<typename T>
252 void ReleasePointer(T* obj) {
253 obj->Release();
254 }
255
256 // RunnableMethodTraits -------------------------------------------------------- 233 // RunnableMethodTraits --------------------------------------------------------
257 // 234 //
258 // This traits-class is used by RunnableMethod to manage the lifetime of the 235 // This traits-class is used by RunnableMethod to manage the lifetime of the
259 // callee object. By default, it is assumed that the callee supports AddRef 236 // callee object. By default, it is assumed that the callee supports AddRef
260 // and Release methods. A particular class can specialize this template to 237 // and Release methods. A particular class can specialize this template to
261 // define other lifetime management. For example, if the callee is known to 238 // define other lifetime management. For example, if the callee is known to
262 // live longer than the RunnableMethod object, then a RunnableMethodTraits 239 // live longer than the RunnableMethod object, then a RunnableMethodTraits
263 // struct could be defined with empty RetainCallee and ReleaseCallee methods. 240 // struct could be defined with empty RetainCallee and ReleaseCallee methods.
264 // 241 //
265 // The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way 242 // The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 Task* task_; 616 Task* task_;
640 bool* should_leak_task_; 617 bool* should_leak_task_;
641 static bool kTaskLeakingDefault; 618 static bool kTaskLeakingDefault;
642 }; 619 };
643 620
644 } // namespace subtle 621 } // namespace subtle
645 622
646 } // namespace base 623 } // namespace base
647 624
648 #endif // BASE_TASK_H_ 625 #endif // BASE_TASK_H_
OLDNEW
« no previous file with comments | « base/message_loop_proxy.cc ('k') | chrome/browser/sync/glue/http_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698