summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 22:24:47 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 22:24:47 +0000
commitbe451c8bdb17be34c764150c47844304a94221c5 (patch)
tree85d589d7772d02ef63852351fda8982a5ea6dbff /remoting
parentea423a68cc76c7d6133bbfcd6d7630d8e8d29b1a (diff)
downloadchromium_src-be451c8bdb17be34c764150c47844304a94221c5.zip
chromium_src-be451c8bdb17be34c764150c47844304a94221c5.tar.gz
chromium_src-be451c8bdb17be34c764150c47844304a94221c5.tar.bz2
Log connection type to syslogs and to the server.
Also updated HostStatusObserver to receive transport route information as part of the OnClientRouteChange() notification, so that logging code receives connection type in order to log it. BUG=96736 Review URL: https://chromiumcodereview.appspot.com/9727005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host.cc5
-rw-r--r--remoting/host/chromoting_host.h3
-rw-r--r--remoting/host/client_session.cc6
-rw-r--r--remoting/host/client_session.h6
-rw-r--r--remoting/host/host_event_logger_posix.cc15
-rw-r--r--remoting/host/host_event_logger_win.cc15
-rw-r--r--remoting/host/host_mock_objects.cc1
-rw-r--r--remoting/host/host_mock_objects.h5
-rw-r--r--remoting/host/host_status_observer.h7
-rw-r--r--remoting/host/log_to_server.cc25
-rw-r--r--remoting/host/log_to_server.h7
-rw-r--r--remoting/host/log_to_server_unittest.cc9
-rw-r--r--remoting/host/remoting_host_messages.mc2
-rw-r--r--remoting/host/server_log_entry.cc14
-rw-r--r--remoting/host/server_log_entry.h6
-rw-r--r--remoting/protocol/connection_to_client.cc6
-rw-r--r--remoting/protocol/connection_to_client.h6
-rw-r--r--remoting/protocol/jingle_session.cc6
-rw-r--r--remoting/protocol/protocol_mock_objects.cc1
-rw-r--r--remoting/protocol/protocol_mock_objects.h9
-rw-r--r--remoting/protocol/session.h5
-rw-r--r--remoting/protocol/transport.cc33
-rw-r--r--remoting/protocol/transport.h6
-rw-r--r--remoting/remoting.gyp1
24 files changed, 140 insertions, 59 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 2687127..19f9d2c 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -222,12 +222,11 @@ void ChromotingHost::OnSessionSequenceNumber(ClientSession* session,
void ChromotingHost::OnSessionRouteChange(
ClientSession* session,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) {
+ const protocol::TransportRoute& route) {
DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
FOR_EACH_OBSERVER(HostStatusObserver, status_observers_,
OnClientRouteChange(session->client_jid(), channel_name,
- remote_end_point, local_end_point));
+ route));
}
void ChromotingHost::OnSessionManagerReady() {
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index dd1e1cb..c326314 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -113,8 +113,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
virtual void OnSessionRouteChange(
ClientSession* session,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) OVERRIDE;
+ const protocol::TransportRoute& route) OVERRIDE;
// SessionManager::Listener implementation.
virtual void OnSessionManagerReady() OVERRIDE;
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 8844ce8..c0db943 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -138,12 +138,10 @@ void ClientSession::OnSequenceNumberUpdated(
void ClientSession::OnRouteChange(
protocol::ConnectionToClient* connection,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) {
+ const protocol::TransportRoute& route) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(connection_.get(), connection);
- event_handler_->OnSessionRouteChange(this, channel_name, remote_end_point,
- local_end_point);
+ event_handler_->OnSessionRouteChange(this, channel_name, route);
}
void ClientSession::Disconnect() {
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index e3a4de1..79f2c6d 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -53,8 +53,7 @@ class ClientSession : public protocol::HostEventStub,
virtual void OnSessionRouteChange(
ClientSession* client,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) = 0;
+ const protocol::TransportRoute& route) = 0;
};
ClientSession(EventHandler* event_handler,
@@ -83,8 +82,7 @@ class ClientSession : public protocol::HostEventStub,
virtual void OnRouteChange(
protocol::ConnectionToClient* connection,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) OVERRIDE;
+ const protocol::TransportRoute& route) OVERRIDE;
// Disconnects the session and destroys the transport. Event handler
// is guaranteed not to be called after this method is called. Can
diff --git a/remoting/host/host_event_logger_posix.cc b/remoting/host/host_event_logger_posix.cc
index 56bc174..33b4b31 100644
--- a/remoting/host/host_event_logger_posix.cc
+++ b/remoting/host/host_event_logger_posix.cc
@@ -10,6 +10,7 @@
#include "net/base/ip_endpoint.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/host_status_observer.h"
+#include "remoting/protocol/transport.h"
// Included here, since the #define for LOG_USER in syslog.h conflicts with the
// constants in base/logging.h, and this source file should use the version in
@@ -35,8 +36,7 @@ class HostEventLoggerPosix : public HostEventLogger, public HostStatusObserver {
virtual void OnClientRouteChange(
const std::string& jid,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) OVERRIDE;
+ const protocol::TransportRoute& route) OVERRIDE;
virtual void OnShutdown() OVERRIDE;
private:
@@ -78,12 +78,13 @@ void HostEventLoggerPosix::OnAccessDenied(const std::string& jid) {
void HostEventLoggerPosix::OnClientRouteChange(
const std::string& jid,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) {
+ const protocol::TransportRoute& route) {
Log(base::StringPrintf(
- "Channel IP for client: %s ip='%s' host_ip='%s' channel='%s'",
- jid.c_str(), remote_end_point.ToString().c_str(),
- local_end_point.ToString().c_str(), channel_name.c_str()));
+ "Channel IP for client: %s ip='%s' host_ip='%s' channel='%s' "
+ "connection='%s'",
+ jid.c_str(), route.remote_address.ToString().c_str(),
+ route.local_address.ToString().c_str(), channel_name.c_str(),
+ protocol::TransportRoute::GetTypeString(route.type).c_str()));
}
void HostEventLoggerPosix::OnShutdown() {
diff --git a/remoting/host/host_event_logger_win.cc b/remoting/host/host_event_logger_win.cc
index b0dd3c0..cc37435 100644
--- a/remoting/host/host_event_logger_win.cc
+++ b/remoting/host/host_event_logger_win.cc
@@ -15,6 +15,7 @@
#include "net/base/ip_endpoint.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/host_status_observer.h"
+#include "remoting/protocol/transport.h"
#include "remoting_host_messages.h"
@@ -37,8 +38,7 @@ class HostEventLoggerWin : public HostEventLogger, public HostStatusObserver {
virtual void OnClientRouteChange(
const std::string& jid,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) OVERRIDE;
+ const protocol::TransportRoute& route) OVERRIDE;
virtual void OnShutdown() OVERRIDE;
private:
@@ -56,7 +56,7 @@ class HostEventLoggerWin : public HostEventLogger, public HostStatusObserver {
} //namespace
HostEventLoggerWin::HostEventLoggerWin(ChromotingHost* host,
- const std::string& application_name)
+ const std::string& application_name)
: host_(host),
event_log_(NULL) {
event_log_ = RegisterEventSourceW(NULL,
@@ -91,13 +91,14 @@ void HostEventLoggerWin::OnAccessDenied(const std::string& jid) {
void HostEventLoggerWin::OnClientRouteChange(
const std::string& jid,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) {
+ const protocol::TransportRoute& route) {
std::vector<string16> strings(4);
strings[0] = ASCIIToUTF16(jid);
- strings[1] = ASCIIToUTF16(remote_end_point.ToString());
- strings[2] = ASCIIToUTF16(local_end_point.ToString());
+ strings[1] = ASCIIToUTF16(route.remote_address.ToString());
+ strings[2] = ASCIIToUTF16(route.local_address.ToString());
strings[3] = ASCIIToUTF16(channel_name);
+ strings[4] = ASCIIToUTF16(
+ protocol::TransportRoute::GetTypeString(route.type));
Log(EVENTLOG_INFORMATION_TYPE, MSG_HOST_CLIENT_ROUTING_CHANGED, strings);
}
diff --git a/remoting/host/host_mock_objects.cc b/remoting/host/host_mock_objects.cc
index 91152d0..1c43ecf 100644
--- a/remoting/host/host_mock_objects.cc
+++ b/remoting/host/host_mock_objects.cc
@@ -7,6 +7,7 @@
#include "base/message_loop_proxy.h"
#include "net/base/ip_endpoint.h"
#include "remoting/proto/event.pb.h"
+#include "remoting/protocol/transport.h"
namespace remoting {
diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h
index 4df9e2a..23f75e4 100644
--- a/remoting/host/host_mock_objects.h
+++ b/remoting/host/host_mock_objects.h
@@ -105,11 +105,10 @@ class MockClientSessionEventHandler : public ClientSession::EventHandler {
MOCK_METHOD1(OnSessionFailed, void(ClientSession* client));
MOCK_METHOD2(OnSessionSequenceNumber, void(ClientSession* client,
int64 sequence_number));
- MOCK_METHOD4(OnSessionRouteChange, void(
+ MOCK_METHOD3(OnSessionRouteChange, void(
ClientSession* client,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point));
+ const protocol::TransportRoute& route));
private:
DISALLOW_COPY_AND_ASSIGN(MockClientSessionEventHandler);
diff --git a/remoting/host/host_status_observer.h b/remoting/host/host_status_observer.h
index 7a1fa6c..6a2a2c9 100644
--- a/remoting/host/host_status_observer.h
+++ b/remoting/host/host_status_observer.h
@@ -14,6 +14,10 @@ class IPEndPoint;
namespace remoting {
class SignalStrategy;
+namespace protocol {
+struct TransportRoute;
+};
+
// Interface for host status observer. All methods are invoked on the
// network thread.
class HostStatusObserver {
@@ -34,8 +38,7 @@ class HostStatusObserver {
// connected.
virtual void OnClientRouteChange(const std::string& jid,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) { }
+ const protocol::TransportRoute& route) { }
// Called when the host shuts down.
virtual void OnShutdown() = 0;
diff --git a/remoting/host/log_to_server.cc b/remoting/host/log_to_server.cc
index 47c4836..723b709 100644
--- a/remoting/host/log_to_server.cc
+++ b/remoting/host/log_to_server.cc
@@ -12,6 +12,7 @@
#include "remoting/jingle_glue/iq_sender.h"
#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/jingle_glue/signal_strategy.h"
+#include "remoting/protocol/transport.h"
#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
#include "third_party/libjingle/source/talk/xmpp/constants.h"
@@ -29,7 +30,8 @@ LogToServer::LogToServer(ChromotingHost* host,
SignalStrategy* signal_strategy)
: host_(host),
mode_(mode),
- signal_strategy_(signal_strategy) {
+ signal_strategy_(signal_strategy),
+ connection_type_set_(false) {
signal_strategy_->AddListener(this);
// |host| may be NULL in tests.
@@ -46,10 +48,15 @@ LogToServer::~LogToServer() {
void LogToServer::LogSessionStateChange(bool connected) {
DCHECK(CalledOnValidThread());
- scoped_ptr<ServerLogEntry> entry(ServerLogEntry::MakeSessionStateChange(
- connected));
+ scoped_ptr<ServerLogEntry> entry(
+ ServerLogEntry::MakeSessionStateChange(connected));
entry->AddHostFields();
entry->AddModeField(mode_);
+
+ if (connected) {
+ DCHECK(connection_type_set_);
+ entry->AddConnectionTypeField(connection_type_);
+ }
Log(*entry.get());
}
@@ -72,11 +79,23 @@ void LogToServer::OnClientAuthenticated(const std::string& jid) {
void LogToServer::OnClientDisconnected(const std::string& jid) {
DCHECK(CalledOnValidThread());
LogSessionStateChange(false);
+ connection_type_set_ = false;
}
void LogToServer::OnAccessDenied(const std::string& jid) {
}
+void LogToServer::OnClientRouteChange(const std::string& jid,
+ const std::string& channel_name,
+ const protocol::TransportRoute& route) {
+ // Store connection type for the video channel. It is logged later
+ // when client authentication is finished.
+ if (channel_name == kVideoChannelName) {
+ connection_type_ = route.type;
+ connection_type_set_ = true;
+ }
+}
+
void LogToServer::OnShutdown() {
}
diff --git a/remoting/host/log_to_server.h b/remoting/host/log_to_server.h
index c26df44..f17b3af 100644
--- a/remoting/host/log_to_server.h
+++ b/remoting/host/log_to_server.h
@@ -13,6 +13,7 @@
#include "remoting/host/host_status_observer.h"
#include "remoting/host/server_log_entry.h"
#include "remoting/jingle_glue/signal_strategy.h"
+#include "remoting/protocol/transport.h"
namespace base {
class MessageLoopProxy;
@@ -51,6 +52,10 @@ class LogToServer : public base::NonThreadSafe,
virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE;
virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
virtual void OnAccessDenied(const std::string& jid) OVERRIDE;
+ virtual void OnClientRouteChange(
+ const std::string& jid,
+ const std::string& channel_name,
+ const protocol::TransportRoute& route) OVERRIDE;
virtual void OnShutdown() OVERRIDE;
private:
@@ -61,6 +66,8 @@ class LogToServer : public base::NonThreadSafe,
ServerLogEntry::Mode mode_;
SignalStrategy* signal_strategy_;
scoped_ptr<IqSender> iq_sender_;
+ protocol::TransportRoute::RouteType connection_type_;
+ bool connection_type_set_;
std::deque<ServerLogEntry> pending_entries_;
DISALLOW_COPY_AND_ASSIGN(LogToServer);
diff --git a/remoting/host/log_to_server_unittest.cc b/remoting/host/log_to_server_unittest.cc
index 5a26801..c443157 100644
--- a/remoting/host/log_to_server_unittest.cc
+++ b/remoting/host/log_to_server_unittest.cc
@@ -58,12 +58,18 @@ TEST_F(LogToServerTest, SendNow) {
.RetiresOnSaturation();
}
log_to_server_->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
+ protocol::TransportRoute route;
+ route.type = protocol::TransportRoute::DIRECT;
+ log_to_server_->OnClientRouteChange("client@domain.com/5678", "video", route);
log_to_server_->OnClientAuthenticated("client@domain.com/5678");
log_to_server_->OnSignalStrategyStateChange(SignalStrategy::DISCONNECTED);
message_loop_.Run();
}
TEST_F(LogToServerTest, SendLater) {
+ protocol::TransportRoute route;
+ route.type = protocol::TransportRoute::DIRECT;
+ log_to_server_->OnClientRouteChange("client@domain.com/5678", "video", route);
log_to_server_->OnClientAuthenticated("client@domain.com/5678");
{
InSequence s;
@@ -83,6 +89,9 @@ TEST_F(LogToServerTest, SendLater) {
}
TEST_F(LogToServerTest, SendTwoEntriesLater) {
+ protocol::TransportRoute route;
+ route.type = protocol::TransportRoute::DIRECT;
+ log_to_server_->OnClientRouteChange("client@domain.com/5678", "video", route);
log_to_server_->OnClientAuthenticated("client@domain.com/5678");
log_to_server_->OnClientAuthenticated("client2@domain.com/6789");
{
diff --git a/remoting/host/remoting_host_messages.mc b/remoting/host/remoting_host_messages.mc
index 95d9b9e..0b2249b 100644
--- a/remoting/host/remoting_host_messages.mc
+++ b/remoting/host/remoting_host_messages.mc
@@ -49,5 +49,5 @@ Severity=Informational
Facility=Host
SymbolicName=MSG_HOST_CLIENT_ROUTING_CHANGED
Language=English
-Channel IP for client: %1 ip='%2' host_ip='%3' channel='%4'.
+Channel IP for client: %1 ip='%2' host_ip='%3' channel='%4' connection='%5'.
.
diff --git a/remoting/host/server_log_entry.cc b/remoting/host/server_log_entry.cc
index 18f85c7..75e2595 100644
--- a/remoting/host/server_log_entry.cc
+++ b/remoting/host/server_log_entry.cc
@@ -42,6 +42,9 @@ const char kValueOsNameChromeOS[] = "ChromeOS";
const char kKeyOsVersion[] = "os-version";
const char kKeyCpu[] = "cpu";
+
+const char kKeyConnectionType[] = "connection-type";
+
} // namespace
ServerLogEntry::ServerLogEntry() {
@@ -80,16 +83,21 @@ void ServerLogEntry::AddHostFields() {
&os_bugfix_version);
os_version << os_major_version << "." << os_minor_version << "."
<< os_bugfix_version;
- Set(kKeyOsVersion, os_version.str().c_str());
+ Set(kKeyOsVersion, os_version.str());
#endif
- Set(kKeyCpu, SysInfo::CPUArchitecture().c_str());
+ Set(kKeyCpu, SysInfo::CPUArchitecture());
};
void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode) {
Set(kKeyMode, GetValueMode(mode));
}
+void ServerLogEntry::AddConnectionTypeField(
+ protocol::TransportRoute::RouteType type) {
+ Set(kKeyConnectionType, protocol::TransportRoute::GetTypeString(type));
+}
+
const char* ServerLogEntry::GetValueMode(ServerLogEntry::Mode mode) {
switch(mode) {
case IT2ME:
@@ -116,7 +124,7 @@ const char* ServerLogEntry::GetValueSessionState(bool connected) {
return connected ? kValueSessionStateConnected : kValueSessionStateClosed;
}
-void ServerLogEntry::Set(const char* key, const char* value) {
+void ServerLogEntry::Set(const std::string& key, const std::string& value) {
values_map_[key] = value;
}
diff --git a/remoting/host/server_log_entry.h b/remoting/host/server_log_entry.h
index a1c090c..8e5be83 100644
--- a/remoting/host/server_log_entry.h
+++ b/remoting/host/server_log_entry.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/memory/scoped_ptr.h"
+#include "remoting/protocol/transport.h"
namespace buzz {
class XmlElement;
@@ -36,6 +37,9 @@ class ServerLogEntry {
// Adds a field describing the mode of a connection to this log entry.
void AddModeField(Mode mode);
+ // Adds a field describing connection type (direct/stun/relay).
+ void AddConnectionTypeField(protocol::TransportRoute::RouteType type);
+
// Converts this object to an XML stanza.
scoped_ptr<buzz::XmlElement> ToStanza() const;
@@ -43,7 +47,7 @@ class ServerLogEntry {
typedef std::map<std::string, std::string> ValuesMap;
ServerLogEntry();
- void Set(const char* key, const char* value);
+ void Set(const std::string& key, const std::string& value);
static const char* GetValueSessionState(bool connected);
static const char* GetValueMode(Mode mode);
diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
index 8226b1f..e8c648b 100644
--- a/remoting/protocol/connection_to_client.cc
+++ b/remoting/protocol/connection_to_client.cc
@@ -136,10 +136,8 @@ void ConnectionToClient::OnSessionStateChange(Session::State state) {
void ConnectionToClient::OnSessionRouteChange(
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) {
- handler_->OnRouteChange(this, channel_name, remote_end_point,
- local_end_point);
+ const TransportRoute& route) {
+ handler_->OnRouteChange(this, channel_name, route);
}
void ConnectionToClient::OnChannelInitialized(bool successful) {
diff --git a/remoting/protocol/connection_to_client.h b/remoting/protocol/connection_to_client.h
index 3b2f57e..cde5905 100644
--- a/remoting/protocol/connection_to_client.h
+++ b/remoting/protocol/connection_to_client.h
@@ -56,8 +56,7 @@ class ConnectionToClient : public base::NonThreadSafe {
// channel is connected.
virtual void OnRouteChange(ConnectionToClient* connection,
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point) = 0;
+ const TransportRoute& route) = 0;
};
// Constructs a ConnectionToClient object for the |session|. Takes
@@ -95,8 +94,7 @@ class ConnectionToClient : public base::NonThreadSafe {
void OnSessionStateChange(Session::State state);
void OnSessionRouteChange(const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point);
+ const TransportRoute& route);
// Callback for channel initialization.
void OnChannelInitialized(bool successful);
diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
index a7d417e..ae44940 100644
--- a/remoting/protocol/jingle_session.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -259,10 +259,8 @@ void JingleSession::OnTransportCandidate(Transport* transport,
void JingleSession::OnTransportRouteChange(Transport* transport,
const TransportRoute& route) {
- if (!route_change_callback_.is_null()) {
- route_change_callback_.Run(transport->name(), route.remote_address,
- route.local_address);
- }
+ if (!route_change_callback_.is_null())
+ route_change_callback_.Run(transport->name(), route);
}
void JingleSession::OnTransportDeleted(Transport* transport) {
diff --git a/remoting/protocol/protocol_mock_objects.cc b/remoting/protocol/protocol_mock_objects.cc
index 5a48cd8..34ff131 100644
--- a/remoting/protocol/protocol_mock_objects.cc
+++ b/remoting/protocol/protocol_mock_objects.cc
@@ -6,6 +6,7 @@
#include "base/message_loop_proxy.h"
#include "net/base/ip_endpoint.h"
+#include "remoting/protocol/transport.h"
namespace remoting {
namespace protocol {
diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h
index 6a7c0a84..0823732 100644
--- a/remoting/protocol/protocol_mock_objects.h
+++ b/remoting/protocol/protocol_mock_objects.h
@@ -16,6 +16,7 @@
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/input_stub.h"
#include "remoting/protocol/session.h"
+#include "remoting/protocol/transport.h"
#include "remoting/protocol/video_stub.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -51,11 +52,9 @@ class MockConnectionToClientEventHandler :
ErrorCode error));
MOCK_METHOD2(OnSequenceNumberUpdated, void(ConnectionToClient* connection,
int64 sequence_number));
- MOCK_METHOD4(OnRouteChange, void(
- ConnectionToClient* connection,
- const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point));
+ MOCK_METHOD3(OnRouteChange, void(ConnectionToClient* connection,
+ const std::string& channel_name,
+ const TransportRoute& route));
private:
DISALLOW_COPY_AND_ASSIGN(MockConnectionToClientEventHandler);
diff --git a/remoting/protocol/session.h b/remoting/protocol/session.h
index 6e3ac35..cd586c6 100644
--- a/remoting/protocol/session.h
+++ b/remoting/protocol/session.h
@@ -22,6 +22,8 @@ class StreamSocket;
namespace remoting {
namespace protocol {
+struct TransportRoute;
+
// Generic interface for Chromotocol connection used by both client and host.
// Provides access to the connection channels, but doesn't depend on the
// protocol used for each channel.
@@ -63,8 +65,7 @@ class Session : public base::NonThreadSafe {
// single interface.
typedef base::Callback<void(
const std::string& channel_name,
- const net::IPEndPoint& remote_end_point,
- const net::IPEndPoint& local_end_point)> RouteChangeCallback;
+ const TransportRoute& route)> RouteChangeCallback;
// TODO(sergeyu): Specify connection error code when channel
// connection fails.
diff --git a/remoting/protocol/transport.cc b/remoting/protocol/transport.cc
new file mode 100644
index 0000000..e1b9eee
--- /dev/null
+++ b/remoting/protocol/transport.cc
@@ -0,0 +1,33 @@
+// 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.
+
+#include "remoting/protocol/transport.h"
+
+#include "base/logging.h"
+
+namespace remoting {
+namespace protocol {
+
+// static
+std::string TransportRoute::GetTypeString(RouteType type) {
+ switch (type) {
+ case DIRECT:
+ return "direct";
+ case STUN:
+ return "stun";
+ case RELAY:
+ return "relay";
+ }
+ NOTREACHED();
+ return "";
+}
+
+TransportRoute::TransportRoute() {
+}
+
+TransportRoute::~TransportRoute() {
+}
+
+} // namespace protocol
+} // namespace remoting
diff --git a/remoting/protocol/transport.h b/remoting/protocol/transport.h
index e892404..47de7de 100644
--- a/remoting/protocol/transport.h
+++ b/remoting/protocol/transport.h
@@ -52,6 +52,12 @@ struct TransportRoute {
RELAY,
};
+ // Helper method to get string representation of the type.
+ static std::string GetTypeString(RouteType type);
+
+ TransportRoute();
+ ~TransportRoute();
+
RouteType type;
net::IPEndPoint remote_address;
net::IPEndPoint local_address;
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index b210afd..1137dd5 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -931,6 +931,7 @@
'protocol/socket_reader_base.h',
'protocol/ssl_hmac_channel_authenticator.cc',
'protocol/ssl_hmac_channel_authenticator.h',
+ 'protocol/transport.cc',
'protocol/transport.h',
'protocol/transport_config.cc',
'protocol/transport_config.h',