summaryrefslogtreecommitdiffstats
path: root/base/thread.h
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 18:34:24 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 18:34:24 +0000
commit656475d275524893e4e9b1f02469fe470721a14e (patch)
tree76198770e24f0bea147c10a50ae2a3bf9c7f7274 /base/thread.h
parent7e19edf7255b366b5e4b9b0bb77caf9842a37f1b (diff)
downloadchromium_src-656475d275524893e4e9b1f02469fe470721a14e.zip
chromium_src-656475d275524893e4e9b1f02469fe470721a14e.tar.gz
chromium_src-656475d275524893e4e9b1f02469fe470721a14e.tar.bz2
Created a stock implementation of the MessageLoopProxy interface than can be used to create an implementation that targets the current thread's message loop.
BUG=None TEST=Unit tests provided. Review URL: http://codereview.chromium.org/1837003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread.h')
-rw-r--r--base/thread.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/base/thread.h b/base/thread.h
index 88bff7b..b5a87eb 100644
--- a/base/thread.h
+++ b/base/thread.h
@@ -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 @@ class Thread : PlatformThread::Delegate {
//
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 @@ class Thread : PlatformThread::Delegate {
// 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_;