Chromium Code Reviews| Index: remoting/protocol/jingle_session.cc |
| diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc |
| index 727be4b073c2845f47c03f802154a9ee34b05ec6..e6eb1e8a9b28da968d90ca2c9e435b9921669234 100644 |
| --- a/remoting/protocol/jingle_session.cc |
| +++ b/remoting/protocol/jingle_session.cc |
| @@ -18,7 +18,10 @@ |
| #include "remoting/protocol/content_description.h" |
| #include "remoting/protocol/jingle_messages.h" |
| #include "remoting/protocol/jingle_session_manager.h" |
| +#include "remoting/protocol/pseudotcp_channel_factory.h" |
| +#include "remoting/protocol/secure_channel_factory.h" |
| #include "remoting/protocol/session_config.h" |
| +#include "remoting/protocol/stream_channel_factory.h" |
| #include "remoting/signaling/iq_sender.h" |
| #include "third_party/libjingle/source/talk/p2p/base/candidate.h" |
| #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| @@ -81,7 +84,7 @@ JingleSession::~JingleSession() { |
| pending_requests_.end()); |
| STLDeleteContainerPointers(transport_info_requests_.begin(), |
| transport_info_requests_.end()); |
| - STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); |
| + DCHECK(channels_.empty()); |
| session_manager_->SessionDestroyed(this); |
| } |
| @@ -187,7 +190,7 @@ void JingleSession::ContinueAcceptIncomingConnection() { |
| SetState(CONNECTED); |
| if (authenticator_->state() == Authenticator::ACCEPTED) { |
| - SetState(AUTHENTICATED); |
| + OnAuthenticated(); |
| } else { |
| DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE); |
| if (authenticator_->started()) { |
| @@ -218,15 +221,17 @@ void JingleSession::set_config(const SessionConfig& config) { |
| config_is_set_ = true; |
| } |
| -ChannelFactory* JingleSession::GetTransportChannelFactory() { |
| +StreamChannelFactory* JingleSession::GetTransportChannelFactory() { |
| DCHECK(CalledOnValidThread()); |
| - return this; |
| + return secure_channel_factory_.get(); |
| } |
| -ChannelFactory* JingleSession::GetMultiplexedChannelFactory() { |
| +StreamChannelFactory* JingleSession::GetMultiplexedChannelFactory() { |
| DCHECK(CalledOnValidThread()); |
| - if (!channel_multiplexer_.get()) |
| - channel_multiplexer_.reset(new ChannelMultiplexer(this, kMuxChannelName)); |
| + if (!channel_multiplexer_.get()) { |
| + channel_multiplexer_.reset( |
| + new ChannelMultiplexer(GetTransportChannelFactory(), kMuxChannelName)); |
| + } |
| return channel_multiplexer_.get(); |
| } |
| @@ -254,19 +259,17 @@ void JingleSession::CreateChannel(const std::string& name, |
| const ChannelCreatedCallback& callback) { |
| DCHECK(!channels_[name]); |
| - scoped_ptr<ChannelAuthenticator> channel_authenticator = |
| - authenticator_->CreateChannelAuthenticator(); |
| - scoped_ptr<StreamTransport> channel = |
| - session_manager_->transport_factory_->CreateStreamTransport(); |
| - channel->Initialize(name, this, channel_authenticator.Pass()); |
| - channel->Connect(callback); |
| + scoped_ptr<Transport> channel = |
| + session_manager_->transport_factory_->CreateTransport(); |
| + channel->Connect(name, this, callback); |
| AddPendingRemoteCandidates(channel.get(), name); |
| channels_[name] = channel.release(); |
| } |
| void JingleSession::CancelChannelCreation(const std::string& name) { |
| ChannelsMap::iterator it = channels_.find(name); |
| - if (it != channels_.end() && !it->second->is_connected()) { |
| + if (it != channels_.end()) { |
| + DCHECK(!it->second->is_connected()); |
|
Wez
2014/09/10 22:19:42
Is there any possibility of a race condition here,
Sergey Ulanov
2014/09/10 22:49:31
I don't think so. Both events happen on the same t
|
| delete it->second; |
| DCHECK(!channels_[name]); |
| } |
| @@ -598,13 +601,22 @@ void JingleSession::ProcessAuthenticationStep() { |
| void JingleSession::ContinueAuthenticationStep() { |
| if (authenticator_->state() == Authenticator::ACCEPTED) { |
| - SetState(AUTHENTICATED); |
| + OnAuthenticated(); |
| } else if (authenticator_->state() == Authenticator::REJECTED) { |
| CloseInternal(AuthRejectionReasonToErrorCode( |
| authenticator_->rejection_reason())); |
| } |
| } |
| +void JingleSession::OnAuthenticated() { |
| + pseudotcp_channel_factory_.reset(new PseudoTcpChannelFactory(this)); |
| + secure_channel_factory_.reset( |
| + new SecureChannelFactory(pseudotcp_channel_factory_.get(), |
| + authenticator_.get())); |
| + |
| + SetState(AUTHENTICATED); |
| +} |
| + |
| void JingleSession::CloseInternal(ErrorCode error) { |
| DCHECK(CalledOnValidThread()); |