Fix race condition disconnecting hosts.

Also, remove a couple of unused functions and rename some to be more meaningful following the recent refactoring.

BUG=102441
TEST=Manual


Review URL: http://codereview.chromium.org/8775021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112762 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b6d53c7
...@@ -66,7 +66,8 @@ void It2MeHostUserInterface::OnClientAuthenticated(const std::string& jid) { ...@@ -66,7 +66,8 @@ void It2MeHostUserInterface::OnClientAuthenticated(const std::string& jid) {
std::string username = jid.substr(0, jid.find('/')); std::string username = jid.substr(0, jid.find('/'));
ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
&It2MeHostUserInterface::ProcessOnConnect, base::Unretained(this), &It2MeHostUserInterface::ProcessOnClientAuthenticated,
base::Unretained(this),
username)); username));
} }
...@@ -74,7 +75,7 @@ void It2MeHostUserInterface::OnClientDisconnected(const std::string& jid) { ...@@ -74,7 +75,7 @@ void It2MeHostUserInterface::OnClientDisconnected(const std::string& jid) {
if (jid == authenticated_jid_) { if (jid == authenticated_jid_) {
authenticated_jid_.clear(); authenticated_jid_.clear();
ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
&It2MeHostUserInterface::ProcessOnLastDisconnect, &It2MeHostUserInterface::ProcessOnClientDisconnected,
base::Unretained(this))); base::Unretained(this)));
} }
} }
...@@ -96,19 +97,8 @@ void It2MeHostUserInterface::Shutdown() { ...@@ -96,19 +97,8 @@ void It2MeHostUserInterface::Shutdown() {
ui_thread_proxy_.Detach(); ui_thread_proxy_.Detach();
} }
void It2MeHostUserInterface::OnConnect(const std::string& username) { void It2MeHostUserInterface::ProcessOnClientAuthenticated(
ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( const std::string& username) {
&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) {
DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
MonitorLocalInputs(true); MonitorLocalInputs(true);
...@@ -116,7 +106,7 @@ void It2MeHostUserInterface::ProcessOnConnect(const std::string& username) { ...@@ -116,7 +106,7 @@ void It2MeHostUserInterface::ProcessOnConnect(const std::string& username) {
StartContinueWindowTimer(true); StartContinueWindowTimer(true);
} }
void It2MeHostUserInterface::ProcessOnLastDisconnect() { void It2MeHostUserInterface::ProcessOnClientDisconnected() {
DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
MonitorLocalInputs(false); MonitorLocalInputs(false);
......
...@@ -67,11 +67,8 @@ class It2MeHostUserInterface : public HostStatusObserver { ...@@ -67,11 +67,8 @@ class It2MeHostUserInterface : public HostStatusObserver {
ContinueWindow* continue_window, ContinueWindow* continue_window,
LocalInputMonitor* monitor); LocalInputMonitor* monitor);
void OnConnect(const std::string& username); void ProcessOnClientAuthenticated(const std::string& username);
void OnLastDisconnect(); void ProcessOnClientDisconnected();
void ProcessOnConnect(const std::string& username);
void ProcessOnLastDisconnect();
void MonitorLocalInputs(bool enable); void MonitorLocalInputs(bool enable);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "remoting/host/chromoting_host.h" #include "remoting/host/chromoting_host.h"
#import "third_party/GTM/AppKit/GTMCarbonEvent.h" #import "third_party/GTM/AppKit/GTMCarbonEvent.h"
...@@ -21,7 +22,7 @@ ...@@ -21,7 +22,7 @@
static const NSUInteger kEscKeyCode = 53; static const NSUInteger kEscKeyCode = 53;
namespace { namespace {
typedef std::set<remoting::ChromotingHost*> Hosts; typedef std::set<scoped_refptr<remoting::ChromotingHost> > Hosts;
} }
@interface LocalInputMonitorImpl : NSObject { @interface LocalInputMonitorImpl : NSObject {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define LOCAL_INPUT_MONITOR_THREAD_LINUX_H_ #define LOCAL_INPUT_MONITOR_THREAD_LINUX_H_
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/threading/simple_thread.h" #include "base/threading/simple_thread.h"
#include "third_party/skia/include/core/SkPoint.h" #include "third_party/skia/include/core/SkPoint.h"
...@@ -27,7 +28,7 @@ class LocalInputMonitorThread : public base::SimpleThread { ...@@ -27,7 +28,7 @@ class LocalInputMonitorThread : public base::SimpleThread {
void LocalKeyPressed(int key_code, bool down); void LocalKeyPressed(int key_code, bool down);
private: private:
ChromotingHost* host_; scoped_refptr<ChromotingHost> host_;
int wakeup_pipe_[2]; int wakeup_pipe_[2];
Display* display_; Display* display_;
bool alt_pressed_; bool alt_pressed_;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <set> #include <set>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/threading/simple_thread.h" #include "base/threading/simple_thread.h"
#include "remoting/host/chromoting_host.h" #include "remoting/host/chromoting_host.h"
...@@ -35,7 +36,7 @@ class LocalInputMonitorThread : public base::SimpleThread { ...@@ -35,7 +36,7 @@ class LocalInputMonitorThread : public base::SimpleThread {
LPARAM event_data); LPARAM event_data);
base::Lock hosts_lock_; base::Lock hosts_lock_;
typedef std::set<ChromotingHost*> ChromotingHosts; typedef std::set<scoped_refptr<ChromotingHost> > ChromotingHosts;
ChromotingHosts hosts_; ChromotingHosts hosts_;
DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorThread); DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorThread);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment