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

Side by Side Diff: base/message_loop_proxy.h

Issue 9034029: Revert 115997 - Replace MessageLoop::DeleteSoon implementation with one that uses base::Bind. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 12 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"
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/message_loop_helpers.h"
14 #include "base/task.h" 13 #include "base/task.h"
15 14
16 namespace tracked_objects { 15 namespace tracked_objects {
17 class Location; 16 class Location;
18 } // namespace tracked_objects 17 } // namespace tracked_objects
19 18
20 namespace base { 19 namespace base {
21 20
22 struct MessageLoopProxyTraits; 21 struct MessageLoopProxyTraits;
23 22
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // * The DataLoader object has no special thread safety. 114 // * The DataLoader object has no special thread safety.
116 // * The DataLoader object can be deleted while |task| is still running, 115 // * 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 116 // and the reply will cancel itself safely because it is bound to a
118 // WeakPtr<>. 117 // WeakPtr<>.
119 bool PostTaskAndReply(const tracked_objects::Location& from_here, 118 bool PostTaskAndReply(const tracked_objects::Location& from_here,
120 const Closure& task, 119 const Closure& task,
121 const Closure& reply); 120 const Closure& reply);
122 121
123 template <class T> 122 template <class T>
124 bool DeleteSoon(const tracked_objects::Location& from_here, 123 bool DeleteSoon(const tracked_objects::Location& from_here,
125 const T* object) { 124 T* object) {
126 return base::subtle::DeleteHelperInternal<T, bool>::DeleteOnMessageLoop( 125 return PostNonNestableTask(from_here, new DeleteTask<T>(object));
127 this, from_here, object);
128 } 126 }
129 template <class T> 127 template <class T>
130 bool ReleaseSoon(const tracked_objects::Location& from_here, 128 bool ReleaseSoon(const tracked_objects::Location& from_here,
131 T* object) { 129 T* object) {
132 return PostNonNestableTask(from_here, new ReleaseTask<T>(object)); 130 return PostNonNestableTask(from_here, new ReleaseTask<T>(object));
133 } 131 }
134 132
135 // Gets the MessageLoopProxy for the current message loop, creating one if 133 // Gets the MessageLoopProxy for the current message loop, creating one if
136 // needed. 134 // needed.
137 static scoped_refptr<MessageLoopProxy> current(); 135 static scoped_refptr<MessageLoopProxy> current();
138 136
139 protected: 137 protected:
140 template <class T, class R> friend class subtle::DeleteHelperInternal;
141 friend class RefCountedThreadSafe<MessageLoopProxy, MessageLoopProxyTraits>; 138 friend class RefCountedThreadSafe<MessageLoopProxy, MessageLoopProxyTraits>;
142 friend struct MessageLoopProxyTraits; 139 friend struct MessageLoopProxyTraits;
143 140
144 MessageLoopProxy(); 141 MessageLoopProxy();
145 virtual ~MessageLoopProxy(); 142 virtual ~MessageLoopProxy();
146 143
147 // Called when the proxy is about to be deleted. Subclasses can override this 144 // Called when the proxy is about to be deleted. Subclasses can override this
148 // to provide deletion on specific threads. 145 // to provide deletion on specific threads.
149 virtual void OnDestruct() const; 146 virtual void OnDestruct() const;
150
151 bool DeleteSoonInternal(const tracked_objects::Location& from_here,
152 void(*deleter)(const void*),
153 const void* object);
154 }; 147 };
155 148
156 struct MessageLoopProxyTraits { 149 struct MessageLoopProxyTraits {
157 static void Destruct(const MessageLoopProxy* proxy) { 150 static void Destruct(const MessageLoopProxy* proxy) {
158 proxy->OnDestruct(); 151 proxy->OnDestruct();
159 } 152 }
160 }; 153 };
161 154
162 } // namespace base 155 } // namespace base
163 156
164 #endif // BASE_MESSAGE_LOOP_PROXY_H_ 157 #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