summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/host/chromoting_host_unittest.cc4
-rw-r--r--remoting/host/host_user_interface.cc41
-rw-r--r--remoting/host/host_user_interface.h20
-rw-r--r--remoting/host/it2me_host_user_interface.cc7
-rw-r--r--remoting/host/it2me_host_user_interface.h5
-rw-r--r--remoting/host/plugin/host_script_object.cc3
-rw-r--r--remoting/host/remoting_me2me_host.cc4
-rw-r--r--remoting/host/simple_host_process.cc4
8 files changed, 55 insertions, 33 deletions
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index e1f3694..cd27486 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -132,7 +132,9 @@ class ChromotingHostTest : public testing::Test {
disconnect_window_ = new MockDisconnectWindow();
continue_window_ = new MockContinueWindow();
local_input_monitor_ = new MockLocalInputMonitor();
- it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_));
+ it2me_host_user_interface_.reset(
+ new It2MeHostUserInterface(context_.network_task_runner(),
+ context_.ui_task_runner()));
it2me_host_user_interface_->StartForTest(
host_,
base::Bind(&ChromotingHost::Shutdown, host_, base::Closure()),
diff --git a/remoting/host/host_user_interface.cc b/remoting/host/host_user_interface.cc
index 9172370..576a899 100644
--- a/remoting/host/host_user_interface.cc
+++ b/remoting/host/host_user_interface.cc
@@ -6,23 +6,25 @@
#include "base/bind.h"
#include "remoting/host/chromoting_host.h"
-#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/disconnect_window.h"
#include "remoting/host/local_input_monitor.h"
namespace remoting {
-HostUserInterface::HostUserInterface(ChromotingHostContext* context)
+HostUserInterface::HostUserInterface(
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
: host_(NULL),
- context_(context),
+ network_task_runner_(network_task_runner),
+ ui_task_runner_(ui_task_runner),
is_monitoring_local_inputs_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
weak_ptr_(weak_factory_.GetWeakPtr()) {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
}
HostUserInterface::~HostUserInterface() {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
MonitorLocalInputs(false);
ShowDisconnectWindow(false, std::string());
@@ -30,7 +32,7 @@ HostUserInterface::~HostUserInterface() {
void HostUserInterface::Start(ChromotingHost* host,
const base::Closure& disconnect_callback) {
- DCHECK(network_task_runner()->BelongsToCurrentThread());
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
DCHECK(host_ == NULL);
host_ = host;
@@ -41,21 +43,21 @@ void HostUserInterface::Start(ChromotingHost* host,
}
void HostUserInterface::OnClientAuthenticated(const std::string& jid) {
- DCHECK(network_task_runner()->BelongsToCurrentThread());
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
authenticated_jid_ = jid;
std::string username = jid.substr(0, jid.find('/'));
- ui_task_runner()->PostTask(FROM_HERE, base::Bind(
+ ui_task_runner_->PostTask(FROM_HERE, base::Bind(
&HostUserInterface::ProcessOnClientAuthenticated,
weak_ptr_, username));
}
void HostUserInterface::OnClientDisconnected(const std::string& jid) {
- DCHECK(network_task_runner()->BelongsToCurrentThread());
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
if (jid == authenticated_jid_) {
- ui_task_runner()->PostTask(FROM_HERE, base::Bind(
+ ui_task_runner_->PostTask(FROM_HERE, base::Bind(
&HostUserInterface::ProcessOnClientDisconnected,
weak_ptr_));
}
@@ -65,7 +67,7 @@ void HostUserInterface::OnAccessDenied(const std::string& jid) {
}
void HostUserInterface::OnShutdown() {
- DCHECK(network_task_runner()->BelongsToCurrentThread());
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
// Host status observers must be removed on the network thread, so
// it must happen here instead of in the destructor.
@@ -74,7 +76,7 @@ void HostUserInterface::OnShutdown() {
}
void HostUserInterface::OnDisconnectCallback() {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
MonitorLocalInputs(false);
ShowDisconnectWindow(false, std::string());
@@ -82,28 +84,29 @@ void HostUserInterface::OnDisconnectCallback() {
}
base::SingleThreadTaskRunner* HostUserInterface::network_task_runner() const {
- return context_->network_task_runner();
+ return network_task_runner_;
}
+
base::SingleThreadTaskRunner* HostUserInterface::ui_task_runner() const {
- return context_->ui_task_runner();
+ return ui_task_runner_;
}
void HostUserInterface::DisconnectSession() const {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
disconnect_callback_.Run();
}
void HostUserInterface::ProcessOnClientAuthenticated(
const std::string& username) {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
MonitorLocalInputs(true);
ShowDisconnectWindow(true, username);
}
void HostUserInterface::ProcessOnClientDisconnected() {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
MonitorLocalInputs(false);
ShowDisconnectWindow(false, std::string());
@@ -124,7 +127,7 @@ void HostUserInterface::StartForTest(
}
void HostUserInterface::MonitorLocalInputs(bool enable) {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
if (enable != is_monitoring_local_inputs_) {
if (enable) {
@@ -138,7 +141,7 @@ void HostUserInterface::MonitorLocalInputs(bool enable) {
void HostUserInterface::ShowDisconnectWindow(bool show,
const std::string& username) {
- DCHECK(ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
if (show) {
disconnect_window_->Show(
diff --git a/remoting/host/host_user_interface.h b/remoting/host/host_user_interface.h
index ce509b8..528df30 100644
--- a/remoting/host/host_user_interface.h
+++ b/remoting/host/host_user_interface.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "remoting/host/host_status_observer.h"
@@ -21,16 +22,20 @@ class SingleThreadTaskRunner;
namespace remoting {
class ChromotingHost;
-class ChromotingHostContext;
class DisconnectWindow;
class LocalInputMonitor;
-class SignalStrategy;
class HostUserInterface : public HostStatusObserver {
public:
- HostUserInterface(ChromotingHostContext* context);
+ HostUserInterface(
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
virtual ~HostUserInterface();
+ // Start the HostUserInterface for |host|. |disconnect_callback| will be
+ // called on |ui_task_runner| when |host| is shut down. |host| must remain
+ // valid at least until ChromotingHost::Shutdown() completes.
+ // Start must be called from |network_task_runner_|.
virtual void Start(ChromotingHost* host,
const base::Closure& disconnect_callback);
@@ -81,9 +86,12 @@ class HostUserInterface : public HostStatusObserver {
ChromotingHost* host_;
- // Host context used to make sure operations are run on the correct thread.
- // This is owned by the ChromotingHost.
- ChromotingHostContext* context_;
+ // Thread on which the ChromotingHost processes network events.
+ // Notifications from the host, and some calls into it, use this thread.
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
+
+ // Thread on which to run the user interface.
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// Used to ask the host to disconnect the session.
base::Closure disconnect_callback_;
diff --git a/remoting/host/it2me_host_user_interface.cc b/remoting/host/it2me_host_user_interface.cc
index da3888b..4b3145f 100644
--- a/remoting/host/it2me_host_user_interface.cc
+++ b/remoting/host/it2me_host_user_interface.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "remoting/host/chromoting_host.h"
-#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/continue_window.h"
#include "remoting/host/disconnect_window.h"
#include "remoting/host/local_input_monitor.h"
@@ -24,8 +23,10 @@ static const int kContinueWindowHideTimeoutMs = 60 * 1000;
namespace remoting {
-It2MeHostUserInterface::It2MeHostUserInterface(ChromotingHostContext* context)
- : HostUserInterface(context),
+It2MeHostUserInterface::It2MeHostUserInterface(
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
+ : HostUserInterface(network_task_runner, ui_task_runner),
ALLOW_THIS_IN_INITIALIZER_LIST(timer_weak_factory_(this)) {
}
diff --git a/remoting/host/it2me_host_user_interface.h b/remoting/host/it2me_host_user_interface.h
index 71619ea..da034d1 100644
--- a/remoting/host/it2me_host_user_interface.h
+++ b/remoting/host/it2me_host_user_interface.h
@@ -24,9 +24,12 @@ class ContinueWindow;
// IT2Me-specific handling of multiple connection attempts.
class It2MeHostUserInterface : public HostUserInterface {
public:
- It2MeHostUserInterface(ChromotingHostContext* context);
+ It2MeHostUserInterface(
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
virtual ~It2MeHostUserInterface();
+ // HostUserInterface overrides.
virtual void Start(ChromotingHost* host,
const base::Closure& disconnect_callback) OVERRIDE;
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index 16be2b6..c0969d0 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -478,7 +478,8 @@ bool HostNPScriptObject::Connect(const NPVariant* args,
// The UserInterface object needs to be created on the UI thread.
it2me_host_user_interface_.reset(
- new It2MeHostUserInterface(host_context_.get()));
+ new It2MeHostUserInterface(host_context_->network_task_runner(),
+ host_context_->ui_task_runner()));
ReadPolicyAndConnect(uid, auth_token, auth_service);
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 98b810c..b6dfb4d5 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -216,7 +216,9 @@ class HostProcess
#endif // OS_MACOSX
if (want_user_interface) {
- host_user_interface_.reset(new HostUserInterface(context_.get()));
+ host_user_interface_.reset(
+ new HostUserInterface(context_->network_task_runner(),
+ context_->ui_task_runner()));
}
StartWatchingPolicy();
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 55291c9..1b5b658 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -281,7 +281,9 @@ class SimpleHost : public HeartbeatSender::Listener {
log_to_server_.reset(new LogToServer(host_, mode, signal_strategy_.get()));
if (is_it2me_) {
- it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_));
+ it2me_host_user_interface_.reset(
+ new It2MeHostUserInterface(context_.network_task_runner(),
+ context_.ui_task_runner()));
it2me_host_user_interface_->Start(
host_,
base::Bind(&ChromotingHost::Shutdown, host_, base::Closure()));