| Index: remoting/host/chromoting_host_context.cc
|
| diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
|
| index 480de732922a9282de5dac6a984b884150f6f2ec..4e8640ee97838d64e85d3e7b854e235af31f0f02 100644
|
| --- a/remoting/host/chromoting_host_context.cc
|
| +++ b/remoting/host/chromoting_host_context.cc
|
| @@ -8,12 +8,13 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/threading/thread.h"
|
| +#include "remoting/base/auto_thread_task_runner.h"
|
| #include "remoting/host/url_request_context.h"
|
|
|
| namespace remoting {
|
|
|
| ChromotingHostContext::ChromotingHostContext(
|
| - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
|
| + scoped_refptr<AutoThreadTaskRunner> ui_task_runner)
|
| : network_thread_("ChromotingNetworkThread"),
|
| capture_thread_("ChromotingCaptureThread"),
|
| encode_thread_("ChromotingEncodeThread"),
|
| @@ -36,26 +37,55 @@ bool ChromotingHostContext::Start() {
|
| if (!started)
|
| return false;
|
|
|
| + // Wrap worker threads with |AutoThreadTaskRunner| and have them reference
|
| + // the main thread via |ui_task_runner_|, to ensure that it remain active to
|
| + // Stop() them when no references remain.
|
| + network_task_runner_ =
|
| + new AutoThreadTaskRunner(network_thread_.message_loop_proxy(),
|
| + ui_task_runner_);
|
| + capture_task_runner_ =
|
| + new AutoThreadTaskRunner(capture_thread_.message_loop_proxy(),
|
| + ui_task_runner_);
|
| + encode_task_runner_ =
|
| + new AutoThreadTaskRunner(encode_thread_.message_loop_proxy(),
|
| + ui_task_runner_);
|
| + desktop_task_runner_ =
|
| + new AutoThreadTaskRunner(desktop_thread_.message_loop_proxy(),
|
| + ui_task_runner_);
|
| + file_task_runner_ =
|
| + new AutoThreadTaskRunner(file_thread_.message_loop_proxy(),
|
| + ui_task_runner_);
|
| +
|
| url_request_context_getter_ = new URLRequestContextGetter(
|
| ui_task_runner(), network_task_runner(),
|
| static_cast<MessageLoopForIO*>(file_thread_.message_loop()));
|
| return true;
|
| }
|
|
|
| +void ChromotingHostContext::ReleaseTaskRunners() {
|
| + url_request_context_getter_ = NULL;
|
| + network_task_runner_ = NULL;
|
| + capture_task_runner_ = NULL;
|
| + encode_task_runner_ = NULL;
|
| + desktop_task_runner_ = NULL;
|
| + file_task_runner_ = NULL;
|
| + ui_task_runner_ = NULL;
|
| +}
|
| +
|
| base::SingleThreadTaskRunner* ChromotingHostContext::capture_task_runner() {
|
| - return capture_thread_.message_loop_proxy();
|
| + return capture_task_runner_;
|
| }
|
|
|
| base::SingleThreadTaskRunner* ChromotingHostContext::encode_task_runner() {
|
| - return encode_thread_.message_loop_proxy();
|
| + return encode_task_runner_;
|
| }
|
|
|
| base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() {
|
| - return network_thread_.message_loop_proxy();
|
| + return network_task_runner_;
|
| }
|
|
|
| base::SingleThreadTaskRunner* ChromotingHostContext::desktop_task_runner() {
|
| - return desktop_thread_.message_loop_proxy();
|
| + return desktop_task_runner_;
|
| }
|
|
|
| base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() {
|
| @@ -63,7 +93,7 @@ base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() {
|
| }
|
|
|
| base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() {
|
| - return file_thread_.message_loop_proxy();
|
| + return file_task_runner_;
|
| }
|
|
|
| const scoped_refptr<net::URLRequestContextGetter>&
|
|
|