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) {
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));
}
......@@ -74,7 +75,7 @@ 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)));
}
}
......@@ -96,19 +97,8 @@ 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);
......@@ -116,7 +106,7 @@ void It2MeHostUserInterface::ProcessOnConnect(const std::string& username) {
StartContinueWindowTimer(true);
}
void It2MeHostUserInterface::ProcessOnLastDisconnect() {
void It2MeHostUserInterface::ProcessOnClientDisconnected() {
DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
MonitorLocalInputs(false);
......
......@@ -67,11 +67,8 @@ class It2MeHostUserInterface : public HostStatusObserver {
ContinueWindow* continue_window,
LocalInputMonitor* monitor);
void OnConnect(const std::string& username);
void OnLastDisconnect();
void ProcessOnConnect(const std::string& username);
void ProcessOnLastDisconnect();
void ProcessOnClientAuthenticated(const std::string& username);
void ProcessOnClientDisconnected();
void MonitorLocalInputs(bool enable);
......
......@@ -12,6 +12,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "remoting/host/chromoting_host.h"
#import "third_party/GTM/AppKit/GTMCarbonEvent.h"
......@@ -21,7 +22,7 @@
static const NSUInteger kEscKeyCode = 53;
namespace {
typedef std::set<remoting::ChromotingHost*> Hosts;
typedef std::set<scoped_refptr<remoting::ChromotingHost> > Hosts;
}
@interface LocalInputMonitorImpl : NSObject {
......
......@@ -6,6 +6,7 @@
#define LOCAL_INPUT_MONITOR_THREAD_LINUX_H_
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/threading/simple_thread.h"
#include "third_party/skia/include/core/SkPoint.h"
......@@ -27,7 +28,7 @@ class LocalInputMonitorThread : public base::SimpleThread {
void LocalKeyPressed(int key_code, bool down);
private:
ChromotingHost* host_;
scoped_refptr<ChromotingHost> host_;
int wakeup_pipe_[2];
Display* display_;
bool alt_pressed_;
......
......@@ -8,6 +8,7 @@
#include <set>
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/threading/simple_thread.h"
#include "remoting/host/chromoting_host.h"
......@@ -35,7 +36,7 @@ class LocalInputMonitorThread : public base::SimpleThread {
LPARAM event_data);
base::Lock hosts_lock_;
typedef std::set<ChromotingHost*> ChromotingHosts;
typedef std::set<scoped_refptr<ChromotingHost> > ChromotingHosts;
ChromotingHosts hosts_;
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