Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: remoting/host/it2me_host_user_interface.cc

Issue 8775021: Fix race condition disconnecting hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/it2me_host_user_interface.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/it2me_host_user_interface.cc
diff --git a/remoting/host/it2me_host_user_interface.cc b/remoting/host/it2me_host_user_interface.cc
index 6a150b31d95003372d7d03f16ad26ef3fe38cec7..4b898a9118c16803fb8642c84167dc8bcef1b2c4 100644
--- a/remoting/host/it2me_host_user_interface.cc
+++ b/remoting/host/it2me_host_user_interface.cc
@@ -32,7 +32,8 @@ It2MeHostUserInterface::It2MeHostUserInterface(ChromotingHost* host,
: host_(host),
context_(context),
is_monitoring_local_inputs_(false),
- ui_thread_proxy_(context->ui_message_loop()) {
+ ui_thread_proxy_(context->ui_message_loop()),
+ callback_complete_(false, false) {
}
It2MeHostUserInterface::~It2MeHostUserInterface() {
@@ -66,16 +67,19 @@ void It2MeHostUserInterface::OnClientAuthenticated(const std::string& jid) {
std::string username = jid.substr(0, jid.find('/'));
ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
- &It2MeHostUserInterface::ProcessOnConnect, base::Unretained(this),
+ &It2MeHostUserInterface::ProcessOnClientAuthenticated,
+ base::Unretained(this),
username));
+ CHECK(callback_complete_.TimedWait(base::TimeDelta::FromSeconds(10)));
}
void It2MeHostUserInterface::OnClientDisconnected(const std::string& jid) {
if (jid == authenticated_jid_) {
authenticated_jid_.clear();
ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
- &It2MeHostUserInterface::ProcessOnLastDisconnect,
+ &It2MeHostUserInterface::ProcessOnClientDisconnected,
base::Unretained(this)));
+ CHECK(callback_complete_.TimedWait(base::TimeDelta::FromSeconds(10)));
Sergey Ulanov 2011/12/01 20:35:24 I don't think that blocking network thread on the
}
}
@@ -96,33 +100,24 @@ void It2MeHostUserInterface::Shutdown() {
ui_thread_proxy_.Detach();
}
-void It2MeHostUserInterface::OnConnect(const std::string& username) {
- ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
- &It2MeHostUserInterface::ProcessOnConnect, base::Unretained(this),
- username));
-}
-
-void It2MeHostUserInterface::OnLastDisconnect() {
- ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
- &It2MeHostUserInterface::ProcessOnLastDisconnect,
- base::Unretained(this)));
-}
-
-void It2MeHostUserInterface::ProcessOnConnect(const std::string& username) {
+void It2MeHostUserInterface::ProcessOnClientAuthenticated(
+ const std::string& username) {
DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
MonitorLocalInputs(true);
ShowDisconnectWindow(true, username);
StartContinueWindowTimer(true);
+ callback_complete_.Signal();
}
-void It2MeHostUserInterface::ProcessOnLastDisconnect() {
+void It2MeHostUserInterface::ProcessOnClientDisconnected() {
DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
MonitorLocalInputs(false);
ShowDisconnectWindow(false, std::string());
ShowContinueWindow(false);
StartContinueWindowTimer(false);
+ callback_complete_.Signal();
}
void It2MeHostUserInterface::MonitorLocalInputs(bool enable) {
« no previous file with comments | « remoting/host/it2me_host_user_interface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698