diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-29 23:13:03 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-29 23:13:03 +0000 |
commit | 4abe0615215de43dd1fe9bf0d31eb62f006056f7 (patch) | |
tree | 5ef288113edf0a1efac511e5ef9d51771f03e269 /base | |
parent | 23b59d264f46c72cd52407f7a028b0eea32b78d6 (diff) | |
download | chromium_src-4abe0615215de43dd1fe9bf0d31eb62f006056f7.zip chromium_src-4abe0615215de43dd1fe9bf0d31eb62f006056f7.tar.gz chromium_src-4abe0615215de43dd1fe9bf0d31eb62f006056f7.tar.bz2 |
Revert 115997 - Replace MessageLoop::DeleteSoon implementation with one that uses base::Bind.
BUG=none
TEST=none
TBR=willchan,brettw,tony
Review URL: http://codereview.chromium.org/9004051
TBR=dcheng@chromium.org
Review URL: http://codereview.chromium.org/9034029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/message_loop.cc | 6 | ||||
-rw-r--r-- | base/message_loop.h | 10 | ||||
-rw-r--r-- | base/message_loop_helpers.h | 73 | ||||
-rw-r--r-- | base/message_loop_proxy.cc | 7 | ||||
-rw-r--r-- | base/message_loop_proxy.h | 11 |
5 files changed, 3 insertions, 104 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc index cf6d89b..f272a83 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -741,12 +741,6 @@ bool MessageLoop::DoIdleWork() { return false; } -void MessageLoop::DeleteSoonInternal(const tracked_objects::Location& from_here, - void(*deleter)(const void*), - const void* object) { - PostNonNestableTask(from_here, base::Bind(deleter, object)); -} - //------------------------------------------------------------------------------ // MessageLoop::AutoRunState diff --git a/base/message_loop.h b/base/message_loop.h index 02f4840..28ccd4e 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -14,7 +14,6 @@ #include "base/callback_forward.h" #include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/message_loop_helpers.h" #include "base/message_loop_proxy.h" #include "base/message_pump.h" #include "base/observer_list.h" @@ -209,8 +208,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) { - base::subtle::DeleteHelperInternal<T, void>::DeleteOnMessageLoop( - this, from_here, object); + PostNonNestableTask(from_here, new DeleteTask<T>(object)); } // A variant on PostTask that releases the given reference counted object @@ -534,12 +532,6 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate { scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; private: - template <class T, class R> friend class base::subtle::DeleteHelperInternal; - - void DeleteSoonInternal(const tracked_objects::Location& from_here, - void(*deleter)(const void*), - const void* object); - DISALLOW_COPY_AND_ASSIGN(MessageLoop); }; diff --git a/base/message_loop_helpers.h b/base/message_loop_helpers.h deleted file mode 100644 index 151128c..0000000 --- a/base/message_loop_helpers.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_MESSAGE_LOOP_HELPERS_H_ -#define BASE_MESSAGE_LOOP_HELPERS_H_ -#pragma once - -#include "base/basictypes.h" - -namespace tracked_objects { -class Location; -} - -namespace base { - -namespace subtle { -template <class T, class R> class DeleteHelperInternal; -} - -// This is a template helper which uses a function indirection to erase T from -// the function signature while still remembering it so we can call the correct -// destructor. We use this trick so we don't need to include bind.h in a -// header file. We also embed the function in a class to make it easier for -// users of DeleteSoon to declare the helper as a friend. -template <class T> -class DeleteHelper { - private: - // TODO(dcheng): Move the return type back to a function template parameter. - template <class T2, class R> friend class subtle::DeleteHelperInternal; - - static void DoDelete(const void* object) { - delete reinterpret_cast<const T*>(object); - } - - DISALLOW_COPY_AND_ASSIGN(DeleteHelper); -}; - -namespace subtle { - -// An internal MessageLoop-like class helper for DeleteHelper. We don't want to -// expose DoDelete directly since the void* argument makes it possible to pass -// an object of the wrong type to delete. Instead, we force callers to go -// through DeleteHelperInternal for type safety. MessageLoop-like classes which -// expose a DeleteSoon method should friend this class and implement a -// DeleteSoonInternal method with the following signature: -// bool(const tracked_objects::Location&, -// void(*deleter)(const void*), -// void* object) -// An implementation of DeleteSoonInternal should simply create a base::Closure -// from (deleter, object) and return the result of posting the task. -template <class T, class ReturnType> -class DeleteHelperInternal { - public: - template <class MessageLoopType> - static ReturnType DeleteOnMessageLoop( - MessageLoopType* message_loop, - const tracked_objects::Location& from_here, - const T* object) { - return message_loop->DeleteSoonInternal(from_here, - &DeleteHelper<T>::DoDelete, - object); - } - - private: - DISALLOW_COPY_AND_ASSIGN(DeleteHelperInternal); -}; - -} // namespace subtle - -} // namespace base - -#endif // BASE_MESSAGE_LOOP_HELPERS_H_ diff --git a/base/message_loop_proxy.cc b/base/message_loop_proxy.cc index 63837d7..f9b4ad8 100644 --- a/base/message_loop_proxy.cc +++ b/base/message_loop_proxy.cc @@ -49,11 +49,4 @@ void MessageLoopProxy::OnDestruct() const { delete this; } -bool MessageLoopProxy::DeleteSoonInternal( - const tracked_objects::Location& from_here, - void(*deleter)(const void*), - const void* object) { - return PostNonNestableTask(from_here, base::Bind(deleter, object)); -} - } // namespace base diff --git a/base/message_loop_proxy.h b/base/message_loop_proxy.h index 738f39f..aac11b9 100644 --- a/base/message_loop_proxy.h +++ b/base/message_loop_proxy.h @@ -10,7 +10,6 @@ #include "base/basictypes.h" #include "base/callback_forward.h" #include "base/memory/ref_counted.h" -#include "base/message_loop_helpers.h" #include "base/task.h" namespace tracked_objects { @@ -122,9 +121,8 @@ class BASE_EXPORT MessageLoopProxy template <class T> bool DeleteSoon(const tracked_objects::Location& from_here, - const T* object) { - return base::subtle::DeleteHelperInternal<T, bool>::DeleteOnMessageLoop( - this, from_here, object); + T* object) { + return PostNonNestableTask(from_here, new DeleteTask<T>(object)); } template <class T> bool ReleaseSoon(const tracked_objects::Location& from_here, @@ -137,7 +135,6 @@ class BASE_EXPORT MessageLoopProxy static scoped_refptr<MessageLoopProxy> current(); protected: - template <class T, class R> friend class subtle::DeleteHelperInternal; friend class RefCountedThreadSafe<MessageLoopProxy, MessageLoopProxyTraits>; friend struct MessageLoopProxyTraits; @@ -147,10 +144,6 @@ class BASE_EXPORT MessageLoopProxy // Called when the proxy is about to be deleted. Subclasses can override this // to provide deletion on specific threads. virtual void OnDestruct() const; - - bool DeleteSoonInternal(const tracked_objects::Location& from_here, - void(*deleter)(const void*), - const void* object); }; struct MessageLoopProxyTraits { |