diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 00:30:55 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 00:30:55 +0000 |
commit | 3cb66770af1d0470f42186d6f958e3a051db96df (patch) | |
tree | 83449f6d30d0d30e2b58d36f8719674a5e63d367 /remoting/protocol | |
parent | 6215054194c9a44aeab7e8a2409f8a1347dfa3c5 (diff) | |
download | chromium_src-3cb66770af1d0470f42186d6f958e3a051db96df.zip chromium_src-3cb66770af1d0470f42186d6f958e3a051db96df.tar.gz chromium_src-3cb66770af1d0470f42186d6f958e3a051db96df.tar.bz2 |
Add JingleSession::OnRouteChange(), and pass IP endpoint information to a
callback (registered via new Session interface method).
This is the first of a series of CLs aimed at logging client IP addresses in
Remoting Me2Me Host.
BUG=109682
TEST=Manual
Review URL: http://codereview.chromium.org/9271026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/fake_session.cc | 6 | ||||
-rw-r--r-- | remoting/protocol/fake_session.h | 5 | ||||
-rw-r--r-- | remoting/protocol/jingle_session.cc | 25 | ||||
-rw-r--r-- | remoting/protocol/jingle_session.h | 6 | ||||
-rw-r--r-- | remoting/protocol/pepper_session.cc | 6 | ||||
-rw-r--r-- | remoting/protocol/pepper_session.h | 4 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.h | 4 | ||||
-rw-r--r-- | remoting/protocol/session.h | 15 |
8 files changed, 65 insertions, 6 deletions
diff --git a/remoting/protocol/fake_session.cc b/remoting/protocol/fake_session.cc index a9279af..3499650 100644 --- a/remoting/protocol/fake_session.cc +++ b/remoting/protocol/fake_session.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. @@ -243,6 +243,10 @@ void FakeSession::SetStateChangeCallback(const StateChangeCallback& callback) { callback_ = callback; } +void FakeSession::SetRouteChangeCallback(const RouteChangeCallback& callback) { + NOTIMPLEMENTED(); +} + Session::Error FakeSession::error() { return error_; } diff --git a/remoting/protocol/fake_session.h b/remoting/protocol/fake_session.h index 8daa59d..7ae3a06 100644 --- a/remoting/protocol/fake_session.h +++ b/remoting/protocol/fake_session.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. @@ -151,6 +151,9 @@ class FakeSession : public Session { virtual void SetStateChangeCallback( const StateChangeCallback& callback) OVERRIDE; + virtual void SetRouteChangeCallback( + const RouteChangeCallback& callback) OVERRIDE; + virtual Session::Error error() OVERRIDE; virtual void CreateStreamChannel( diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc index b05805d..907bc93 100644 --- a/remoting/protocol/jingle_session.cc +++ b/remoting/protocol/jingle_session.cc @@ -7,11 +7,15 @@ #include "base/base64.h" #include "base/bind.h" #include "base/location.h" +#include "base/logging.h" #include "base/message_loop_proxy.h" #include "base/rand_util.h" #include "base/stl_util.h" #include "crypto/hmac.h" +#include "jingle/glue/utils.h" +#include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" +#include "net/base/net_util.h" #include "net/socket/stream_socket.h" #include "remoting/base/constants.h" #include "remoting/protocol/auth_util.h" @@ -132,6 +136,12 @@ void JingleSession::SetStateChangeCallback( state_change_callback_ = callback; } +void JingleSession::SetRouteChangeCallback( + const RouteChangeCallback& callback) { + DCHECK(CalledOnValidThread()); + route_change_callback_ = callback; +} + Session::Error JingleSession::error() { DCHECK(CalledOnValidThread()); return error_; @@ -468,6 +478,8 @@ void JingleSession::AddChannelConnector( cricket::TransportChannel* raw_channel = cricket_session_->CreateChannel(content_name, name); + raw_channel->SignalRouteChange.connect(this, &JingleSession::OnRouteChange); + if (!jingle_session_manager_->allow_nat_traversal_ && !cricket_session_->initiator()) { // Don't make outgoing connections from the host to client when @@ -493,6 +505,19 @@ void JingleSession::OnChannelConnectorFinished( channel_connectors_.erase(name); } +void JingleSession::OnRouteChange(cricket::TransportChannel* channel, + const cricket::Candidate& candidate) { + net::IPEndPoint end_point; + if (!jingle_glue::SocketAddressToIPEndPoint(candidate.address(), + &end_point)) { + NOTREACHED(); + return; + } + + if (!route_change_callback_.is_null()) + route_change_callback_.Run(channel->name(), end_point); +} + const cricket::ContentInfo* JingleSession::GetContentInfo() const { const cricket::SessionDescription* session_description; // If we initiate the session, we get to specify the content name. When diff --git a/remoting/protocol/jingle_session.h b/remoting/protocol/jingle_session.h index caa46d2..e5e382e 100644 --- a/remoting/protocol/jingle_session.h +++ b/remoting/protocol/jingle_session.h @@ -30,6 +30,8 @@ class JingleSession : public protocol::Session, // Session interface. virtual void SetStateChangeCallback( const StateChangeCallback& callback) OVERRIDE; + virtual void SetRouteChangeCallback( + const RouteChangeCallback& callback) OVERRIDE; virtual Error error() OVERRIDE; virtual void CreateStreamChannel( const std::string& name, @@ -104,6 +106,9 @@ class JingleSession : public protocol::Session, void OnChannelConnectorFinished(const std::string& name, JingleChannelConnector* connector); + void OnRouteChange(cricket::TransportChannel* channel, + const cricket::Candidate& candidate); + const cricket::ContentInfo* GetContentInfo() const; void SetState(State new_state); @@ -122,6 +127,7 @@ class JingleSession : public protocol::Session, State state_; StateChangeCallback state_change_callback_; + RouteChangeCallback route_change_callback_; Error error_; diff --git a/remoting/protocol/pepper_session.cc b/remoting/protocol/pepper_session.cc index ae2dd66..aa69d5c 100644 --- a/remoting/protocol/pepper_session.cc +++ b/remoting/protocol/pepper_session.cc @@ -49,6 +49,12 @@ void PepperSession::SetStateChangeCallback( state_change_callback_ = callback; } +void PepperSession::SetRouteChangeCallback( + const RouteChangeCallback& callback) { + // This callback is not used on the client side yet. + NOTREACHED(); +} + Session::Error PepperSession::error() { DCHECK(CalledOnValidThread()); return error_; diff --git a/remoting/protocol/pepper_session.h b/remoting/protocol/pepper_session.h index ba2a2b4..391e808 100644 --- a/remoting/protocol/pepper_session.h +++ b/remoting/protocol/pepper_session.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. @@ -42,6 +42,8 @@ class PepperSession : public Session { // Session interface. virtual void SetStateChangeCallback( const StateChangeCallback& callback) OVERRIDE; + virtual void SetRouteChangeCallback( + const RouteChangeCallback& callback) OVERRIDE; virtual Error error() OVERRIDE; virtual void CreateStreamChannel( const std::string& name, diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h index 26b4b8e..94a4868 100644 --- a/remoting/protocol/protocol_mock_objects.h +++ b/remoting/protocol/protocol_mock_objects.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. @@ -103,6 +103,8 @@ class MockSession : public Session { MOCK_METHOD1(SetStateChangeCallback, void(const StateChangeCallback& callback)); + MOCK_METHOD1(SetRouteChangeCallback, + void(const RouteChangeCallback& callback)); MOCK_METHOD0(error, Session::Error()); MOCK_METHOD2(CreateStreamChannel, void( const std::string& name, const StreamChannelCallback& callback)); diff --git a/remoting/protocol/session.h b/remoting/protocol/session.h index 7003a13..c9986ac 100644 --- a/remoting/protocol/session.h +++ b/remoting/protocol/session.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. @@ -13,6 +13,7 @@ #include "remoting/protocol/session_config.h" namespace net { +class IPEndPoint; class Socket; class StreamSocket; } // namespace net @@ -68,6 +69,12 @@ class Session : public base::NonThreadSafe { // handler unless |state| is CLOSED or FAILED. typedef base::Callback<void(State state)> StateChangeCallback; + // TODO(lambroslambrou): Merge this together with StateChangeCallback into a + // single interface. + typedef base::Callback<void( + const std::string& channel_name, + const net::IPEndPoint& end_point)> RouteChangeCallback; + // TODO(sergeyu): Specify connection error code when channel // connection fails. typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; @@ -77,9 +84,13 @@ class Session : public base::NonThreadSafe { virtual ~Session() { } // Set callback that is called when state of the connection is changed. - // Must be called on the jingle thread only. virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; + // Set callback that is called when the route for a channel is changed. + // The callback must be registered immediately after + // JingleSessionManager::Connect() or from OnIncomingSession() callback. + virtual void SetRouteChangeCallback(const RouteChangeCallback& callback) = 0; + // Returns error code for a failed session. virtual Error error() = 0; |