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

Unified Diff: base/message_loop_proxy.h

Issue 1837003: Created a stock implementation of the MessageLoopProxy interface than can be ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Rearranged header files Created 10 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gypi ('k') | base/message_loop_proxy_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop_proxy.h
===================================================================
--- base/message_loop_proxy.h (revision 46408)
+++ base/message_loop_proxy.h (working copy)
@@ -9,9 +9,15 @@
#include "base/ref_counted.h"
#include "base/task.h"
+namespace base {
+
+struct MessageLoopProxyTraits;
+
// This class provides a thread-safe refcounted interface to the Post* methods
// of a message loop. This class can outlive the target message loop.
-class MessageLoopProxy : public base::RefCountedThreadSafe<MessageLoopProxy> {
+class MessageLoopProxy
+ : public base::RefCountedThreadSafe<MessageLoopProxy,
+ MessageLoopProxyTraits> {
public:
// These are the same methods in message_loop.h, but are guaranteed to either
// get posted to the MessageLoop if it's still alive, or be deleted otherwise.
@@ -42,7 +48,27 @@
T* object) {
return PostNonNestableTask(from_here, new ReleaseTask<T>(object));
}
+
+ // Factory method for creating an implementation of MessageLoopProxy
+ // for the current thread.
+ static scoped_refptr<MessageLoopProxy> CreateForCurrentThread();
+
+ protected:
+ friend struct MessageLoopProxyTraits;
+ // Called when the proxy is about to be deleted. Subclasses can override this
+ // to provide deletion on specific threads.
+ virtual void OnDestruct() {
+ delete this;
+ }
};
+struct MessageLoopProxyTraits {
+ static void Destruct(MessageLoopProxy* proxy) {
+ proxy->OnDestruct();
+ }
+};
+
+} // namespace base
+
#endif // BASE_MESSAGE_LOOP_PROXY_H_
« no previous file with comments | « base/base.gypi ('k') | base/message_loop_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698