Index: content/child/child_thread_impl.h |
diff --git a/content/child/child_thread_impl.h b/content/child/child_thread_impl.h |
index 03727d6b0477ef8fc529230e2c763b9d5e0a01b9..87a8e6ba8971dd1691c566ee93b1ee36af305b97 100644 |
--- a/content/child/child_thread_impl.h |
+++ b/content/child/child_thread_impl.h |
@@ -81,6 +81,12 @@ class CONTENT_EXPORT ChildThreadImpl |
bool Send(IPC::Message* msg) override; |
// ChildThread implementation: |
+ // Returns the task runner which should be used to post tasks to run on this |
+ // child thread. Note that this may be different from the underlying message |
+ // loop returned by message_loop(). For this reason, only use message_loop() |
+ // if you need to directly manipulate the underlying message loop, e.g., by |
+ // adding a task listener instead of just posting tasks for execution. |
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(); |
#if defined(OS_WIN) |
void PreCacheFont(const LOGFONT& log_font) override; |
void ReleaseCachedFonts() override; |
@@ -166,6 +172,7 @@ class CONTENT_EXPORT ChildThreadImpl |
return resource_message_filter_.get(); |
} |
+ // See note in GetTaskRunner(). |
base::MessageLoop* message_loop() const { return message_loop_; } |
// Returns the one child thread. Can only be called on the main thread. |
@@ -263,6 +270,7 @@ class CONTENT_EXPORT ChildThreadImpl |
bool on_channel_error_called_; |
base::MessageLoop* message_loop_; |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
scoped_ptr<FileSystemDispatcher> file_system_dispatcher_; |
@@ -314,6 +322,7 @@ struct ChildThreadImpl::Options { |
bool use_mojo_channel; |
bool in_browser_process; |
std::vector<IPC::MessageFilter*> startup_filters; |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner; |
private: |
Options(); |
@@ -327,6 +336,8 @@ class ChildThreadImpl::Options::Builder { |
Builder& UseMojoChannel(bool use_mojo_channel); |
Builder& WithChannelName(const std::string& channel_name); |
Builder& AddStartupFilter(IPC::MessageFilter* filter); |
+ Builder& WithTaskRunner( |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
Options Build(); |