Chromium Code Reviews| Index: remoting/client/client_context.cc |
| diff --git a/remoting/client/client_context.cc b/remoting/client/client_context.cc |
| index 4ad0faba196deabfb5fe4747de9f3ee2622d5899..908602e864b281ad1773257d6f7ff9426ad00104 100644 |
| --- a/remoting/client/client_context.cc |
| +++ b/remoting/client/client_context.cc |
| @@ -4,8 +4,21 @@ |
| #include "remoting/client/client_context.h" |
| +#include "base/bind.h" |
| +#include "base/synchronization/waitable_event.h" |
| + |
| namespace remoting { |
| +namespace { |
| +void InitializeMessageLoopProxy( |
| + scoped_refptr<base::MessageLoopProxy>* proxy, |
| + base::WaitableEvent* done) { |
| + *proxy = base::MessageLoopProxy::CreateForCurrentThread(); |
| + done->Signal(); |
| +} |
| + |
| +} // namespace |
| + |
| ClientContext::ClientContext() |
| : main_thread_("ChromotingClientMainThread"), |
| decode_thread_("ChromotingClientDecodeThread"), |
| @@ -21,6 +34,12 @@ void ClientContext::Start() { |
| decode_thread_.Start(); |
| network_thread_.StartWithOptions( |
| base::Thread::Options(MessageLoop::TYPE_IO, 0)); |
| + |
| + // Initialize |network_message_loop_| on the network thread. |
| + base::WaitableEvent proxy_event(true, false); |
| + network_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| + &InitializeMessageLoopProxy, &network_message_loop_, &proxy_event)); |
|
Wez
2011/08/12 21:11:20
Is there a reason we can't just call message_loop_
Sergey Ulanov
2011/08/12 21:24:18
I didn't know about Thread::message_loop_proxy().
|
| + proxy_event.Wait(); |
| } |
| void ClientContext::Stop() { |
| @@ -38,8 +57,8 @@ MessageLoop* ClientContext::decode_message_loop() { |
| return decode_thread_.message_loop(); |
| } |
| -MessageLoop* ClientContext::network_message_loop() { |
| - return network_thread_.message_loop(); |
| +base::MessageLoopProxy* ClientContext::network_message_loop() { |
| + return network_message_loop_; |
| } |
| } // namespace remoting |