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

Side by Side Diff: base/memory/ref_counted.h

Issue 7210053: Implementation of PostTaskAndReply() in MessageLoopProxy and BrowserThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed something small Created 9 years, 5 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 | « no previous file | base/task.h » ('j') | base/task.h » ('J')
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 #ifndef BASE_MEMORY_REF_COUNTED_H_ 5 #ifndef BASE_MEMORY_REF_COUNTED_H_
6 #define BASE_MEMORY_REF_COUNTED_H_ 6 #define BASE_MEMORY_REF_COUNTED_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/atomic_ref_count.h" 9 #include "base/atomic_ref_count.h"
10 #include "base/base_api.h" 10 #include "base/base_api.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 struct DefaultRefCountedThreadSafeTraits { 109 struct DefaultRefCountedThreadSafeTraits {
110 static void Destruct(const T* x) { 110 static void Destruct(const T* x) {
111 // Delete through RefCountedThreadSafe to make child classes only need to be 111 // Delete through RefCountedThreadSafe to make child classes only need to be
112 // friend with RefCountedThreadSafe instead of this struct, which is an 112 // friend with RefCountedThreadSafe instead of this struct, which is an
113 // implementation detail. 113 // implementation detail.
114 RefCountedThreadSafe<T, 114 RefCountedThreadSafe<T,
115 DefaultRefCountedThreadSafeTraits>::DeleteInternal(x); 115 DefaultRefCountedThreadSafeTraits>::DeleteInternal(x);
116 } 116 }
117 }; 117 };
118 118
119 // Use as Traits parameter to RefCountedThreadSafe in order to override how the
120 // RefCountedThreadSafe subclass is destroyed.
121 //
122 // class MyFoo : public base::RefCountedThreadSafe<MyFoo, ManualDestruction> {
123 // ...
124 // private:
125 // friend class ManualDestruction;
126 // void DoManualDestruction() {
127 // delete this; // Or something else that's appropriate.
128 // }
129 // };
130 //
131 class ManualDestruction {
132 public:
133 template <class T>
134 static void Destruct(const T* x) {
135 T::DoManualDestruction(x);
136 }
137 };
138
119 // 139 //
120 // A thread-safe variant of RefCounted<T> 140 // A thread-safe variant of RefCounted<T>
121 // 141 //
122 // class MyFoo : public base::RefCountedThreadSafe<MyFoo> { 142 // class MyFoo : public base::RefCountedThreadSafe<MyFoo> {
123 // ... 143 // ...
124 // }; 144 // };
125 // 145 //
126 // If you're using the default trait, then you should add compile time 146 // If you're using the default trait, then you should add compile time
127 // asserts that no one else is deleting your object. i.e. 147 // asserts that no one else is deleting your object. i.e.
128 // private: 148 // private:
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 }; 310 };
291 311
292 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without 312 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without
293 // having to retype all the template arguments 313 // having to retype all the template arguments
294 template <typename T> 314 template <typename T>
295 scoped_refptr<T> make_scoped_refptr(T* t) { 315 scoped_refptr<T> make_scoped_refptr(T* t) {
296 return scoped_refptr<T>(t); 316 return scoped_refptr<T>(t);
297 } 317 }
298 318
299 #endif // BASE_MEMORY_REF_COUNTED_H_ 319 #endif // BASE_MEMORY_REF_COUNTED_H_
OLDNEW
« no previous file with comments | « no previous file | base/task.h » ('j') | base/task.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698