diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 18:27:27 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 18:27:27 +0000 |
commit | bfd9d5af0f678688dbaeba69d50a79c07285aa7e (patch) | |
tree | b553b7aeb07c76ac0a187480ed77366c06a8deec /remoting/host/chromoting_host_context.cc | |
parent | ad8ef9ac2412b8179a06984bc23f14287a8bda45 (diff) | |
download | chromium_src-bfd9d5af0f678688dbaeba69d50a79c07285aa7e.zip chromium_src-bfd9d5af0f678688dbaeba69d50a79c07285aa7e.tar.gz chromium_src-bfd9d5af0f678688dbaeba69d50a79c07285aa7e.tar.bz2 |
Revert 96981 - Add PluginMessageLoopProxy and use it for Host plugin UI thread.
The new class will also be used in the client plugin for the main plugin thread.
BUG=None
TEST=Everything works.
Review URL: http://codereview.chromium.org/7635030
TBR=sergeyu@chromium.org
Review URL: http://codereview.chromium.org/7665002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/chromoting_host_context.cc')
-rw-r--r-- | remoting/host/chromoting_host_context.cc | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc index 6f02943..de99a1f 100644 --- a/remoting/host/chromoting_host_context.cc +++ b/remoting/host/chromoting_host_context.cc @@ -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 @@ 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(); } @@ -63,4 +57,31 @@ 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 |