| Index: remoting/host/chromoting_host_context.cc
|
| diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
|
| index de99a1f0f5fe17f7c336702a8492cbca41443466..c90f5b0304dad1cd8c001f38ded8aa7826f19d83 100644
|
| --- a/remoting/host/chromoting_host_context.cc
|
| +++ b/remoting/host/chromoting_host_context.cc
|
| @@ -7,15 +7,27 @@
|
| #include <string>
|
|
|
| #include "base/bind.h"
|
| +#include "base/synchronization/waitable_event.h"
|
| #include "base/threading/thread.h"
|
| #include "remoting/jingle_glue/jingle_thread.h"
|
|
|
| namespace remoting {
|
|
|
| -ChromotingHostContext::ChromotingHostContext()
|
| +namespace {
|
| +void InitializeMessageLoopProxy(
|
| + scoped_refptr<base::MessageLoopProxy>* proxy,
|
| + base::WaitableEvent* done) {
|
| + *proxy = base::MessageLoopProxy::CreateForCurrentThread();
|
| + done->Signal();
|
| +}
|
| +} // namespace
|
| +
|
| +ChromotingHostContext::ChromotingHostContext(
|
| + base::MessageLoopProxy* ui_message_loop)
|
| : main_thread_("ChromotingMainThread"),
|
| encode_thread_("ChromotingEncodeThread"),
|
| - desktop_thread_("ChromotingDesktopThread") {
|
| + desktop_thread_("ChromotingDesktopThread"),
|
| + ui_message_loop_(ui_message_loop) {
|
| }
|
|
|
| ChromotingHostContext::~ChromotingHostContext() {
|
| @@ -27,6 +39,12 @@ void ChromotingHostContext::Start() {
|
| encode_thread_.Start();
|
| jingle_thread_.Start();
|
| desktop_thread_.Start();
|
| +
|
| + // Initialize |network_message_loop_| on the network thread.
|
| + base::WaitableEvent proxy_event(true, false);
|
| + jingle_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
|
| + &InitializeMessageLoopProxy, &network_message_loop_, &proxy_event));
|
| + proxy_event.Wait();
|
| }
|
|
|
| void ChromotingHostContext::Stop() {
|
| @@ -41,6 +59,10 @@ JingleThread* ChromotingHostContext::jingle_thread() {
|
| return &jingle_thread_;
|
| }
|
|
|
| +base::MessageLoopProxy* ChromotingHostContext::ui_message_loop() {
|
| + return ui_message_loop_;
|
| +}
|
| +
|
| MessageLoop* ChromotingHostContext::main_message_loop() {
|
| return main_thread_.message_loop();
|
| }
|
| @@ -50,38 +72,11 @@ MessageLoop* ChromotingHostContext::encode_message_loop() {
|
| }
|
|
|
| base::MessageLoopProxy* ChromotingHostContext::network_message_loop() {
|
| - return jingle_thread_.message_loop_proxy();
|
| + return network_message_loop_;
|
| }
|
|
|
| MessageLoop* ChromotingHostContext::desktop_message_loop() {
|
| return desktop_thread_.message_loop();
|
| }
|
|
|
| -void ChromotingHostContext::SetUITaskPostFunction(
|
| - const UIThreadPostTaskFunction& poster) {
|
| - ui_poster_ = poster;
|
| - ui_main_thread_id_ = base::PlatformThread::CurrentId();
|
| -}
|
| -
|
| -void ChromotingHostContext::PostTaskToUIThread(
|
| - const tracked_objects::Location& from_here, const base::Closure& task) {
|
| - ui_poster_.Run(from_here, task);
|
| -}
|
| -
|
| -void ChromotingHostContext::PostDelayedTaskToUIThread(
|
| - const tracked_objects::Location& from_here,
|
| - const base::Closure& task,
|
| - int delay_ms) {
|
| - // Post delayed task on the main thread that will post task on UI
|
| - // thread. It is safe to use base::Unretained() here because
|
| - // ChromotingHostContext owns |main_thread_|.
|
| - main_message_loop()->PostDelayedTask(from_here, base::Bind(
|
| - &ChromotingHostContext::PostTaskToUIThread, base::Unretained(this),
|
| - from_here, task), delay_ms);
|
| -}
|
| -
|
| -bool ChromotingHostContext::IsUIThread() const {
|
| - return ui_main_thread_id_ == base::PlatformThread::CurrentId();
|
| -}
|
| -
|
| } // namespace remoting
|
|
|