Index: base/thread.h |
=================================================================== |
--- base/thread.h (revision 46408) |
+++ base/thread.h (working copy) |
@@ -8,6 +8,7 @@ |
#include <string> |
#include "base/message_loop.h" |
+#include "base/message_loop_proxy.h" |
#include "base/platform_thread.h" |
namespace base { |
@@ -104,6 +105,16 @@ |
// |
MessageLoop* message_loop() const { return message_loop_; } |
+ // Returns a MessageLoopProxy for this thread. Use the MessageLoopProxy's |
+ // PostTask methods to execute code on the thread. This only returns |
+ // non-null after a successful call to Start. After Stop has been called, |
+ // this will return NULL. Callers can hold on to this even after the thread |
+ // is gone. |
+ // TODO(sanjeevr): Look into merging MessageLoop and MessageLoopProxy. |
+ scoped_refptr<MessageLoopProxy> message_loop_proxy() { |
+ return message_loop_proxy_; |
+ } |
+ |
// Set the name of this thread (for display in debugger too). |
const std::string &thread_name() { return name_; } |
@@ -162,6 +173,10 @@ |
// by the created thread. |
MessageLoop* message_loop_; |
+ // A MessageLoopProxy implementation that targets this thread. This can |
+ // outlive the thread. |
+ scoped_refptr<MessageLoopProxy> message_loop_proxy_; |
+ |
// Our thread's ID. |
PlatformThreadId thread_id_; |