Chromium Code Reviews| Index: remoting/protocol/jingle_session.cc |
| diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc |
| index 3638e893746c280b8c1f1a8cbf1125d15309fd1d..c31083161821212b9594b025f2098b0bdd3958cf 100644 |
| --- a/remoting/protocol/jingle_session.cc |
| +++ b/remoting/protocol/jingle_session.cc |
| @@ -12,12 +12,15 @@ |
| #include "base/thread_task_runner_handle.h" |
| #include "base/time/time.h" |
| #include "remoting/base/constants.h" |
| +#include "remoting/protocol/authenticated_channel_factory.h" |
| #include "remoting/protocol/authenticator.h" |
| #include "remoting/protocol/channel_authenticator.h" |
| +#include "remoting/protocol/channel_factory.h" |
| #include "remoting/protocol/channel_multiplexer.h" |
| #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/session_config.h" |
| #include "remoting/signaling/iq_sender.h" |
| #include "third_party/libjingle/source/talk/p2p/base/candidate.h" |
| @@ -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()) { |
| @@ -220,13 +223,15 @@ void JingleSession::set_config(const SessionConfig& config) { |
| ChannelFactory* JingleSession::GetTransportChannelFactory() { |
| DCHECK(CalledOnValidThread()); |
| - return this; |
| + return authenticated_channel_factory_.get(); |
| } |
| ChannelFactory* 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,11 +259,9 @@ 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()); |
| + scoped_ptr<Transport> channel = |
| + session_manager_->transport_factory_->CreateTransport(); |
| + channel->Initialize(name, this); |
| channel->Connect(callback); |
| AddPendingRemoteCandidates(channel.get(), name); |
| channels_[name] = channel.release(); |
| @@ -598,13 +601,21 @@ 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)); |
| + authenticated_channel_factory_.reset(new AuthenticatedChannelFactory( |
| + pseudotcp_channel_factory_.get(), authenticator_.get())); |
|
Wez
2014/09/10 02:29:26
nit: Although it's an extra line, I'd suggest wrap
Sergey Ulanov
2014/09/10 21:50:58
Done.
|
| + |
| + SetState(AUTHENTICATED); |
| +} |
| + |
| void JingleSession::CloseInternal(ErrorCode error) { |
| DCHECK(CalledOnValidThread()); |