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

Side by Side Diff: base/message_loop_proxy.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_helpers.h ('k') | base/message_loop_proxy.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 #ifndef BASE_MESSAGE_LOOP_PROXY_H_ 5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_
6 #define BASE_MESSAGE_LOOP_PROXY_H_ 6 #define BASE_MESSAGE_LOOP_PROXY_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_export.h" 9 #include "base/base_export.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // * The DataLoader object can be deleted while |task| is still running, 116 // * The DataLoader object can be deleted while |task| is still running,
117 // and the reply will cancel itself safely because it is bound to a 117 // and the reply will cancel itself safely because it is bound to a
118 // WeakPtr<>. 118 // WeakPtr<>.
119 bool PostTaskAndReply(const tracked_objects::Location& from_here, 119 bool PostTaskAndReply(const tracked_objects::Location& from_here,
120 const Closure& task, 120 const Closure& task,
121 const Closure& reply); 121 const Closure& reply);
122 122
123 template <class T> 123 template <class T>
124 bool DeleteSoon(const tracked_objects::Location& from_here, 124 bool DeleteSoon(const tracked_objects::Location& from_here,
125 const T* object) { 125 const T* object) {
126 return base::subtle::DeleteHelperInternal<T, bool>::DeleteOnMessageLoop( 126 return subtle::DeleteHelperInternal<T, bool>::DeleteOnMessageLoop(
127 this, from_here, object); 127 this, from_here, object);
128 } 128 }
129 template <class T> 129 template <class T>
130 bool ReleaseSoon(const tracked_objects::Location& from_here, 130 bool ReleaseSoon(const tracked_objects::Location& from_here,
131 T* object) { 131 T* object) {
132 return PostNonNestableTask(from_here, new ReleaseTask<T>(object)); 132 return subtle::ReleaseHelperInternal<T, bool>::ReleaseOnMessageLoop(
133 this, from_here, object);
133 } 134 }
134 135
135 // Gets the MessageLoopProxy for the current message loop, creating one if 136 // Gets the MessageLoopProxy for the current message loop, creating one if
136 // needed. 137 // needed.
137 static scoped_refptr<MessageLoopProxy> current(); 138 static scoped_refptr<MessageLoopProxy> current();
138 139
139 protected: 140 protected:
140 template <class T, class R> friend class subtle::DeleteHelperInternal;
141 friend class RefCountedThreadSafe<MessageLoopProxy, MessageLoopProxyTraits>; 141 friend class RefCountedThreadSafe<MessageLoopProxy, MessageLoopProxyTraits>;
142 friend struct MessageLoopProxyTraits; 142 friend struct MessageLoopProxyTraits;
143 143
144 MessageLoopProxy(); 144 MessageLoopProxy();
145 virtual ~MessageLoopProxy(); 145 virtual ~MessageLoopProxy();
146 146
147 // Called when the proxy is about to be deleted. Subclasses can override this 147 // Called when the proxy is about to be deleted. Subclasses can override this
148 // to provide deletion on specific threads. 148 // to provide deletion on specific threads.
149 virtual void OnDestruct() const; 149 virtual void OnDestruct() const;
150 150
151 private:
152 template <class T, class R> friend class subtle::DeleteHelperInternal;
153 template <class T, class R> friend class subtle::ReleaseHelperInternal;
151 bool DeleteSoonInternal(const tracked_objects::Location& from_here, 154 bool DeleteSoonInternal(const tracked_objects::Location& from_here,
152 void(*deleter)(const void*), 155 void(*deleter)(const void*),
153 const void* object); 156 const void* object);
157 bool ReleaseSoonInternal(const tracked_objects::Location& from_here,
158 void(*releaser)(const void*),
159 const void* object);
154 }; 160 };
155 161
156 struct MessageLoopProxyTraits { 162 struct MessageLoopProxyTraits {
157 static void Destruct(const MessageLoopProxy* proxy) { 163 static void Destruct(const MessageLoopProxy* proxy) {
158 proxy->OnDestruct(); 164 proxy->OnDestruct();
159 } 165 }
160 }; 166 };
161 167
162 } // namespace base 168 } // namespace base
163 169
164 #endif // BASE_MESSAGE_LOOP_PROXY_H_ 170 #endif // BASE_MESSAGE_LOOP_PROXY_H_
OLDNEW
« no previous file with comments | « base/message_loop_helpers.h ('k') | base/message_loop_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698