summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorrmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-31 16:26:24 +0000
committerrmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-31 16:26:24 +0000
commitdc22637d6d783940cd178b29f1ecabe4711a912b (patch)
treea45ae1875229e72568b303da4ab14173a3c2c63c /remoting
parent8ed50afa40a29d14d3800d268bbbbba2d26bbad4 (diff)
downloadchromium_src-dc22637d6d783940cd178b29f1ecabe4711a912b.zip
chromium_src-dc22637d6d783940cd178b29f1ecabe4711a912b.tar.gz
chromium_src-dc22637d6d783940cd178b29f1ecabe4711a912b.tar.bz2
Log when the host is started for an account.
BUG=132683 TEST=me2me_virtual_host (manual) and it2me_basic (pyauto) on Linux Review URL: https://chromiumcodereview.appspot.com/10893009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host.cc5
-rw-r--r--remoting/host/chromoting_host.h2
-rw-r--r--remoting/host/chromoting_host_unittest.cc25
-rw-r--r--remoting/host/host_event_logger_posix.cc7
-rw-r--r--remoting/host/host_event_logger_win.cc6
-rw-r--r--remoting/host/host_mock_objects.h1
-rw-r--r--remoting/host/host_status_observer.h3
-rw-r--r--remoting/host/plugin/host_script_object.cc2
-rw-r--r--remoting/host/remoting_host_messages.mc8
-rw-r--r--remoting/host/remoting_me2me_host.cc2
-rw-r--r--remoting/host/simple_host_process.cc2
11 files changed, 46 insertions, 17 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 9a9abee..e902ce6 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -96,7 +96,7 @@ ChromotingHost::~ChromotingHost() {
DCHECK(clients_.empty());
}
-void ChromotingHost::Start() {
+void ChromotingHost::Start(const std::string& xmpp_login) {
DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
LOG(INFO) << "Starting host";
@@ -106,6 +106,9 @@ void ChromotingHost::Start() {
return;
state_ = kStarted;
+ FOR_EACH_OBSERVER(HostStatusObserver, status_observers_,
+ OnStart(xmpp_login));
+
// Start the SessionManager, supplying this ChromotingHost as the listener.
session_manager_->Init(signal_strategy_, this);
}
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index 84c44ae..3cbf2b7 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -80,7 +80,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
// network and start listening for incoming connections.
//
// This method can only be called once during the lifetime of this object.
- void Start();
+ void Start(const std::string& xmpp_login);
// Asynchronously shutdown the host process. |shutdown_task| is
// called after shutdown is completed.
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index cf0fbd1..2fbf2cc 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -109,6 +109,7 @@ class ChromotingHostTest : public testing::Test {
scoped_ptr<ContinueWindow>(continue_window_),
scoped_ptr<LocalInputMonitor>(local_input_monitor_));
+ xmpp_login_ = "host@domain";
session1_ = new MockSession();
session2_ = new MockSession();
session_unowned1_.reset(new MockSession());
@@ -286,6 +287,7 @@ class ChromotingHostTest : public testing::Test {
// that the session manager has started.
Expectation ExpectHostAndSessionManagerStart() {
ExpectHostStart();
+ EXPECT_CALL(host_status_observer_, OnStart(xmpp_login_));
return EXPECT_CALL(*session_manager_, Init(_, host_.get()));
}
@@ -375,6 +377,7 @@ class ChromotingHostTest : public testing::Test {
MockHostStatusObserver host_status_observer_;
MockChromotingHostContext context_;
protocol::MockSessionManager* session_manager_;
+ std::string xmpp_login_;
MockConnectionToClient* connection1_;
scoped_ptr<MockConnectionToClient> owned_connection1_;
ClientSession* client1_;
@@ -429,7 +432,7 @@ TEST_F(ChromotingHostTest, StartAndShutdown) {
Expectation start = ExpectHostAndSessionManagerStart();
EXPECT_CALL(host_status_observer_, OnShutdown()).After(start);
- host_->Start();
+ host_->Start(xmpp_login_);
message_loop_.PostTask(
FROM_HERE, base::Bind(
&ChromotingHost::Shutdown, host_.get(),
@@ -447,7 +450,7 @@ TEST_F(ChromotingHostTest, Connect) {
0, true, video_packet_sent, InvokeWithoutArgs(DoNothing));
EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected);
- host_->Start();
+ host_->Start(xmpp_login_);
SimulateClientConnection(0, true, false);
message_loop_.Run();
}
@@ -462,7 +465,7 @@ TEST_F(ChromotingHostTest, RejectAuthenticatingClient) {
InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
EXPECT_CALL(host_status_observer_, OnShutdown());
- host_->Start();
+ host_->Start(xmpp_login_);
SimulateClientConnection(0, true, true);
message_loop_.Run();
}
@@ -473,7 +476,7 @@ TEST_F(ChromotingHostTest, AuthenticationFailed) {
.WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
EXPECT_CALL(host_status_observer_, OnShutdown());
- host_->Start();
+ host_->Start(xmpp_login_);
SimulateClientConnection(0, false, false);
message_loop_.Run();
}
@@ -497,7 +500,7 @@ TEST_F(ChromotingHostTest, Reconnect) {
1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing));
EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2);
- host_->Start();
+ host_->Start(xmpp_login_);
SimulateClientConnection(0, true, false);
message_loop_.Run();
SimulateClientConnection(1, true, false);
@@ -523,7 +526,7 @@ TEST_F(ChromotingHostTest, ConnectWhenAnotherClientIsConnected) {
1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing));
EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2);
- host_->Start();
+ host_->Start(xmpp_login_);
SimulateClientConnection(0, true, false);
message_loop_.Run();
}
@@ -544,7 +547,7 @@ TEST_F(ChromotingHostTest, IncomingSessionIncompatible) {
host_->set_protocol_config(
protocol::CandidateSessionConfig::CreateDefault().release());
- host_->Start();
+ host_->Start(xmpp_login_);
protocol::SessionManager::IncomingSessionResponse response =
protocol::SessionManager::ACCEPT;
@@ -566,7 +569,7 @@ TEST_F(ChromotingHostTest, IncomingSessionAccepted) {
host_->set_protocol_config(
protocol::CandidateSessionConfig::CreateDefault().release());
- host_->Start();
+ host_->Start(xmpp_login_);
protocol::SessionManager::IncomingSessionResponse response =
protocol::SessionManager::DECLINE;
@@ -588,7 +591,7 @@ TEST_F(ChromotingHostTest, IncomingSessionOverload) {
host_->set_protocol_config(
protocol::CandidateSessionConfig::CreateDefault().release());
- host_->Start();
+ host_->Start(xmpp_login_);
protocol::SessionManager::IncomingSessionResponse response =
protocol::SessionManager::DECLINE;
@@ -617,7 +620,7 @@ TEST_F(ChromotingHostTest, OnSessionRouteChange) {
ExpectClientDisconnected(0, true, route_change, InvokeWithoutArgs(DoNothing));
EXPECT_CALL(host_status_observer_, OnShutdown());
- host_->Start();
+ host_->Start(xmpp_login_);
SimulateClientConnection(0, true, false);
message_loop_.Run();
}
@@ -630,7 +633,7 @@ TEST_F(ChromotingHostTest, DisconnectAllClients) {
InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
EXPECT_CALL(host_status_observer_, OnShutdown());
- host_->Start();
+ host_->Start(xmpp_login_);
SimulateClientConnection(0, true, false);
message_loop_.Run();
}
diff --git a/remoting/host/host_event_logger_posix.cc b/remoting/host/host_event_logger_posix.cc
index b29f9d2..fed6203 100644
--- a/remoting/host/host_event_logger_posix.cc
+++ b/remoting/host/host_event_logger_posix.cc
@@ -37,6 +37,7 @@ class HostEventLoggerPosix : public HostEventLogger, public HostStatusObserver {
const std::string& jid,
const std::string& channel_name,
const protocol::TransportRoute& route) OVERRIDE;
+ virtual void OnStart(const std::string& xmpp_login) OVERRIDE;
virtual void OnShutdown() OVERRIDE;
private:
@@ -56,7 +57,6 @@ HostEventLoggerPosix::HostEventLoggerPosix(ChromotingHost* host,
application_name_(application_name) {
openlog(application_name_.c_str(), 0, LOG_USER);
host_->AddStatusObserver(this);
- Log("Started");
}
HostEventLoggerPosix::~HostEventLoggerPosix() {
@@ -89,6 +89,11 @@ void HostEventLoggerPosix::OnClientRouteChange(
}
void HostEventLoggerPosix::OnShutdown() {
+ // TODO(rmsousa): Fix host shutdown to actually call this, and add a log line.
+}
+
+void HostEventLoggerPosix::OnStart(const std::string& xmpp_login) {
+ Log("Host started for user: " + xmpp_login);
}
void HostEventLoggerPosix::Log(const std::string& message) {
diff --git a/remoting/host/host_event_logger_win.cc b/remoting/host/host_event_logger_win.cc
index 85f31d2..7e13a40 100644
--- a/remoting/host/host_event_logger_win.cc
+++ b/remoting/host/host_event_logger_win.cc
@@ -38,6 +38,7 @@ class HostEventLoggerWin : public HostEventLogger, public HostStatusObserver {
const std::string& jid,
const std::string& channel_name,
const protocol::TransportRoute& route) OVERRIDE;
+ virtual void OnStart(const std::string& xmpp_login) OVERRIDE;
virtual void OnShutdown() OVERRIDE;
private:
@@ -101,6 +102,11 @@ void HostEventLoggerWin::OnClientRouteChange(
}
void HostEventLoggerWin::OnShutdown() {
+ // TODO(rmsousa): Fix host shutdown to actually call this, and add a log line.
+}
+
+void HostEventLoggerWin::OnStart(const std::string& xmpp_login) {
+ LogString(EVENTLOG_INFORMATION_TYPE, MSG_HOST_STARTED, xmpp_login);
}
void HostEventLoggerWin::Log(WORD type,
diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h
index 0c56b0c..b0264d1 100644
--- a/remoting/host/host_mock_objects.h
+++ b/remoting/host/host_mock_objects.h
@@ -149,6 +149,7 @@ class MockHostStatusObserver : public HostStatusObserver {
void(const std::string& jid,
const std::string& channel_name,
const protocol::TransportRoute& route));
+ MOCK_METHOD1(OnStart, void(const std::string& xmpp_login));
MOCK_METHOD0(OnShutdown, void());
};
diff --git a/remoting/host/host_status_observer.h b/remoting/host/host_status_observer.h
index 482b1fb..200b7d8 100644
--- a/remoting/host/host_status_observer.h
+++ b/remoting/host/host_status_observer.h
@@ -44,6 +44,9 @@ class HostStatusObserver {
const std::string& channel_name,
const protocol::TransportRoute& route) {}
+ // Called when hosting is started for an account.
+ virtual void OnStart(const std::string& xmpp_login) {}
+
// Called when the host shuts down.
virtual void OnShutdown() {}
};
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index a53eea6..118114f 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -607,7 +607,7 @@ void HostNPScriptObject::FinishConnectNetworkThread(
}
signal_strategy_->Connect();
- host_->Start();
+ host_->Start(uid);
SetState(kRequestedAccessCode);
return;
diff --git a/remoting/host/remoting_host_messages.mc b/remoting/host/remoting_host_messages.mc
index 0b2249b..0b5c677 100644
--- a/remoting/host/remoting_host_messages.mc
+++ b/remoting/host/remoting_host_messages.mc
@@ -51,3 +51,11 @@ SymbolicName=MSG_HOST_CLIENT_ROUTING_CHANGED
Language=English
Channel IP for client: %1 ip='%2' host_ip='%3' channel='%4' connection='%5'.
.
+
+MessageId=5
+Severity=Informational
+Facility=Host
+SymbolicName=MSG_HOST_STARTED
+Language=English
+Host started for user: %1.
+.
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 4958b7b..fa01ee2 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -541,7 +541,7 @@ class HostProcess
}
#endif
- host_->Start();
+ host_->Start(xmpp_login_);
CreateAuthenticatorFactory();
}
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 63dc305..5d03329 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -268,7 +268,7 @@ class SimpleHost : public HeartbeatSender::Listener {
this, host_id_, signal_strategy_.get(), &key_pair_));
}
- host_->Start();
+ host_->Start(xmpp_login_);
// Create a Me2Me authenticator factory.
if (!is_it2me_) {