summaryrefslogtreecommitdiffstats
path: root/remoting/host/host_user_interface.cc
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/host/host_user_interface.cc')
-rw-r--r--remoting/host/host_user_interface.cc30
1 files changed, 12 insertions, 18 deletions
diff --git a/remoting/host/host_user_interface.cc b/remoting/host/host_user_interface.cc
index 964473b..4401fb5 100644
--- a/remoting/host/host_user_interface.cc
+++ b/remoting/host/host_user_interface.cc
@@ -16,8 +16,7 @@ HostUserInterface::HostUserInterface(ChromotingHostContext* context)
: host_(NULL),
context_(context),
is_monitoring_local_inputs_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
- weak_ptr_(weak_factory_.GetWeakPtr()) {
+ ui_thread_proxy_(context->ui_message_loop()) {
}
HostUserInterface::~HostUserInterface() {
@@ -25,6 +24,8 @@ HostUserInterface::~HostUserInterface() {
MonitorLocalInputs(false);
ShowDisconnectWindow(false, std::string());
+
+ ui_thread_proxy_.Detach();
}
void HostUserInterface::Start(ChromotingHost* host,
@@ -41,23 +42,19 @@ void HostUserInterface::Start(ChromotingHost* host,
}
void HostUserInterface::OnClientAuthenticated(const std::string& jid) {
- DCHECK(network_message_loop()->BelongsToCurrentThread());
-
authenticated_jid_ = jid;
std::string username = jid.substr(0, jid.find('/'));
- ui_message_loop()->PostTask(FROM_HERE, base::Bind(
+ ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
&HostUserInterface::ProcessOnClientAuthenticated,
- weak_ptr_, username));
+ base::Unretained(this), username));
}
void HostUserInterface::OnClientDisconnected(const std::string& jid) {
- DCHECK(network_message_loop()->BelongsToCurrentThread());
-
if (jid == authenticated_jid_) {
- ui_message_loop()->PostTask(FROM_HERE, base::Bind(
+ ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
&HostUserInterface::ProcessOnClientDisconnected,
- weak_ptr_));
+ base::Unretained(this)));
}
}
@@ -65,20 +62,20 @@ void HostUserInterface::OnAccessDenied(const std::string& jid) {
}
void HostUserInterface::OnShutdown() {
- DCHECK(network_message_loop()->BelongsToCurrentThread());
-
// Host status observers must be removed on the network thread, so
// it must happen here instead of in the destructor.
host_->RemoveStatusObserver(this);
host_ = NULL;
+ disconnect_callback_ = base::Closure();
}
void HostUserInterface::OnDisconnectCallback() {
DCHECK(ui_message_loop()->BelongsToCurrentThread());
+ DCHECK(!disconnect_callback_.is_null());
MonitorLocalInputs(false);
ShowDisconnectWindow(false, std::string());
- DisconnectSession();
+ disconnect_callback_.Run();
}
base::MessageLoopProxy* HostUserInterface::network_message_loop() const {
@@ -89,10 +86,7 @@ base::MessageLoopProxy* HostUserInterface::ui_message_loop() const {
}
void HostUserInterface::DisconnectSession() const {
- DCHECK(ui_message_loop()->BelongsToCurrentThread());
- DCHECK(!disconnect_callback_.is_null());
-
- disconnect_callback_.Run();
+ return disconnect_callback_.Run();
}
void HostUserInterface::ProcessOnClientAuthenticated(
@@ -146,7 +140,7 @@ void HostUserInterface::ShowDisconnectWindow(bool show,
disconnect_window_->Show(
host_,
base::Bind(&HostUserInterface::OnDisconnectCallback,
- weak_ptr_),
+ base::Unretained(this)),
username);
} else {
disconnect_window_->Hide();