Index: remoting/host/chromoting_host_context.cc |
=================================================================== |
--- remoting/host/chromoting_host_context.cc (revision 97052) |
+++ remoting/host/chromoting_host_context.cc (working copy) |
@@ -12,12 +12,10 @@ |
namespace remoting { |
-ChromotingHostContext::ChromotingHostContext( |
- base::MessageLoopProxy* ui_message_loop) |
+ChromotingHostContext::ChromotingHostContext() |
: main_thread_("ChromotingMainThread"), |
encode_thread_("ChromotingEncodeThread"), |
- desktop_thread_("ChromotingDesktopThread"), |
- ui_message_loop_(ui_message_loop) { |
+ desktop_thread_("ChromotingDesktopThread") { |
} |
ChromotingHostContext::~ChromotingHostContext() { |
@@ -43,10 +41,6 @@ |
return &jingle_thread_; |
} |
-base::MessageLoopProxy* ChromotingHostContext::ui_message_loop() { |
- return ui_message_loop_; |
-} |
- |
MessageLoop* ChromotingHostContext::main_message_loop() { |
return main_thread_.message_loop(); |
} |
@@ -63,4 +57,31 @@ |
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 |