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

Unified Diff: base/message_loop.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: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop.h
diff --git a/base/message_loop.h b/base/message_loop.h
index 28ccd4eefa825460b9c3e20b50dc52d0e7c9d49b..80c46dcf79214e50eb6b18b1cc05dced85771326 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -44,6 +44,14 @@
namespace base {
class Histogram;
+
+template <class T>
awong 2011/12/28 23:24:19 This needs a comment explaining why we need this.
dcheng 2011/12/28 23:34:20 Done. As discussed, made DoDelete private as well
+class DeleteHelper {
+ public:
+ static void DoDelete(const void* object) {
+ delete reinterpret_cast<const T*>(object);
+ }
+};
}
// A MessageLoop is used to process events for a particular thread. There is
@@ -208,7 +216,7 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate {
// from RefCountedThreadSafe<T>!
template <class T>
void DeleteSoon(const tracked_objects::Location& from_here, const T* object) {
- PostNonNestableTask(from_here, new DeleteTask<T>(object));
+ DeleteSoonInternal(from_here, &base::DeleteHelper<T>::DoDelete, object);
}
// A variant on PostTask that releases the given reference counted object
@@ -532,6 +540,10 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate {
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
private:
+ void DeleteSoonInternal(const tracked_objects::Location& from_here,
+ void(*deleter)(const void*),
+ const void* object);
+
DISALLOW_COPY_AND_ASSIGN(MessageLoop);
};
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698