summaryrefslogtreecommitdiffstats
path: root/remoting/host/plugin
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-08 09:52:34 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-08 09:52:34 +0000
commit4c35f73337302284aaa503dc2d6b2172623687b5 (patch)
tree35d32d1c06d8c8fd2b87ffbe0587d1509c5ac6eb /remoting/host/plugin
parentdd29cd42928c96b849ab5b832fbe78e1cd1cd9ef (diff)
downloadchromium_src-4c35f73337302284aaa503dc2d6b2172623687b5.zip
chromium_src-4c35f73337302284aaa503dc2d6b2172623687b5.tar.gz
chromium_src-4c35f73337302284aaa503dc2d6b2172623687b5.tar.bz2
[Chromoting] Refactoring DesktopEnvironment and moving screen/audio recorders to ClientSession.
This CL changes the way screen/audio recorders and event executors are managed. New DesktopEnvironmentFactory class is now used by ChromotingHost's owner to specify the kind of desktop environment (or virtual terminal) to be used by the host. Screen/audio recorders and event executors now owned by the ClientSession instance, so there is a separate set of recorders and stubs exists for each authenticated client session. Clients sessions can now be torn dowsn in parallel with the host shuttting down. This is the 2nd attempt to land this change. This version includes: - |ClientSession| objects are torn down asynchronously now. - |ChromotingHost| now waits until all connections are torn down before deleting the session manager. BUG=134694 TEST=remoting_unittests Review URL: https://chromiumcodereview.appspot.com/10911152 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155574 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/plugin')
-rw-r--r--remoting/host/plugin/host_script_object.cc44
-rw-r--r--remoting/host/plugin/host_script_object.h14
2 files changed, 14 insertions, 44 deletions
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index 8cffb5e..c900bc6 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -19,7 +19,7 @@
#include "remoting/base/auth_token_util.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
-#include "remoting/host/desktop_environment.h"
+#include "remoting/host/desktop_environment_factory.h"
#include "remoting/host/host_config.h"
#include "remoting/host/host_event_logger.h"
#include "remoting/host/host_key_pair.h"
@@ -93,6 +93,7 @@ HostNPScriptObject::HostNPScriptObject(
np_thread_id_(base::PlatformThread::CurrentId()),
plugin_task_runner_(
new PluginThreadTaskRunner(plugin_thread_delegate)),
+ desktop_environment_factory_(new DesktopEnvironmentFactory()),
failed_login_attempts_(0),
disconnected_event_(true, false),
nat_traversal_enabled_(false),
@@ -511,43 +512,22 @@ void HostNPScriptObject::ReadPolicyAndConnect(const std::string& uid,
// Only proceed to FinishConnect() if at least one policy update has been
// received.
if (policy_received_) {
- FinishConnectMainThread(uid, auth_token, auth_service);
+ FinishConnect(uid, auth_token, auth_service);
} else {
// Otherwise, create the policy watcher, and thunk the connect.
pending_connect_ =
- base::Bind(&HostNPScriptObject::FinishConnectMainThread,
+ base::Bind(&HostNPScriptObject::FinishConnect,
base::Unretained(this), uid, auth_token, auth_service);
}
}
-void HostNPScriptObject::FinishConnectMainThread(
- const std::string& uid,
- const std::string& auth_token,
- const std::string& auth_service) {
- if (!host_context_->capture_task_runner()->BelongsToCurrentThread()) {
- host_context_->capture_task_runner()->PostTask(FROM_HERE, base::Bind(
- &HostNPScriptObject::FinishConnectMainThread, base::Unretained(this),
- uid, auth_token, auth_service));
- return;
- }
-
- // DesktopEnvironment must be initialized on the capture thread.
- //
- // TODO(sergeyu): Fix DesktopEnvironment so that it can be created
- // on either the UI or the network thread so that we can avoid
- // jumping to the main thread here.
- desktop_environment_ = DesktopEnvironment::Create(host_context_.get());
-
- FinishConnectNetworkThread(uid, auth_token, auth_service);
-}
-
-void HostNPScriptObject::FinishConnectNetworkThread(
+void HostNPScriptObject::FinishConnect(
const std::string& uid,
const std::string& auth_token,
const std::string& auth_service) {
if (!host_context_->network_task_runner()->BelongsToCurrentThread()) {
host_context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
- &HostNPScriptObject::FinishConnectNetworkThread, base::Unretained(this),
+ &HostNPScriptObject::FinishConnect, base::Unretained(this),
uid, auth_token, auth_service));
return;
}
@@ -564,12 +544,6 @@ void HostNPScriptObject::FinishConnectNetworkThread(
return;
}
- // Verify that DesktopEnvironment has been created.
- if (desktop_environment_.get() == NULL) {
- SetState(kError);
- return;
- }
-
// Generate a key pair for the Host to use.
// TODO(wez): Move this to the worker thread.
host_key_pair_.Generate();
@@ -603,7 +577,8 @@ void HostNPScriptObject::FinishConnectNetworkThread(
// Create the Host.
host_ = new ChromotingHost(
- host_context_.get(), signal_strategy_.get(), desktop_environment_.get(),
+ host_context_.get(), signal_strategy_.get(),
+ desktop_environment_factory_.get(),
CreateHostSessionManager(network_settings,
host_context_->url_request_context_getter()));
host_->AddStatusObserver(this);
@@ -895,7 +870,6 @@ void HostNPScriptObject::DisconnectInternal() {
return;
case kStarting:
- desktop_environment_.reset();
SetState(kDisconnecting);
SetState(kDisconnected);
return;
@@ -925,8 +899,6 @@ void HostNPScriptObject::DisconnectInternal() {
void HostNPScriptObject::OnShutdownFinished() {
DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
-
- desktop_environment_.reset();
}
void HostNPScriptObject::OnPolicyUpdate(
diff --git a/remoting/host/plugin/host_script_object.h b/remoting/host/plugin/host_script_object.h
index abb6734..a1bb4fe 100644
--- a/remoting/host/plugin/host_script_object.h
+++ b/remoting/host/plugin/host_script_object.h
@@ -33,7 +33,7 @@
namespace remoting {
class ChromotingHost;
-class DesktopEnvironment;
+class DesktopEnvironmentFactory;
class HostEventLogger;
class It2MeHostUserInterface;
class MutableHostConfig;
@@ -198,12 +198,10 @@ class HostNPScriptObject : public HostStatusObserver {
void ReadPolicyAndConnect(const std::string& uid,
const std::string& auth_token,
const std::string& auth_service);
- void FinishConnectMainThread(const std::string& uid,
- const std::string& auth_token,
- const std::string& auth_service);
- void FinishConnectNetworkThread(const std::string& uid,
- const std::string& auth_token,
- const std::string& auth_service);
+ void FinishConnect(const std::string& uid,
+ const std::string& auth_token,
+ const std::string& auth_service);
+
void DisconnectInternal();
// Callback for ChromotingHost::Shutdown().
@@ -313,7 +311,7 @@ class HostNPScriptObject : public HostStatusObserver {
scoped_ptr<SignalStrategy> signal_strategy_;
scoped_ptr<RegisterSupportHostRequest> register_request_;
scoped_ptr<LogToServer> log_to_server_;
- scoped_ptr<DesktopEnvironment> desktop_environment_;
+ scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_;
scoped_ptr<HostEventLogger> host_event_logger_;