summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorlambroslambrou@google.com <lambroslambrou@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 19:29:01 +0000
committerlambroslambrou@google.com <lambroslambrou@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 19:29:01 +0000
commit217d63f8020735f190237b3cfc337a794df1d212 (patch)
tree2584f230988d85a60d0b85eeb13daf6e49924c71 /remoting
parent63411a0180c7eb6678ca3681578479a3ab003436 (diff)
downloadchromium_src-217d63f8020735f190237b3cfc337a794df1d212.zip
chromium_src-217d63f8020735f190237b3cfc337a794df1d212.tar.gz
chromium_src-217d63f8020735f190237b3cfc337a794df1d212.tar.bz2
Revert 89227 - Run DisconnectWindow::Show/Hide on correct thread.
This is to ensure that the DisconnectWindow UI actions are carried out on the proper thread for making platform-native GUI API calls (for example, GTK on Linux). BUG=None TEST=Manual Review URL: http://codereview.chromium.org/7144010 TBR=lambroslambrou@chromium.org Review URL: http://codereview.chromium.org/7172024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host.cc4
-rw-r--r--remoting/host/chromoting_host_context.cc15
-rw-r--r--remoting/host/chromoting_host_context.h21
-rw-r--r--remoting/host/host_plugin.cc20
-rw-r--r--remoting/host/simple_host_process.cc6
5 files changed, 8 insertions, 58 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index ace4f71..36a1b45 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -547,8 +547,8 @@ void ChromotingHost::ProcessPreAuthentication(
void ChromotingHost::ShowDisconnectWindow(bool show,
const std::string& username) {
- if (!context_->IsUIThread()) {
- context_->PostToUIThread(
+ if (context_->ui_message_loop() != MessageLoop::current()) {
+ context_->ui_message_loop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromotingHost::ShowDisconnectWindow,
show, username));
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
index bc3601e..b1d9837 100644
--- a/remoting/host/chromoting_host_context.cc
+++ b/remoting/host/chromoting_host_context.cc
@@ -56,19 +56,4 @@ MessageLoop* ChromotingHostContext::ui_message_loop() {
return ui_thread_.message_loop();
}
-void ChromotingHostContext::SetUITaskPostFunction(const base::Callback<void(
- const tracked_objects::Location& from_here, Task* task)>& poster) {
- ui_poster_ = poster;
- ui_main_thread_id_ = base::PlatformThread::CurrentId();
-}
-
-void ChromotingHostContext::PostToUIThread(
- const tracked_objects::Location& from_here, Task* task) {
- ui_poster_.Run(from_here, task);
-}
-
-bool ChromotingHostContext::IsUIThread() const {
- return ui_main_thread_id_ == base::PlatformThread::CurrentId();
-}
-
} // namespace remoting
diff --git a/remoting/host/chromoting_host_context.h b/remoting/host/chromoting_host_context.h
index 4efcb3d..609da46 100644
--- a/remoting/host/chromoting_host_context.h
+++ b/remoting/host/chromoting_host_context.h
@@ -7,18 +7,10 @@
#include <string>
-#include "base/callback.h"
#include "base/gtest_prod_util.h"
-#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "remoting/jingle_glue/jingle_thread.h"
-class Task;
-
-namespace tracked_objects {
-class Location;
-}
-
namespace remoting {
// A class that manages threads and running context for the chromoting host
@@ -43,13 +35,6 @@ class ChromotingHostContext {
virtual MessageLoop* network_message_loop();
virtual MessageLoop* ui_message_loop();
- // Must be called from the main GUI thread.
- void SetUITaskPostFunction(const base::Callback<void(
- const tracked_objects::Location& from_here, Task* task)>& poster);
-
- void PostToUIThread(const tracked_objects::Location& from_here, Task* task);
- bool IsUIThread() const;
-
private:
FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
@@ -66,12 +51,6 @@ class ChromotingHostContext {
// This is NOT a Chrome-style UI thread.
base::Thread ui_thread_;
- base::Callback<void(const tracked_objects::Location& from_here, Task* task)>
- ui_poster_;
- // This IS the main Chrome GUI thread that |ui_poster_| will post to.
- base::PlatformThreadId ui_main_thread_id_;
-
-
DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
};
diff --git a/remoting/host/host_plugin.cc b/remoting/host/host_plugin.cc
index 11b621e..fd8ea75c 100644
--- a/remoting/host/host_plugin.cc
+++ b/remoting/host/host_plugin.cc
@@ -140,8 +140,6 @@ class HostNPScriptObject {
on_state_changed_func_(NULL),
np_thread_id_(base::PlatformThread::CurrentId()) {
LOG(INFO) << "HostNPScriptObject";
- host_context_.SetUITaskPostFunction(base::Bind(
- &HostNPScriptObject::PostTaskToNPThread, base::Unretained(this)));
}
~HostNPScriptObject() {
@@ -366,8 +364,7 @@ class HostNPScriptObject {
NPVariant* result);
// Posts a task on the main NP thread.
- void PostTaskToNPThread(const tracked_objects::Location& from_here,
- Task* task);
+ void PostTaskToNPThread(Task* task);
// Utility function for PostTaskToNPThread.
static void NPTaskSpringboard(void* task);
@@ -527,10 +524,10 @@ void HostNPScriptObject::OnHostShutdown() {
}
void HostNPScriptObject::OnStateChanged(State state) {
- if (!host_context_.IsUIThread()) {
- host_context_.PostToUIThread(
- FROM_HERE,
- NewRunnableMethod(this, &HostNPScriptObject::OnStateChanged, state));
+ if (base::PlatformThread::CurrentId() != np_thread_id_) {
+ PostTaskToNPThread(NewRunnableMethod(this,
+ &HostNPScriptObject::OnStateChanged,
+ state));
return;
}
state_ = state;
@@ -562,12 +559,7 @@ bool HostNPScriptObject::CallJSFunction(NPObject* func,
return is_good;
}
-void HostNPScriptObject::PostTaskToNPThread(
- const tracked_objects::Location& from_here, Task* task) {
- // The NPAPI functions cannot make use of |from_here|, but this method is
- // passed as a callback to ChromotingHostContext, so it needs to have the
- // appropriate signature.
-
+void HostNPScriptObject::PostTaskToNPThread(Task* task) {
// Can be called from any thread.
g_npnetscape_funcs->pluginthreadasynccall(plugin_,
&NPTaskSpringboard,
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index d62d49b..fc2029c 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -27,7 +27,6 @@
#include "base/file_path.h"
#include "base/logging.h"
#include "base/mac/scoped_nsautorelease_pool.h"
-#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/test/mock_chrome_application_mac.h"
#include "base/threading/thread.h"
@@ -121,11 +120,6 @@ class SimpleHost {
MessageLoop message_loop(MessageLoop::TYPE_UI);
remoting::ChromotingHostContext context;
- // static_cast needed to resolve overloaded PostTask member-function.
- context.SetUITaskPostFunction(base::Bind(
- static_cast<void(MessageLoop::*)(
- const tracked_objects::Location&, Task*)>(&MessageLoop::PostTask),
- base::Unretained(&message_loop)));
context.Start();
base::Thread file_io_thread("FileIO");