Index: base/message_loop/message_loop.h |
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h |
index f2f89d0574dc05f70102cc592fa0250860e13031..fbb8309c203275768188b499ef5d5e8102a751e9 100644 |
--- a/base/message_loop/message_loop.h |
+++ b/base/message_loop/message_loop.h |
@@ -16,8 +16,7 @@ |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop/incoming_task_queue.h" |
-#include "base/message_loop/message_loop_proxy.h" |
-#include "base/message_loop/message_loop_proxy_impl.h" |
+#include "base/message_loop/message_loop_task_runner.h" |
#include "base/message_loop/message_pump.h" |
#include "base/message_loop/timer_slack.h" |
#include "base/observer_list.h" |
@@ -296,20 +295,18 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
} |
const std::string& thread_name() const { return thread_name_; } |
- // Gets the message loop proxy associated with this message loop. |
- // |
- // NOTE: Deprecated; prefer task_runner() and the TaskRunner interfaces |
- scoped_refptr<MessageLoopProxy> message_loop_proxy() { |
- return message_loop_proxy_; |
- } |
- |
// Gets the TaskRunner associated with this message loop. |
- // TODO(skyostil): Change this to return a const reference to a refptr |
- // once the internal type matches what is being returned (crbug.com/465354). |
- scoped_refptr<SingleThreadTaskRunner> task_runner() { |
- return message_loop_proxy_; |
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner() { |
+ return task_runner_; |
} |
+ // Sets a new TaskRunner for this message loop. The message loop must already |
+ // have been bound to a thread prior to this call, and the task runner must |
+ // belong to that thread. Note that changing the task runner will also affect |
+ // the ThreadTaskRunnerHandle for the target thread. Must be called on the |
+ // thread to which the message loop is bound. |
+ void SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner); |
+ |
// Enables or disables the recursive task processing. This happens in the case |
// of recursive message loops. Some unwanted message loop may occurs when |
// using common controls or printer functions. By default, recursive task |
@@ -425,7 +422,7 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
// thread the message loop runs on, before calling Run(). |
// Before BindToCurrentThread() is called only Post*Task() functions can |
// be called on the message loop. |
- scoped_ptr<MessageLoop> CreateUnbound( |
+ static scoped_ptr<MessageLoop> CreateUnbound( |
Type type, |
MessagePumpFactoryCallback pump_factory); |
@@ -436,6 +433,10 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
// Configure various members and bind this message loop to the current thread. |
void BindToCurrentThread(); |
+ // Sets the ThreadTaskRunnerHandle for the current thread to point to the |
+ // task runner for this message loop. |
+ void SetThreadTaskRunnerHandle(); |
+ |
// Invokes the actual run loop using the message pump. |
void RunHandler(); |
@@ -531,8 +532,11 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; |
- // The message loop proxy associated with this message loop. |
- scoped_refptr<internal::MessageLoopProxyImpl> message_loop_proxy_; |
+ // A task runner which we haven't bound to a thread yet. |
+ scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_; |
+ |
+ // The task runner associated with this message loop. |
+ scoped_refptr<SingleThreadTaskRunner> task_runner_; |
scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; |
template <class T, class R> friend class base::subtle::DeleteHelperInternal; |