diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 04:07:52 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 04:07:52 +0000 |
commit | 17af2abc53be34c9e5eff2b611d09f69b3e9d409 (patch) | |
tree | 8f6b9002365848ca731d8912db6335a9e07d704f /remoting | |
parent | 291b4e8eac584859ec7f909364dda3809f35aee0 (diff) | |
download | chromium_src-17af2abc53be34c9e5eff2b611d09f69b3e9d409.zip chromium_src-17af2abc53be34c9e5eff2b611d09f69b3e9d409.tar.gz chromium_src-17af2abc53be34c9e5eff2b611d09f69b3e9d409.tar.bz2 |
Log IP/port of host as well as client in Me2Me host
BUG=112327
TEST=Manual
Review URL: http://codereview.chromium.org/9316052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/chromoting_host.cc | 12 | ||||
-rw-r--r-- | remoting/host/chromoting_host.h | 8 | ||||
-rw-r--r-- | remoting/host/client_session.cc | 11 | ||||
-rw-r--r-- | remoting/host/client_session.h | 16 | ||||
-rw-r--r-- | remoting/host/host_event_logger.cc | 12 | ||||
-rw-r--r-- | remoting/host/host_event_logger.h | 8 | ||||
-rw-r--r-- | remoting/host/host_mock_objects.h | 8 | ||||
-rw-r--r-- | remoting/host/host_status_observer.h | 7 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client.cc | 7 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client.h | 10 | ||||
-rw-r--r-- | remoting/protocol/jingle_session.cc | 18 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.h | 8 | ||||
-rw-r--r-- | remoting/protocol/session.h | 3 |
13 files changed, 84 insertions, 44 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 6821e75..8865e2d 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -225,13 +225,15 @@ void ChromotingHost::OnSessionSequenceNumber(ClientSession* session, recorder_->UpdateSequenceNumber(sequence_number); } -void ChromotingHost::OnSessionIpAddress(ClientSession* session, - const std::string& channel_name, - const net::IPEndPoint& end_point) { +void ChromotingHost::OnSessionRouteChange( + ClientSession* session, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) { DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, - OnClientIpAddress(session->client_jid(), channel_name, - end_point)); + OnClientRouteChange(session->client_jid(), channel_name, + remote_end_point, local_end_point)); } void ChromotingHost::OnSessionManagerReady() { diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 8b56ab9..dc06acc 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -110,9 +110,11 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, virtual void OnSessionClosed(ClientSession* session) OVERRIDE; virtual void OnSessionSequenceNumber(ClientSession* session, int64 sequence_number) OVERRIDE; - virtual void OnSessionIpAddress(ClientSession* session, - const std::string& channel_name, - const net::IPEndPoint& end_point) OVERRIDE; + virtual void OnSessionRouteChange( + ClientSession* session, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) OVERRIDE; // SessionManager::Listener implementation. virtual void OnSessionManagerReady() OVERRIDE; diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 140f4c5..7989e09 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -125,12 +125,15 @@ void ClientSession::OnSequenceNumberUpdated( event_handler_->OnSessionSequenceNumber(this, sequence_number); } -void ClientSession::OnClientIpAddress(protocol::ConnectionToClient* connection, - const std::string& channel_name, - const net::IPEndPoint& end_point) { +void ClientSession::OnRouteChange( + protocol::ConnectionToClient* connection, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) { DCHECK(CalledOnValidThread()); DCHECK_EQ(connection_.get(), connection); - event_handler_->OnSessionIpAddress(this, channel_name, end_point); + event_handler_->OnSessionRouteChange(this, channel_name, remote_end_point, + local_end_point); } void ClientSession::Disconnect() { diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h index 98f6cf8..44607c4 100644 --- a/remoting/host/client_session.h +++ b/remoting/host/client_session.h @@ -49,9 +49,11 @@ class ClientSession : public protocol::HostStub, // Called on notification of a route change event, when a channel is // connected. - virtual void OnSessionIpAddress(ClientSession* client, - const std::string& channel_name, - const net::IPEndPoint& end_point) = 0; + virtual void OnSessionRouteChange( + ClientSession* client, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) = 0; }; // Takes ownership of |connection|. Does not take ownership of @@ -75,9 +77,11 @@ class ClientSession : public protocol::HostStub, protocol::Session::Error error) OVERRIDE; virtual void OnSequenceNumberUpdated( protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE; - virtual void OnClientIpAddress(protocol::ConnectionToClient* connection, - const std::string& channel_name, - const net::IPEndPoint& end_point) OVERRIDE; + virtual void OnRouteChange( + protocol::ConnectionToClient* connection, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) 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.cc b/remoting/host/host_event_logger.cc index 4947d06..9cd6258 100644 --- a/remoting/host/host_event_logger.cc +++ b/remoting/host/host_event_logger.cc @@ -33,10 +33,14 @@ void HostEventLogger::OnAccessDenied(const std::string& jid) { Log("Access denied for client: " + jid); } -void HostEventLogger::OnClientIpAddress(const std::string& jid, - const std::string& channel_name, - const net::IPEndPoint& end_point) { - Log("Channel IP for client: " + jid + " ip='" + end_point.ToString() + +void HostEventLogger::OnClientRouteChange( + const std::string& jid, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) { + Log("Channel IP for client: " + jid + + " ip='" + remote_end_point.ToString() + + "' host_ip='" + local_end_point.ToString() + "' channel='" + channel_name + "'"); } diff --git a/remoting/host/host_event_logger.h b/remoting/host/host_event_logger.h index 1944756..3c92bd6 100644 --- a/remoting/host/host_event_logger.h +++ b/remoting/host/host_event_logger.h @@ -28,9 +28,11 @@ class HostEventLogger : public HostStatusObserver { 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 OnClientIpAddress(const std::string& jid, - const std::string& channel_name, - const net::IPEndPoint& end_point) OVERRIDE; + 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; virtual void OnShutdown() OVERRIDE; private: diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h index e1c91fa..f1b440f 100644 --- a/remoting/host/host_mock_objects.h +++ b/remoting/host/host_mock_objects.h @@ -104,9 +104,11 @@ class MockClientSessionEventHandler : public ClientSession::EventHandler { MOCK_METHOD1(OnSessionFailed, void(ClientSession* client)); MOCK_METHOD2(OnSessionSequenceNumber, void(ClientSession* client, int64 sequence_number)); - MOCK_METHOD3(OnSessionIpAddress, void(ClientSession* client, - const std::string& channel_name, - const net::IPEndPoint& end_point)); + MOCK_METHOD4(OnSessionRouteChange, void( + ClientSession* client, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point)); private: DISALLOW_COPY_AND_ASSIGN(MockClientSessionEventHandler); diff --git a/remoting/host/host_status_observer.h b/remoting/host/host_status_observer.h index 29a7193..7a1fa6c 100644 --- a/remoting/host/host_status_observer.h +++ b/remoting/host/host_status_observer.h @@ -32,9 +32,10 @@ class HostStatusObserver { // Called on notification of a route change event, when a channel is // connected. - virtual void OnClientIpAddress(const std::string& jid, - const std::string& channel_name, - const net::IPEndPoint& end_point) { } + virtual void OnClientRouteChange(const std::string& jid, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) { } // Called when the host shuts down. virtual void OnShutdown() = 0; diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc index ea17201..69b1624 100644 --- a/remoting/protocol/connection_to_client.cc +++ b/remoting/protocol/connection_to_client.cc @@ -135,8 +135,11 @@ void ConnectionToClient::OnSessionStateChange(Session::State state) { } void ConnectionToClient::OnSessionRouteChange( - const std::string& channel_name, const net::IPEndPoint& end_point) { - handler_->OnClientIpAddress(this, channel_name, end_point); + 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); } void ConnectionToClient::OnChannelInitialized(bool successful) { diff --git a/remoting/protocol/connection_to_client.h b/remoting/protocol/connection_to_client.h index 9a92724..1f2cd54 100644 --- a/remoting/protocol/connection_to_client.h +++ b/remoting/protocol/connection_to_client.h @@ -53,9 +53,10 @@ class ConnectionToClient : public base::NonThreadSafe { // Called on notification of a route change event, which happens when a // channel is connected. - virtual void OnClientIpAddress(ConnectionToClient* connection, - const std::string& channel_name, - const net::IPEndPoint& end_point) = 0; + virtual void OnRouteChange(ConnectionToClient* connection, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point) = 0; }; // Constructs a ConnectionToClient object for the |session|. Takes @@ -92,7 +93,8 @@ class ConnectionToClient : public base::NonThreadSafe { void OnSessionStateChange(Session::State state); void OnSessionRouteChange(const std::string& channel_name, - const net::IPEndPoint& end_point); + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point); // Callback for channel initialization. void OnChannelInitialized(bool successful); diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc index 907bc93..6f856c0 100644 --- a/remoting/protocol/jingle_session.cc +++ b/remoting/protocol/jingle_session.cc @@ -507,15 +507,27 @@ void JingleSession::OnChannelConnectorFinished( void JingleSession::OnRouteChange(cricket::TransportChannel* channel, const cricket::Candidate& candidate) { - net::IPEndPoint end_point; + net::IPEndPoint remote_end_point; if (!jingle_glue::SocketAddressToIPEndPoint(candidate.address(), - &end_point)) { + &remote_end_point)) { + NOTREACHED(); + return; + } + + DCHECK(channel->GetP2PChannel()); + DCHECK(channel->GetP2PChannel()->best_connection()); + const cricket::Candidate& local_candidate = + channel->GetP2PChannel()->best_connection()->local_candidate(); + net::IPEndPoint local_end_point; + if (!jingle_glue::SocketAddressToIPEndPoint(local_candidate.address(), + &local_end_point)) { NOTREACHED(); return; } if (!route_change_callback_.is_null()) - route_change_callback_.Run(channel->name(), end_point); + route_change_callback_.Run(channel->name(), remote_end_point, + local_end_point); } const cricket::ContentInfo* JingleSession::GetContentInfo() const { diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h index ea79d72..ea85d23 100644 --- a/remoting/protocol/protocol_mock_objects.h +++ b/remoting/protocol/protocol_mock_objects.h @@ -49,9 +49,11 @@ class MockConnectionToClientEventHandler : Session::Error error)); MOCK_METHOD2(OnSequenceNumberUpdated, void(ConnectionToClient* connection, int64 sequence_number)); - MOCK_METHOD3(OnClientIpAddress, void(ConnectionToClient* connection, - const std::string& channel_name, - const net::IPEndPoint& end_point)); + MOCK_METHOD4(OnRouteChange, void( + ConnectionToClient* connection, + const std::string& channel_name, + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point)); private: DISALLOW_COPY_AND_ASSIGN(MockConnectionToClientEventHandler); diff --git a/remoting/protocol/session.h b/remoting/protocol/session.h index c9986ac..3291a5c 100644 --- a/remoting/protocol/session.h +++ b/remoting/protocol/session.h @@ -73,7 +73,8 @@ class Session : public base::NonThreadSafe { // single interface. typedef base::Callback<void( const std::string& channel_name, - const net::IPEndPoint& end_point)> RouteChangeCallback; + const net::IPEndPoint& remote_end_point, + const net::IPEndPoint& local_end_point)> RouteChangeCallback; // TODO(sergeyu): Specify connection error code when channel // connection fails. |