summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 21:26:31 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 21:26:31 +0000
commit1958a61070f62bc0b5f28ff05110ff6446275cde (patch)
treea1de9c097035320d29b089cea8920770ce0f9e0e /remoting
parent4ab22cfc619ee8ff17a8c50e289ec3b30731ceba (diff)
downloadchromium_src-1958a61070f62bc0b5f28ff05110ff6446275cde.zip
chromium_src-1958a61070f62bc0b5f28ff05110ff6446275cde.tar.gz
chromium_src-1958a61070f62bc0b5f28ff05110ff6446275cde.tar.bz2
Call the DisconnectWindow interface methods on the UI thread.
BUG=None TEST=Unit-tests still pass Review URL: http://codereview.chromium.org/7089015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88592 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host.cc21
-rw-r--r--remoting/host/chromoting_host.h4
-rw-r--r--remoting/host/chromoting_host_unittest.cc4
-rw-r--r--remoting/host/disconnect_window_linux.cc2
-rw-r--r--remoting/host/host_mock_objects.h1
5 files changed, 29 insertions, 3 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 7f3cadd..44b2281 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -372,7 +372,7 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) {
if (!HasAuthenticatedClients()) {
EnableCurtainMode(false);
if (is_me2mom_)
- desktop_environment_->disconnect_window()->Hide();
+ ShowDisconnectWindow(false, std::string());
}
}
@@ -471,7 +471,7 @@ void ChromotingHost::LocalLoginSucceeded(
size_t pos = username.find('/');
if (pos != std::string::npos)
username.replace(pos, std::string::npos, "");
- desktop_environment_->disconnect_window()->Show(this, username);
+ ShowDisconnectWindow(true, username);
}
}
@@ -503,4 +503,21 @@ void ChromotingHost::ProcessPreAuthentication(
client->get()->OnAuthorizationComplete(true);
}
+void ChromotingHost::ShowDisconnectWindow(bool show,
+ const std::string& username) {
+ if (context_->ui_message_loop() != MessageLoop::current()) {
+ context_->ui_message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &ChromotingHost::ShowDisconnectWindow,
+ show, username));
+ return;
+ }
+
+ if (show) {
+ desktop_environment_->disconnect_window()->Show(this, username);
+ } else {
+ desktop_environment_->disconnect_window()->Hide();
+ }
+}
+
} // namespace remoting
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index 20d476a..a5d83db 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -166,6 +166,10 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
void ProcessPreAuthentication(
const scoped_refptr<protocol::ConnectionToClient>& connection);
+ // Show or hide the Disconnect window on the UI thread. If |show| is false,
+ // hide the window, ignoring the |username| parameter.
+ void ShowDisconnectWindow(bool show, const std::string& username);
+
// The context that the chromoting host runs on.
ChromotingHostContext* context_;
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index 54df055..3e4c051 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -75,12 +75,16 @@ class ChromotingHostTest : public testing::Test {
.WillByDefault(Return(&message_loop_));
ON_CALL(context_, network_message_loop())
.WillByDefault(Return(&message_loop_));
+ ON_CALL(context_, ui_message_loop())
+ .WillByDefault(Return(&message_loop_));
EXPECT_CALL(context_, main_message_loop())
.Times(AnyNumber());
EXPECT_CALL(context_, encode_message_loop())
.Times(AnyNumber());
EXPECT_CALL(context_, network_message_loop())
.Times(AnyNumber());
+ EXPECT_CALL(context_, ui_message_loop())
+ .Times(AnyNumber());
Capturer* capturer = new CapturerFake();
event_executor_ = new MockEventExecutor();
diff --git a/remoting/host/disconnect_window_linux.cc b/remoting/host/disconnect_window_linux.cc
index 0def170..cb52eae 100644
--- a/remoting/host/disconnect_window_linux.cc
+++ b/remoting/host/disconnect_window_linux.cc
@@ -12,7 +12,7 @@ class DisconnectWindowLinux : public remoting::DisconnectWindow {
public:
DisconnectWindowLinux() {}
virtual void Show(remoting::ChromotingHost* host,
- const std::string& username) OVERRIDE;
+ const std::string& username) OVERRIDE;
virtual void Hide() OVERRIDE;
private:
diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h
index 61d3135..5a8264b 100644
--- a/remoting/host/host_mock_objects.h
+++ b/remoting/host/host_mock_objects.h
@@ -64,6 +64,7 @@ class MockChromotingHostContext : public ChromotingHostContext {
MOCK_METHOD0(main_message_loop, MessageLoop*());
MOCK_METHOD0(encode_message_loop, MessageLoop*());
MOCK_METHOD0(network_message_loop, MessageLoop*());
+ MOCK_METHOD0(ui_message_loop, MessageLoop*());
private:
DISALLOW_COPY_AND_ASSIGN(MockChromotingHostContext);