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

Side by Side Diff: base/message_loop_proxy.h

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