diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 00:25:57 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-21 00:25:57 +0000 |
commit | be93be84596e5d610f4feeef53b2cb9cd1195dca (patch) | |
tree | 11014abdb230970c41baa668c18dfb2f5332ed96 | |
parent | c351e829e6f49069abf0f50adde2aa657807a812 (diff) | |
download | chromium_src-be93be84596e5d610f4feeef53b2cb9cd1195dca.zip chromium_src-be93be84596e5d610f4feeef53b2cb9cd1195dca.tar.gz chromium_src-be93be84596e5d610f4feeef53b2cb9cd1195dca.tar.bz2 |
The chromoting hosts log an "IT2Me or Me2Me" field to the server.
BUG=106208
TEST=none
Review URL: http://codereview.chromium.org/9192025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118562 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/host/log_to_server.cc | 3 | ||||
-rw-r--r-- | remoting/host/log_to_server.h | 2 | ||||
-rw-r--r-- | remoting/host/log_to_server_unittest.cc | 3 | ||||
-rw-r--r-- | remoting/host/plugin/host_script_object.cc | 3 | ||||
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 3 | ||||
-rw-r--r-- | remoting/host/server_log_entry.cc | 22 | ||||
-rw-r--r-- | remoting/host/server_log_entry.h | 12 | ||||
-rw-r--r-- | remoting/host/server_log_entry_unittest.cc | 34 | ||||
-rw-r--r-- | remoting/host/simple_host_process.cc | 4 |
9 files changed, 79 insertions, 7 deletions
diff --git a/remoting/host/log_to_server.cc b/remoting/host/log_to_server.cc index b0859d0..f86c91e 100644 --- a/remoting/host/log_to_server.cc +++ b/remoting/host/log_to_server.cc @@ -25,8 +25,10 @@ const char kLogCommand[] = "log"; } // namespace LogToServer::LogToServer(ChromotingHost* host, + ServerLogEntry::Mode mode, SignalStrategy* signal_strategy) : host_(host), + mode_(mode), signal_strategy_(signal_strategy) { signal_strategy_->AddListener(this); @@ -47,6 +49,7 @@ void LogToServer::LogSessionStateChange(bool connected) { scoped_ptr<ServerLogEntry> entry(ServerLogEntry::MakeSessionStateChange( connected)); entry->AddHostFields(); + entry->AddModeField(mode_); Log(*entry.get()); } diff --git a/remoting/host/log_to_server.h b/remoting/host/log_to_server.h index 9fc1cfd..c26df44 100644 --- a/remoting/host/log_to_server.h +++ b/remoting/host/log_to_server.h @@ -35,6 +35,7 @@ class LogToServer : public base::NonThreadSafe, public SignalStrategy::Listener { public: explicit LogToServer(ChromotingHost* host, + ServerLogEntry::Mode mode, SignalStrategy* signal_strategy); virtual ~LogToServer(); @@ -57,6 +58,7 @@ class LogToServer : public base::NonThreadSafe, void SendPendingEntries(); scoped_refptr<ChromotingHost> host_; + ServerLogEntry::Mode mode_; SignalStrategy* signal_strategy_; scoped_ptr<IqSender> iq_sender_; std::deque<ServerLogEntry> pending_entries_; diff --git a/remoting/host/log_to_server_unittest.cc b/remoting/host/log_to_server_unittest.cc index f7b8004..ad4874b 100644 --- a/remoting/host/log_to_server_unittest.cc +++ b/remoting/host/log_to_server_unittest.cc @@ -32,7 +32,8 @@ class LogToServerTest : public testing::Test { virtual void SetUp() OVERRIDE { message_loop_proxy_ = base::MessageLoopProxy::current(); EXPECT_CALL(signal_strategy_, AddListener(_)); - log_to_server_.reset(new LogToServer(NULL, &signal_strategy_)); + log_to_server_.reset( + new LogToServer(NULL, ServerLogEntry::ME2ME, &signal_strategy_)); EXPECT_CALL(signal_strategy_, RemoveListener(_)); } diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc index b9306c01..b4ca6ad 100644 --- a/remoting/host/plugin/host_script_object.cc +++ b/remoting/host/plugin/host_script_object.cc @@ -515,7 +515,8 @@ void HostNPScriptObject::FinishConnectNetworkThread( &host_context_, signal_strategy_.get(), desktop_environment_.get(), protocol::NetworkSettings(nat_traversal_enabled_)); host_->AddStatusObserver(this); - log_to_server_.reset(new LogToServer(host_, signal_strategy_.get())); + log_to_server_.reset( + new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get())); it2me_host_user_interface_.reset( new It2MeHostUserInterface(host_.get(), &host_context_)); it2me_host_user_interface_->Init(); diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 6cb5565..5e17900 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -176,7 +176,8 @@ class HostProcess { heartbeat_sender_.reset( new HeartbeatSender(host_id_, signal_strategy_.get(), &key_pair_)); - log_to_server_.reset(new LogToServer(host_, signal_strategy_.get())); + log_to_server_.reset( + new LogToServer(host_, ServerLogEntry::ME2ME, signal_strategy_.get())); host_event_logger_.reset(new HostEventLogger(host_, kApplicationName)); host_->Start(); diff --git a/remoting/host/server_log_entry.cc b/remoting/host/server_log_entry.cc index 08e649d..6e1a267 100644 --- a/remoting/host/server_log_entry.cc +++ b/remoting/host/server_log_entry.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,6 +25,10 @@ const char kValueEventNameSessionState[] = "session-state"; const char kKeyRole[] = "role"; const char kValueRoleHost[] = "host"; +const char kKeyMode[] = "mode"; +const char kValueModeIt2Me[] = "it2me"; +const char kValueModeMe2Me[] = "me2me"; + const char kKeySessionState[] = "session-state"; const char kValueSessionStateConnected[] = "connected"; const char kValueSessionStateClosed[] = "closed"; @@ -82,6 +86,22 @@ void ServerLogEntry::AddHostFields() { Set(kKeyCpu, SysInfo::CPUArchitecture().c_str()); }; +void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode) { + Set(kKeyMode, GetValueMode(mode)); +} + +const char* ServerLogEntry::GetValueMode(ServerLogEntry::Mode mode) { + switch(mode) { + case IT2ME: + return kValueModeIt2Me; + case ME2ME: + return kValueModeMe2Me; + default: + NOTREACHED(); + return NULL; + } +} + XmlElement* ServerLogEntry::ToStanza() const { XmlElement* stanza = new XmlElement(QName( kChromotingXmlNamespace, kLogEntry)); diff --git a/remoting/host/server_log_entry.h b/remoting/host/server_log_entry.h index 1b1d452..3353569 100644 --- a/remoting/host/server_log_entry.h +++ b/remoting/host/server_log_entry.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,6 +16,12 @@ namespace remoting { class ServerLogEntry { public: + // The mode of a connection. + enum Mode { + IT2ME, + ME2ME + }; + // Constructs a log entry for a session state change. // Currently this is either connection or disconnection. static ServerLogEntry* MakeSessionStateChange(bool connection); @@ -25,6 +31,9 @@ class ServerLogEntry { // Adds fields describing the host to this log entry. void AddHostFields(); + // Adds a field describing the mode of a connection to this log entry. + void AddModeField(Mode mode); + // Converts this object to an XML stanza. // The caller takes ownership of the stanza. buzz::XmlElement* ToStanza() const; @@ -36,6 +45,7 @@ class ServerLogEntry { void Set(const char* key, const char* value); static const char* GetValueSessionState(bool connected); + static const char* GetValueMode(Mode mode); ValuesMap values_map_; }; diff --git a/remoting/host/server_log_entry_unittest.cc b/remoting/host/server_log_entry_unittest.cc index 11bf863..55c676c 100644 --- a/remoting/host/server_log_entry_unittest.cc +++ b/remoting/host/server_log_entry_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -102,4 +102,36 @@ TEST_F(ServerLogEntryTest, AddHostFields) { error; } +TEST_F(ServerLogEntryTest, AddModeField1) { + scoped_ptr<ServerLogEntry> entry( + ServerLogEntry::MakeSessionStateChange(true)); + entry->AddModeField(ServerLogEntry::IT2ME); + scoped_ptr<XmlElement> stanza(entry->ToStanza()); + std::string error; + std::map<std::string, std::string> key_value_pairs; + key_value_pairs["role"] = "host"; + key_value_pairs["event-name"] = "session-state"; + key_value_pairs["session-state"] = "connected"; + key_value_pairs["mode"] = "it2me"; + std::set<std::string> keys; + ASSERT_TRUE(VerifyStanza(key_value_pairs, keys, stanza.get(), &error)) << + error; +} + +TEST_F(ServerLogEntryTest, AddModeField2) { + scoped_ptr<ServerLogEntry> entry( + ServerLogEntry::MakeSessionStateChange(true)); + entry->AddModeField(ServerLogEntry::ME2ME); + scoped_ptr<XmlElement> stanza(entry->ToStanza()); + std::string error; + std::map<std::string, std::string> key_value_pairs; + key_value_pairs["role"] = "host"; + key_value_pairs["event-name"] = "session-state"; + key_value_pairs["session-state"] = "connected"; + key_value_pairs["mode"] = "me2me"; + std::set<std::string> keys; + ASSERT_TRUE(VerifyStanza(key_value_pairs, keys, stanza.get(), &error)) << + error; +} + } // namespace remoting diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index 1fdd3a1..053c394 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -216,7 +216,9 @@ class SimpleHost { host_ = new ChromotingHost(&context_, signal_strategy_.get(), desktop_environment_.get(), network_settings_); - log_to_server_.reset(new LogToServer(host_, signal_strategy_.get())); + ServerLogEntry::Mode mode = + is_it2me_ ? ServerLogEntry::IT2ME : ServerLogEntry::ME2ME; + log_to_server_.reset(new LogToServer(host_, mode, signal_strategy_.get())); if (is_it2me_) { it2me_host_user_interface_.reset( |