summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-23 01:05:14 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-23 01:05:14 +0000
commit5dc5b12a05218732918d7276215bd818f4cc0916 (patch)
treef2a94cec0617b50fd9e9583e89daef8601f095b1 /remoting
parent82752671f55f7eecf069c83c12f31cbe676459df (diff)
downloadchromium_src-5dc5b12a05218732918d7276215bd818f4cc0916.zip
chromium_src-5dc5b12a05218732918d7276215bd818f4cc0916.tar.gz
chromium_src-5dc5b12a05218732918d7276215bd818f4cc0916.tar.bz2
This CL sets a maximum session duration only for Linux Me2Me, and hard-codes it to 12 hours.
A follow-up CL will get the maximum session duration from a policy. BUG=132678 Review URL: https://chromiumcodereview.appspot.com/10629016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143767 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host.cc7
-rw-r--r--remoting/host/chromoting_host.h7
-rw-r--r--remoting/host/chromoting_host_unittest.cc2
-rw-r--r--remoting/host/client_session.cc13
-rw-r--r--remoting/host/client_session.h12
-rw-r--r--remoting/host/client_session_unittest.cc2
-rw-r--r--remoting/host/remoting_me2me_host.cc5
7 files changed, 42 insertions, 6 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 4aa7768..db48080 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -156,6 +156,11 @@ void ChromotingHost::SetAuthenticatorFactory(
session_manager_->set_authenticator_factory(authenticator_factory.Pass());
}
+void ChromotingHost::SetMaximumSessionDuration(
+ const base::TimeDelta& max_session_duration) {
+ max_session_duration_ = max_session_duration;
+}
+
////////////////////////////////////////////////////////////////////////////
// protocol::ClientSession::EventHandler implementation.
void ChromotingHost::OnSessionAuthenticated(ClientSession* client) {
@@ -315,7 +320,7 @@ void ChromotingHost::OnIncomingSession(
new protocol::ConnectionToClient(session));
ClientSession* client = new ClientSession(
this, connection.Pass(), desktop_environment_->event_executor(),
- desktop_environment_->capturer());
+ desktop_environment_->capturer(), max_session_duration_);
clients_.push_back(client);
}
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index baf030e..fa6c939 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -104,6 +104,10 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
void SetAuthenticatorFactory(
scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory);
+ // Sets the maximum duration of any session. By default, a session has no
+ // maximum duration.
+ void SetMaximumSessionDuration(const base::TimeDelta& max_session_duration);
+
////////////////////////////////////////////////////////////////////////////
// ClientSession::EventHandler implementation.
virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE;
@@ -223,6 +227,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
// ChromotingHost and should be moved elsewhere.
UiStrings ui_strings_;
+ // The maximum duration of any session.
+ base::TimeDelta max_session_duration_;
+
DISALLOW_COPY_AND_ASSIGN(ChromotingHost);
};
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index 22060b4..25c2c4f 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -176,7 +176,7 @@ class ChromotingHostTest : public testing::Test {
protocol::ConnectionToClient* connection_ptr = connection.get();
ClientSession* client = new ClientSession(
host_.get(), connection.Pass(), desktop_environment_->event_executor(),
- desktop_environment_->capturer());
+ desktop_environment_->capturer(), base::TimeDelta());
connection_ptr->set_host_stub(client);
context_.network_message_loop()->PostTask(
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index dd32400..8b511d0 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -19,7 +19,8 @@ ClientSession::ClientSession(
EventHandler* event_handler,
scoped_ptr<protocol::ConnectionToClient> connection,
protocol::HostEventStub* host_event_stub,
- Capturer* capturer)
+ Capturer* capturer,
+ const base::TimeDelta& max_duration)
: event_handler_(event_handler),
connection_(connection.Pass()),
client_jid_(connection_->session()->jid()),
@@ -29,7 +30,8 @@ ClientSession::ClientSession(
remote_input_filter_(&input_tracker_),
mouse_input_filter_(&remote_input_filter_),
client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
- capturer_(capturer) {
+ capturer_(capturer),
+ max_duration_(max_duration) {
connection_->SetEventHandler(this);
// TODO(sergeyu): Currently ConnectionToClient expects stubs to be
@@ -98,6 +100,12 @@ void ClientSession::OnConnectionAuthenticated(
is_authenticated_ = true;
auth_input_filter_.set_input_stub(&disable_input_filter_);
clipboard_echo_filter_.set_client_stub(connection_->client_stub());
+ if (max_duration_ > base::TimeDelta()) {
+ // TODO(simonmorris): Let Disconnect() tell the client that the
+ // disconnection was caused by the session exceeding its maximum duration.
+ max_duration_timer_.Start(FROM_HERE, max_duration_,
+ this, &ClientSession::Disconnect);
+ }
event_handler_->OnSessionAuthenticated(this);
}
@@ -145,6 +153,7 @@ void ClientSession::Disconnect() {
DCHECK(CalledOnValidThread());
DCHECK(connection_.get());
+ max_duration_timer_.Stop();
// This triggers OnConnectionClosed(), and the session may be destroyed
// as the result, so this call must be the last in this method.
connection_->Disconnect();
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index e15793a..0fb8532 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -8,6 +8,7 @@
#include <list>
#include "base/time.h"
+#include "base/timer.h"
#include "base/threading/non_thread_safe.h"
#include "remoting/host/remote_input_filter.h"
#include "remoting/protocol/clipboard_echo_filter.h"
@@ -67,7 +68,8 @@ class ClientSession : public protocol::HostEventStub,
ClientSession(EventHandler* event_handler,
scoped_ptr<protocol::ConnectionToClient> connection,
protocol::HostEventStub* host_event_stub,
- Capturer* capturer);
+ Capturer* capturer,
+ const base::TimeDelta& max_duration);
virtual ~ClientSession();
// protocol::ClipboardStub interface.
@@ -167,6 +169,14 @@ class ClientSession : public protocol::HostEventStub,
// area, out of this class (crbug.com/96508).
Capturer* capturer_;
+ // The maximum duration of this session.
+ // There is no maximum if this value is <= 0.
+ base::TimeDelta max_duration_;
+
+ // A timer that triggers a disconnect when the maximum session duration
+ // is reached.
+ base::OneShotTimer<ClientSession> max_duration_timer_;
+
DISALLOW_COPY_AND_ASSIGN(ClientSession);
};
diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc
index 33779c0..080ebab 100644
--- a/remoting/host/client_session_unittest.cc
+++ b/remoting/host/client_session_unittest.cc
@@ -43,7 +43,7 @@ class ClientSessionTest : public testing::Test {
new protocol::ConnectionToClient(session));
client_session_.reset(new ClientSession(
&session_event_handler_, connection.Pass(),
- &host_event_stub_, &capturer_));
+ &host_event_stub_, &capturer_, base::TimeDelta()));
}
virtual void TearDown() OVERRIDE {
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index c0b457a..47c8e03 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -390,6 +390,11 @@ class HostProcess
CreateHostSessionManager(network_settings,
context_->url_request_context_getter()));
+ // TODO(simonmorris): Get the maximum session duration from a policy.
+#if defined(OS_LINUX)
+ host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20));
+#endif
+
heartbeat_sender_.reset(new HeartbeatSender(
this, host_id_, signal_strategy_.get(), &key_pair_));