diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 21:57:44 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 21:57:44 +0000 |
commit | 6c44b53b10ea8b759b8e209e107a197cc1d445e1 (patch) | |
tree | 3d7f95d5df0805b842d4731354f248ef4f90cce6 /remoting/protocol | |
parent | cdff0f7e3057e41cece048bd4957b381b108d6d6 (diff) | |
download | chromium_src-6c44b53b10ea8b759b8e209e107a197cc1d445e1.zip chromium_src-6c44b53b10ea8b759b8e209e107a197cc1d445e1.tar.gz chromium_src-6c44b53b10ea8b759b8e209e107a197cc1d445e1.tar.bz2 |
Rename PepperSession to JingleSession.
After Transport interface has been added the PepperSession is
not specific to Pepper anymore, so renaming it to JingleSession. Also removed some header files that were left
from the previous refactoring, and are not used anymore.
Review URL: https://chromiumcodereview.appspot.com/9428055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 4 | ||||
-rw-r--r-- | remoting/protocol/jingle_session.cc (renamed from remoting/protocol/pepper_session.cc) | 78 | ||||
-rw-r--r-- | remoting/protocol/jingle_session.h (renamed from remoting/protocol/pepper_session.h) | 26 | ||||
-rw-r--r-- | remoting/protocol/jingle_session_manager.cc (renamed from remoting/protocol/pepper_session_manager.cc) | 34 | ||||
-rw-r--r-- | remoting/protocol/jingle_session_manager.h (renamed from remoting/protocol/pepper_session_manager.h) | 24 | ||||
-rw-r--r-- | remoting/protocol/jingle_session_unittest.cc (renamed from remoting/protocol/pepper_session_unittest.cc) | 40 | ||||
-rw-r--r-- | remoting/protocol/pepper_channel.h | 56 | ||||
-rw-r--r-- | remoting/protocol/pepper_stream_channel.h | 77 |
8 files changed, 104 insertions, 235 deletions
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 9352712..3e109336 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -16,7 +16,7 @@ #include "remoting/protocol/client_control_dispatcher.h" #include "remoting/protocol/client_event_dispatcher.h" #include "remoting/protocol/client_stub.h" -#include "remoting/protocol/pepper_session_manager.h" +#include "remoting/protocol/jingle_session_manager.h" #include "remoting/protocol/pepper_transport_factory.h" #include "remoting/protocol/video_reader.h" #include "remoting/protocol/video_stub.h" @@ -72,7 +72,7 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, scoped_ptr<TransportFactory> transport_factory( new PepperTransportFactory(pp_instance_)); - session_manager_.reset(new PepperSessionManager(transport_factory.Pass())); + session_manager_.reset(new JingleSessionManager(transport_factory.Pass())); session_manager_->Init(signal_strategy_.get(), this, NetworkSettings(allow_nat_traversal_)); } diff --git a/remoting/protocol/pepper_session.cc b/remoting/protocol/jingle_session.cc index 0fc8d06..61d4bc9 100644 --- a/remoting/protocol/pepper_session.cc +++ b/remoting/protocol/jingle_session.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/protocol/pepper_session.h" +#include "remoting/protocol/jingle_session.h" #include "base/bind.h" #include "base/rand_util.h" @@ -14,7 +14,7 @@ #include "remoting/protocol/channel_authenticator.h" #include "remoting/protocol/content_description.h" #include "remoting/protocol/jingle_messages.h" -#include "remoting/protocol/pepper_session_manager.h" +#include "remoting/protocol/jingle_session_manager.h" #include "remoting/protocol/session_config.h" #include "third_party/libjingle/source/talk/p2p/base/candidate.h" #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" @@ -46,37 +46,37 @@ Session::Error AuthRejectionReasonToError( } // namespace -PepperSession::PepperSession(PepperSessionManager* session_manager) +JingleSession::JingleSession(JingleSessionManager* session_manager) : session_manager_(session_manager), state_(INITIALIZING), error_(OK), config_is_set_(false) { } -PepperSession::~PepperSession() { +JingleSession::~JingleSession() { STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); session_manager_->SessionDestroyed(this); } -void PepperSession::SetStateChangeCallback( +void JingleSession::SetStateChangeCallback( const StateChangeCallback& callback) { DCHECK(CalledOnValidThread()); DCHECK(!callback.is_null()); state_change_callback_ = callback; } -void PepperSession::SetRouteChangeCallback( +void JingleSession::SetRouteChangeCallback( const RouteChangeCallback& callback) { DCHECK(CalledOnValidThread()); route_change_callback_ = callback; } -Session::Error PepperSession::error() { +Session::Error JingleSession::error() { DCHECK(CalledOnValidThread()); return error_; } -void PepperSession::StartConnection( +void JingleSession::StartConnection( const std::string& peer_jid, scoped_ptr<Authenticator> authenticator, scoped_ptr<CandidateSessionConfig> config, @@ -104,13 +104,13 @@ void PepperSession::StartConnection( authenticator_->GetNextMessage())); initiate_request_ = session_manager_->iq_sender()->SendIq( message.ToXml(), - base::Bind(&PepperSession::OnSessionInitiateResponse, + base::Bind(&JingleSession::OnSessionInitiateResponse, base::Unretained(this))); SetState(CONNECTING); } -void PepperSession::InitializeIncomingConnection( +void JingleSession::InitializeIncomingConnection( const JingleMessage& initiate_message, scoped_ptr<Authenticator> authenticator) { DCHECK(CalledOnValidThread()); @@ -126,7 +126,7 @@ void PepperSession::InitializeIncomingConnection( SetState(CONNECTING); } -void PepperSession::AcceptIncomingConnection( +void JingleSession::AcceptIncomingConnection( const JingleMessage& initiate_message) { DCHECK(config_is_set_); @@ -160,7 +160,7 @@ void PepperSession::AcceptIncomingConnection( auth_message.Pass())); initiate_request_ = session_manager_->iq_sender()->SendIq( message.ToXml(), - base::Bind(&PepperSession::OnSessionInitiateResponse, + base::Bind(&JingleSession::OnSessionInitiateResponse, base::Unretained(this))); // Update state. @@ -175,7 +175,7 @@ void PepperSession::AcceptIncomingConnection( return; } -void PepperSession::OnSessionInitiateResponse( +void JingleSession::OnSessionInitiateResponse( const buzz::XmlElement* response) { const std::string& type = response->Attr(buzz::QName("", "type")); if (type != "result") { @@ -189,7 +189,7 @@ void PepperSession::OnSessionInitiateResponse( } } -void PepperSession::CreateStreamChannel( +void JingleSession::CreateStreamChannel( const std::string& name, const StreamChannelCallback& callback) { DCHECK(!channels_[name]); @@ -204,7 +204,7 @@ void PepperSession::CreateStreamChannel( channels_[name] = channel.release(); } -void PepperSession::CreateDatagramChannel( +void JingleSession::CreateDatagramChannel( const std::string& name, const DatagramChannelCallback& callback) { DCHECK(!channels_[name]); @@ -219,7 +219,7 @@ void PepperSession::CreateDatagramChannel( channels_[name] = channel.release(); } -void PepperSession::CancelChannelCreation(const std::string& name) { +void JingleSession::CancelChannelCreation(const std::string& name) { ChannelsMap::iterator it = channels_.find(name); if (it != channels_.end() && !it->second->is_connected()) { delete it->second; @@ -227,35 +227,35 @@ void PepperSession::CancelChannelCreation(const std::string& name) { } } -const std::string& PepperSession::jid() { +const std::string& JingleSession::jid() { DCHECK(CalledOnValidThread()); return peer_jid_; } -const CandidateSessionConfig* PepperSession::candidate_config() { +const CandidateSessionConfig* JingleSession::candidate_config() { DCHECK(CalledOnValidThread()); return candidate_config_.get(); } -const SessionConfig& PepperSession::config() { +const SessionConfig& JingleSession::config() { DCHECK(CalledOnValidThread()); return config_; } -void PepperSession::set_config(const SessionConfig& config) { +void JingleSession::set_config(const SessionConfig& config) { DCHECK(CalledOnValidThread()); DCHECK(!config_is_set_); config_ = config; config_is_set_ = true; } -void PepperSession::Close() { +void JingleSession::Close() { DCHECK(CalledOnValidThread()); CloseInternal(OK); } -void PepperSession::OnTransportCandidate(Transport* transport, +void JingleSession::OnTransportCandidate(Transport* transport, const cricket::Candidate& candidate) { pending_candidates_.push_back(candidate); @@ -264,11 +264,11 @@ void PepperSession::OnTransportCandidate(Transport* transport, // that we can send in one message. transport_infos_timer_.Start( FROM_HERE, base::TimeDelta::FromMilliseconds(kTransportInfoSendDelayMs), - this, &PepperSession::SendTransportInfo); + this, &JingleSession::SendTransportInfo); } } -void PepperSession::OnTransportRouteChange(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, @@ -276,13 +276,13 @@ void PepperSession::OnTransportRouteChange(Transport* transport, } } -void PepperSession::OnTransportDeleted(Transport* transport) { +void JingleSession::OnTransportDeleted(Transport* transport) { ChannelsMap::iterator it = channels_.find(transport->name()); DCHECK_EQ(it->second, transport); channels_.erase(it); } -void PepperSession::OnIncomingMessage(const JingleMessage& message, +void JingleSession::OnIncomingMessage(const JingleMessage& message, const ReplyCallback& reply_callback) { DCHECK(CalledOnValidThread()); @@ -315,7 +315,7 @@ void PepperSession::OnIncomingMessage(const JingleMessage& message, } } -void PepperSession::OnAccept(const JingleMessage& message, +void JingleSession::OnAccept(const JingleMessage& message, const ReplyCallback& reply_callback) { if (state_ != CONNECTING) { reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST); @@ -354,7 +354,7 @@ void PepperSession::OnAccept(const JingleMessage& message, } } -void PepperSession::OnSessionInfo(const JingleMessage& message, +void JingleSession::OnSessionInfo(const JingleMessage& message, const ReplyCallback& reply_callback) { if (!message.info.get() || !Authenticator::IsAuthenticatorMessage(message.info.get())) { @@ -377,7 +377,7 @@ void PepperSession::OnSessionInfo(const JingleMessage& message, ProcessAuthenticationStep(); } -void PepperSession::ProcessTransportInfo(const JingleMessage& message) { +void JingleSession::ProcessTransportInfo(const JingleMessage& message) { for (std::list<cricket::Candidate>::const_iterator it = message.candidates.begin(); it != message.candidates.end(); ++it) { @@ -390,7 +390,7 @@ void PepperSession::ProcessTransportInfo(const JingleMessage& message) { } } -void PepperSession::OnTerminate(const JingleMessage& message, +void JingleSession::OnTerminate(const JingleMessage& message, const ReplyCallback& reply_callback) { if (state_ != CONNECTING && state_ != CONNECTED && state_ != AUTHENTICATED) { LOG(WARNING) << "Received unexpected session-terminate message."; @@ -428,7 +428,7 @@ void PepperSession::OnTerminate(const JingleMessage& message, } } -bool PepperSession::InitializeConfigFromDescription( +bool JingleSession::InitializeConfigFromDescription( const ContentDescription* description) { DCHECK(description); @@ -444,7 +444,7 @@ bool PepperSession::InitializeConfigFromDescription( return true; } -void PepperSession::ProcessAuthenticationStep() { +void JingleSession::ProcessAuthenticationStep() { DCHECK_EQ(state_, CONNECTED); if (authenticator_->state() == Authenticator::MESSAGE_READY) { @@ -454,7 +454,7 @@ void PepperSession::ProcessAuthenticationStep() { session_info_request_ = session_manager_->iq_sender()->SendIq( message.ToXml(), base::Bind( - &PepperSession::OnSessionInfoResponse, + &JingleSession::OnSessionInfoResponse, base::Unretained(this))); } DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY); @@ -467,7 +467,7 @@ void PepperSession::ProcessAuthenticationStep() { } } -void PepperSession::OnSessionInfoResponse(const buzz::XmlElement* response) { +void JingleSession::OnSessionInfoResponse(const buzz::XmlElement* response) { const std::string& type = response->Attr(buzz::QName("", "type")); if (type != "result") { LOG(ERROR) << "Received error in response to session-info message: \"" @@ -477,7 +477,7 @@ void PepperSession::OnSessionInfoResponse(const buzz::XmlElement* response) { } } -void PepperSession::OnTransportInfoResponse(const buzz::XmlElement* response) { +void JingleSession::OnTransportInfoResponse(const buzz::XmlElement* response) { const std::string& type = response->Attr(buzz::QName("", "type")); if (type != "result") { LOG(ERROR) << "Received error in response to session-initiate message: \"" @@ -493,17 +493,17 @@ void PepperSession::OnTransportInfoResponse(const buzz::XmlElement* response) { } } -void PepperSession::SendTransportInfo() { +void JingleSession::SendTransportInfo() { JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_); message.candidates.swap(pending_candidates_); transport_info_request_ = session_manager_->iq_sender()->SendIq( message.ToXml(), base::Bind( - &PepperSession::OnTransportInfoResponse, + &JingleSession::OnTransportInfoResponse, base::Unretained(this))); } -void PepperSession::CloseInternal(Error error) { +void JingleSession::CloseInternal(Error error) { DCHECK(CalledOnValidThread()); if (state_ == CONNECTING || state_ == CONNECTED || state_ == AUTHENTICATED) { @@ -542,7 +542,7 @@ void PepperSession::CloseInternal(Error error) { } } -void PepperSession::SetState(State new_state) { +void JingleSession::SetState(State new_state) { DCHECK(CalledOnValidThread()); if (new_state != state_) { diff --git a/remoting/protocol/pepper_session.h b/remoting/protocol/jingle_session.h index 33cd554..f092402 100644 --- a/remoting/protocol/pepper_session.h +++ b/remoting/protocol/jingle_session.h @@ -30,15 +30,15 @@ class IqRequest; namespace protocol { -class PepperSessionManager; +class JingleSessionManager; -// Implements the protocol::Session interface using the Pepper P2P -// Transport API. Created by PepperSessionManager for incoming and -// outgoing connections. -class PepperSession : public Session, +// JingleSessionManager and JingleSession implement the subset of the +// Jingle protocol used in Chromoting. Instances of this class are +// created by the JingleSessionManager. +class JingleSession : public Session, public Transport::EventHandler { public: - virtual ~PepperSession(); + virtual ~JingleSession(); // Session interface. virtual void SetStateChangeCallback( @@ -68,12 +68,12 @@ class PepperSession : public Session, virtual void OnTransportDeleted(Transport* transport) OVERRIDE; private: - friend class PepperSessionManager; + friend class JingleSessionManager; typedef std::map<std::string, Transport*> ChannelsMap; typedef base::Callback<void(JingleMessageReply::ErrorType)> ReplyCallback; - explicit PepperSession(PepperSessionManager* session_manager); + explicit JingleSession(JingleSessionManager* session_manager); // Start connection by sending session-initiate message. void StartConnection(const std::string& peer_jid, @@ -81,7 +81,7 @@ class PepperSession : public Session, scoped_ptr<CandidateSessionConfig> config, const StateChangeCallback& state_change_callback); - // Called by PepperSessionManager for incoming connections. + // Called by JingleSessionManager for incoming connections. void InitializeIncomingConnection(const JingleMessage& initiate_message, scoped_ptr<Authenticator> authenticator); void AcceptIncomingConnection(const JingleMessage& initiate_message); @@ -89,7 +89,7 @@ class PepperSession : public Session, // Handler for session-initiate response. void OnSessionInitiateResponse(const buzz::XmlElement* response); - // Called by PepperSessionManager on incoming |message|. Must call + // Called by JingleSessionManager on incoming |message|. Must call // |reply_callback| to send reply message before sending any other // messages. void OnIncomingMessage(const JingleMessage& message, @@ -121,7 +121,7 @@ class PepperSession : public Session, // Sets |state_| to |new_state| and calls state change callback. void SetState(State new_state); - PepperSessionManager* session_manager_; + JingleSessionManager* session_manager_; std::string peer_jid_; scoped_ptr<CandidateSessionConfig> candidate_config_; StateChangeCallback state_change_callback_; @@ -142,10 +142,10 @@ class PepperSession : public Session, ChannelsMap channels_; - base::OneShotTimer<PepperSession> transport_infos_timer_; + base::OneShotTimer<JingleSession> transport_infos_timer_; std::list<cricket::Candidate> pending_candidates_; - DISALLOW_COPY_AND_ASSIGN(PepperSession); + DISALLOW_COPY_AND_ASSIGN(JingleSession); }; } // namespace protocol diff --git a/remoting/protocol/pepper_session_manager.cc b/remoting/protocol/jingle_session_manager.cc index 1024984..1735954 100644 --- a/remoting/protocol/pepper_session_manager.cc +++ b/remoting/protocol/jingle_session_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/protocol/pepper_session_manager.h" +#include "remoting/protocol/jingle_session_manager.h" #include "base/bind.h" #include "remoting/jingle_glue/iq_sender.h" @@ -11,7 +11,7 @@ #include "remoting/protocol/authenticator.h" #include "remoting/protocol/content_description.h" #include "remoting/protocol/jingle_messages.h" -#include "remoting/protocol/pepper_session.h" +#include "remoting/protocol/jingle_session.h" #include "third_party/libjingle/source/talk/base/socketaddress.h" #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" @@ -20,7 +20,7 @@ using buzz::QName; namespace remoting { namespace protocol { -PepperSessionManager::PepperSessionManager( +JingleSessionManager::JingleSessionManager( scoped_ptr<TransportFactory> transport_factory) : transport_factory_(transport_factory.Pass()), signal_strategy_(NULL), @@ -28,11 +28,11 @@ PepperSessionManager::PepperSessionManager( ready_(false) { } -PepperSessionManager::~PepperSessionManager() { +JingleSessionManager::~JingleSessionManager() { Close(); } -void PepperSessionManager::Init( +void JingleSessionManager::Init( SignalStrategy* signal_strategy, SessionManager::Listener* listener, const NetworkSettings& network_settings) { @@ -49,7 +49,7 @@ void PepperSessionManager::Init( OnSignalStrategyStateChange(signal_strategy_->GetState()); } -void PepperSessionManager::OnJingleInfo( +void JingleSessionManager::OnJingleInfo( const std::string& relay_token, const std::vector<std::string>& relay_hosts, const std::vector<talk_base::SocketAddress>& stun_hosts) { @@ -70,19 +70,19 @@ void PepperSessionManager::OnJingleInfo( } } -scoped_ptr<Session> PepperSessionManager::Connect( +scoped_ptr<Session> JingleSessionManager::Connect( const std::string& host_jid, scoped_ptr<Authenticator> authenticator, scoped_ptr<CandidateSessionConfig> config, const Session::StateChangeCallback& state_change_callback) { - scoped_ptr<PepperSession> session(new PepperSession(this)); + scoped_ptr<JingleSession> session(new JingleSession(this)); session->StartConnection(host_jid, authenticator.Pass(), config.Pass(), state_change_callback); sessions_[session->session_id_] = session.get(); return session.PassAs<Session>(); } -void PepperSessionManager::Close() { +void JingleSessionManager::Close() { DCHECK(CalledOnValidThread()); // Close() can be called only after all sessions are destroyed. @@ -97,19 +97,19 @@ void PepperSessionManager::Close() { } } -void PepperSessionManager::set_authenticator_factory( +void JingleSessionManager::set_authenticator_factory( scoped_ptr<AuthenticatorFactory> authenticator_factory) { DCHECK(CalledOnValidThread()); authenticator_factory_ = authenticator_factory.Pass(); } -void PepperSessionManager::OnSignalStrategyStateChange( +void JingleSessionManager::OnSignalStrategyStateChange( SignalStrategy::State state) { // If NAT traversal is enabled then we need to request STUN/Relay info. if (state == SignalStrategy::CONNECTED) { if (transport_config_.nat_traversal) { jingle_info_request_.reset(new JingleInfoRequest(signal_strategy_)); - jingle_info_request_->Send(base::Bind(&PepperSessionManager::OnJingleInfo, + jingle_info_request_->Send(base::Bind(&JingleSessionManager::OnJingleInfo, base::Unretained(this))); } else if (!ready_) { ready_ = true; @@ -118,7 +118,7 @@ void PepperSessionManager::OnSignalStrategyStateChange( } } -bool PepperSessionManager::OnSignalStrategyIncomingStanza( +bool JingleSessionManager::OnSignalStrategyIncomingStanza( const buzz::XmlElement* stanza) { if (!JingleMessage::IsJingleMessage(stanza)) return false; @@ -140,7 +140,7 @@ bool PepperSessionManager::OnSignalStrategyIncomingStanza( authenticator_factory_->CreateAuthenticator( message.from, message.description->authenticator_message()); - PepperSession* session = new PepperSession(this); + JingleSession* session = new JingleSession(this); session->InitializeIncomingConnection(message, authenticator.Pass()); sessions_[session->session_id_] = session; @@ -165,17 +165,17 @@ bool PepperSessionManager::OnSignalStrategyIncomingStanza( } it->second->OnIncomingMessage(message, base::Bind( - &PepperSessionManager::SendReply, base::Unretained(this), stanza)); + &JingleSessionManager::SendReply, base::Unretained(this), stanza)); return true; } -void PepperSessionManager::SendReply(const buzz::XmlElement* original_stanza, +void JingleSessionManager::SendReply(const buzz::XmlElement* original_stanza, JingleMessageReply::ErrorType error) { signal_strategy_->SendStanza( JingleMessageReply(error).ToXml(original_stanza)); } -void PepperSessionManager::SessionDestroyed(PepperSession* session) { +void JingleSessionManager::SessionDestroyed(JingleSession* session) { sessions_.erase(session->session_id_); } diff --git a/remoting/protocol/pepper_session_manager.h b/remoting/protocol/jingle_session_manager.h index bf1fb2b..1c4ab51 100644 --- a/remoting/protocol/pepper_session_manager.h +++ b/remoting/protocol/jingle_session_manager.h @@ -36,16 +36,18 @@ class JingleInfoRequest; namespace protocol { -class PepperSession; +class JingleSession; -// This class implements SessionManager interface on top of the Pepper -// P2P Transport API. -class PepperSessionManager : public SessionManager, +// JingleSessionManager and JingleSession implement the subset of the +// Jingle protocol used in Chromoting. JingleSessionManager provides +// the protocol::SessionManager interface for accepting incoming and +// creating outgoing sessions. +class JingleSessionManager : public SessionManager, public SignalStrategy::Listener { public: - explicit PepperSessionManager( + explicit JingleSessionManager( scoped_ptr<TransportFactory> transport_factory); - virtual ~PepperSessionManager(); + virtual ~JingleSessionManager(); // SessionManager interface. virtual void Init(SignalStrategy* signal_strategy, @@ -67,9 +69,9 @@ class PepperSessionManager : public SessionManager, const buzz::XmlElement* stanza) OVERRIDE; private: - friend class PepperSession; + friend class JingleSession; - typedef std::map<std::string, PepperSession*> SessionsMap; + typedef std::map<std::string, JingleSession*> SessionsMap; void OnJingleInfo( const std::string& relay_token, @@ -80,8 +82,8 @@ class PepperSessionManager : public SessionManager, void SendReply(const buzz::XmlElement* original_stanza, JingleMessageReply::ErrorType error); - // Called by PepperSession when it is being destroyed. - void SessionDestroyed(PepperSession* session); + // Called by JingleSession when it is being destroyed. + void SessionDestroyed(JingleSession* session); scoped_ptr<TransportFactory> transport_factory_; @@ -98,7 +100,7 @@ class PepperSessionManager : public SessionManager, SessionsMap sessions_; - DISALLOW_COPY_AND_ASSIGN(PepperSessionManager); + DISALLOW_COPY_AND_ASSIGN(JingleSessionManager); }; } // namespace protocol diff --git a/remoting/protocol/pepper_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc index 1c18fba..b5984aa 100644 --- a/remoting/protocol/pepper_session_unittest.cc +++ b/remoting/protocol/jingle_session_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/protocol/pepper_session.h" +#include "remoting/protocol/jingle_session.h" #include "base/bind.h" #include "base/message_loop.h" @@ -15,7 +15,7 @@ #include "remoting/protocol/channel_authenticator.h" #include "remoting/protocol/connection_tester.h" #include "remoting/protocol/fake_authenticator.h" -#include "remoting/protocol/pepper_session_manager.h" +#include "remoting/protocol/jingle_session_manager.h" #include "remoting/protocol/libjingle_transport_factory.h" #include "remoting/jingle_glue/jingle_thread.h" #include "remoting/jingle_glue/fake_signal_strategy.h" @@ -79,9 +79,9 @@ class MockStreamChannelCallback { } // namespace -class PepperSessionTest : public testing::Test { +class JingleSessionTest : public testing::Test { public: - PepperSessionTest() + JingleSessionTest() : message_loop_(talk_base::Thread::Current()) { } @@ -132,7 +132,7 @@ class PepperSessionTest : public testing::Test { EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) .Times(1); - host_server_.reset(new PepperSessionManager( + host_server_.reset(new JingleSessionManager( scoped_ptr<TransportFactory>(new LibjingleTransportFactory()))); host_server_->Init(host_signal_strategy_.get(), &host_server_listener_, NetworkSettings(false)); @@ -143,7 +143,7 @@ class PepperSessionTest : public testing::Test { EXPECT_CALL(client_server_listener_, OnSessionManagerReady()) .Times(1); - client_server_.reset(new PepperSessionManager( + client_server_.reset(new JingleSessionManager( scoped_ptr<TransportFactory>(new LibjingleTransportFactory()))); client_server_->Init(client_signal_strategy_.get(), &client_server_listener_, NetworkSettings()); @@ -167,7 +167,7 @@ class PepperSessionTest : public testing::Test { bool expect_fail) { EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) .WillOnce(DoAll( - WithArg<0>(Invoke(this, &PepperSessionTest::SetHostSession)), + WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)), SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); { @@ -229,9 +229,9 @@ class PepperSessionTest : public testing::Test { void CreateChannel(bool expect_fail) { client_session_->CreateStreamChannel(kChannelName, base::Bind( - &PepperSessionTest::OnClientChannelCreated, base::Unretained(this))); + &JingleSessionTest::OnClientChannelCreated, base::Unretained(this))); host_session_->CreateStreamChannel(kChannelName, base::Bind( - &PepperSessionTest::OnHostChannelCreated, base::Unretained(this))); + &JingleSessionTest::OnHostChannelCreated, base::Unretained(this))); int counter = 2; EXPECT_CALL(client_channel_callback_, OnDone(_)) @@ -254,9 +254,9 @@ class PepperSessionTest : public testing::Test { scoped_ptr<FakeSignalStrategy> host_signal_strategy_; scoped_ptr<FakeSignalStrategy> client_signal_strategy_; - scoped_ptr<PepperSessionManager> host_server_; + scoped_ptr<JingleSessionManager> host_server_; MockSessionManagerListener host_server_listener_; - scoped_ptr<PepperSessionManager> client_server_; + scoped_ptr<JingleSessionManager> client_server_; MockSessionManagerListener client_server_listener_; scoped_ptr<Session> host_session_; @@ -274,13 +274,13 @@ class PepperSessionTest : public testing::Test { // Verify that we can create and destroy session managers without a // connection. -TEST_F(PepperSessionTest, CreateAndDestoy) { +TEST_F(JingleSessionTest, CreateAndDestoy) { CreateSessionManagers(1, FakeAuthenticator::ACCEPT); } // Verify that an incoming session can be rejected, and that the // status of the connection is set to FAILED in this case. -TEST_F(PepperSessionTest, RejectConnection) { +TEST_F(JingleSessionTest, RejectConnection) { CreateSessionManagers(1, FakeAuthenticator::ACCEPT); // Reject incoming session. @@ -309,31 +309,31 @@ TEST_F(PepperSessionTest, RejectConnection) { } // Verify that we can connect two endpoints with single-step authentication. -TEST_F(PepperSessionTest, Connect) { +TEST_F(JingleSessionTest, Connect) { CreateSessionManagers(1, FakeAuthenticator::ACCEPT); InitiateConnection(1, FakeAuthenticator::ACCEPT, false); } // Verify that we can connect two endpoints with multi-step authentication. -TEST_F(PepperSessionTest, ConnectWithMultistep) { +TEST_F(JingleSessionTest, ConnectWithMultistep) { CreateSessionManagers(3, FakeAuthenticator::ACCEPT); InitiateConnection(3, FakeAuthenticator::ACCEPT, false); } // Verify that connection is terminated when single-step auth fails. -TEST_F(PepperSessionTest, ConnectWithBadAuth) { +TEST_F(JingleSessionTest, ConnectWithBadAuth) { CreateSessionManagers(1, FakeAuthenticator::REJECT); InitiateConnection(1, FakeAuthenticator::ACCEPT, true); } // Verify that connection is terminated when multi-step auth fails. -TEST_F(PepperSessionTest, ConnectWithBadMultistepAuth) { +TEST_F(JingleSessionTest, ConnectWithBadMultistepAuth) { CreateSessionManagers(3, FakeAuthenticator::REJECT); InitiateConnection(3, FakeAuthenticator::ACCEPT, true); } // Verify that data can be sent over stream channel. -TEST_F(PepperSessionTest, TestStreamChannel) { +TEST_F(JingleSessionTest, TestStreamChannel) { CreateSessionManagers(1, FakeAuthenticator::ACCEPT); ASSERT_NO_FATAL_FAILURE( InitiateConnection(1, FakeAuthenticator::ACCEPT, false)); @@ -348,7 +348,7 @@ TEST_F(PepperSessionTest, TestStreamChannel) { } // Verify that we can connect channels with multistep auth. -TEST_F(PepperSessionTest, TestMultistepAuthStreamChannel) { +TEST_F(JingleSessionTest, TestMultistepAuthStreamChannel) { CreateSessionManagers(3, FakeAuthenticator::ACCEPT); ASSERT_NO_FATAL_FAILURE( InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); @@ -363,7 +363,7 @@ TEST_F(PepperSessionTest, TestMultistepAuthStreamChannel) { } // Verify that we shutdown properly when channel authentication fails. -TEST_F(PepperSessionTest, TestFailedChannelAuth) { +TEST_F(JingleSessionTest, TestFailedChannelAuth) { CreateSessionManagers(1, FakeAuthenticator::ACCEPT); ASSERT_NO_FATAL_FAILURE( InitiateConnection(1, FakeAuthenticator::REJECT_CHANNEL, false)); diff --git a/remoting/protocol/pepper_channel.h b/remoting/protocol/pepper_channel.h deleted file mode 100644 index c908d70..0000000 --- a/remoting/protocol/pepper_channel.h +++ /dev/null @@ -1,56 +0,0 @@ -// 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. - -#ifndef REMOTING_PROTOCOL_PEPPER_CHANNEL_H_ -#define REMOTING_PROTOCOL_PEPPER_CHANNEL_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "base/threading/non_thread_safe.h" - -namespace pp { -class Instance; -} // namespace pp - -namespace cricket { -class Candidate; -} // namespace cricket - -namespace remoting { -namespace protocol { - -class ChannelAuthenticator; -struct TransportConfig; - -// Interface for stream and datagram channels used by PepperSession. -class PepperChannel : public base::NonThreadSafe { - public: - PepperChannel() { } - virtual ~PepperChannel() { } - - // Connect the channel using specified |config|. The specified - // |authenticator| is used to authenticate the channel. - virtual void Connect(pp::Instance* pp_instance, - const TransportConfig& config, - scoped_ptr<ChannelAuthenticator> authenticator) = 0; - - // Adds |candidate| received from the peer. - virtual void AddRemoteCandidate(const cricket::Candidate& candidate) = 0; - - // Name of the channel. - virtual const std::string& name() const = 0; - - // Returns true if the channel is already connected. - virtual bool is_connected() const = 0; - - protected: - DISALLOW_COPY_AND_ASSIGN(PepperChannel); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_PEPPER_CHANNEL_H_ diff --git a/remoting/protocol/pepper_stream_channel.h b/remoting/protocol/pepper_stream_channel.h deleted file mode 100644 index 693b643..0000000 --- a/remoting/protocol/pepper_stream_channel.h +++ /dev/null @@ -1,77 +0,0 @@ -// 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. - -#ifndef REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ -#define REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ - -#include <string> - -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "net/base/completion_callback.h" -#include "remoting/protocol/channel_authenticator.h" -#include "remoting/protocol/pepper_channel.h" -#include "remoting/protocol/pepper_transport_socket_adapter.h" -#include "remoting/protocol/session.h" - -namespace net { -class CertVerifier; -class StreamSocket; -class SSLClientSocket; -} // namespace net - -namespace remoting { -namespace protocol { - -class PepperSession; - -class PepperStreamChannel : public PepperChannel, - public PepperTransportSocketAdapter::Observer { - public: - PepperStreamChannel(PepperSession* session, - const std::string& name, - const Session::StreamChannelCallback& callback); - virtual ~PepperStreamChannel(); - - // PepperChannel implementation. - virtual void Connect(pp::Instance* pp_instance, - const TransportConfig& transport_config, - scoped_ptr<ChannelAuthenticator> authenticator) OVERRIDE; - virtual void AddRemoteCandidate(const cricket::Candidate& candidate) OVERRIDE; - virtual const std::string& name() const OVERRIDE; - virtual bool is_connected() const OVERRIDE; - - // PepperTransportSocketAdapter implementation. - virtual void OnChannelDeleted() OVERRIDE; - virtual void OnChannelNewLocalCandidate( - const std::string& candidate) OVERRIDE; - - private: - void OnP2PConnect(int result); - void OnAuthenticationDone(net::Error error, - scoped_ptr<net::StreamSocket> socket); - - void NotifyConnected(scoped_ptr<net::StreamSocket> socket); - void NotifyConnectFailed(); - - PepperSession* session_; - std::string name_; - Session::StreamChannelCallback callback_; - scoped_ptr<ChannelAuthenticator> authenticator_; - - // We own |channel_| until it is connected. After that - // |authenticator_| owns it. - scoped_ptr<PepperTransportSocketAdapter> owned_channel_; - PepperTransportSocketAdapter* channel_; - - // Indicates that we've finished connecting. - bool connected_; - - DISALLOW_COPY_AND_ASSIGN(PepperStreamChannel); -}; - -} // namespace protocol -} // namespace remoting - -#endif // REMOTING_PROTOCOL_PEPPER_STREAM_CHANNEL_H_ |