Commit b998b32f authored by rtenneti's avatar rtenneti Committed by Commit bot

QUIC - Construct crypto_stream_ in QuicClientSession::InitializeSession

instread of QuicClientSession's constructor to make it easier for server
side code to do the same.

Call QuicClientSessionBase::InitializeSession() after constructing
QuicCryptoClientStream.

This is done per discussion in interal change: 72671781

The following are the earlier related issues:
  https://codereview.chromium.org/393953009/
  https://codereview.chromium.org/407193002/

R=rch@chromium.org

Review URL: https://codereview.chromium.org/481103003

Cr-Commit-Position: refs/heads/master@{#291812}
parent 0bc497a8
...@@ -137,16 +137,12 @@ QuicClientSession::QuicClientSession( ...@@ -137,16 +137,12 @@ QuicClientSession::QuicClientSession(
QuicConnection* connection, QuicConnection* connection,
scoped_ptr<DatagramClientSocket> socket, scoped_ptr<DatagramClientSocket> socket,
QuicStreamFactory* stream_factory, QuicStreamFactory* stream_factory,
QuicCryptoClientStreamFactory* crypto_client_stream_factory,
TransportSecurityState* transport_security_state, TransportSecurityState* transport_security_state,
scoped_ptr<QuicServerInfo> server_info, scoped_ptr<QuicServerInfo> server_info,
const QuicServerId& server_id,
const QuicConfig& config, const QuicConfig& config,
QuicCryptoClientConfig* crypto_config,
base::TaskRunner* task_runner, base::TaskRunner* task_runner,
NetLog* net_log) NetLog* net_log)
: QuicClientSessionBase(connection, config), : QuicClientSessionBase(connection, config),
server_host_port_(server_id.host_port_pair()),
require_confirmation_(false), require_confirmation_(false),
stream_factory_(stream_factory), stream_factory_(stream_factory),
socket_(socket.Pass()), socket_(socket.Pass()),
...@@ -161,6 +157,14 @@ QuicClientSession::QuicClientSession( ...@@ -161,6 +157,14 @@ QuicClientSession::QuicClientSession(
num_packets_read_(0), num_packets_read_(0),
going_away_(false), going_away_(false),
weak_factory_(this) { weak_factory_(this) {
connection->set_debug_visitor(logger_);
}
void QuicClientSession::InitializeSession(
const QuicServerId& server_id,
QuicCryptoClientConfig* crypto_config,
QuicCryptoClientStreamFactory* crypto_client_stream_factory) {
server_host_port_.reset(new HostPortPair(server_id.host_port_pair()));
crypto_stream_.reset( crypto_stream_.reset(
crypto_client_stream_factory ? crypto_client_stream_factory ?
crypto_client_stream_factory->CreateQuicCryptoClientStream( crypto_client_stream_factory->CreateQuicCryptoClientStream(
...@@ -168,8 +172,7 @@ QuicClientSession::QuicClientSession( ...@@ -168,8 +172,7 @@ QuicClientSession::QuicClientSession(
new QuicCryptoClientStream(server_id, this, new QuicCryptoClientStream(server_id, this,
new ProofVerifyContextChromium(net_log_), new ProofVerifyContextChromium(net_log_),
crypto_config)); crypto_config));
QuicClientSessionBase::InitializeSession();
connection->set_debug_visitor(logger_);
// TODO(rch): pass in full host port proxy pair // TODO(rch): pass in full host port proxy pair
net_log_.BeginEvent( net_log_.BeginEvent(
NetLog::TYPE_QUIC_SESSION, NetLog::TYPE_QUIC_SESSION,
...@@ -491,7 +494,7 @@ bool QuicClientSession::CanPool(const std::string& hostname) const { ...@@ -491,7 +494,7 @@ bool QuicClientSession::CanPool(const std::string& hostname) const {
} }
return SpdySession::CanPool(transport_security_state_, ssl_info, return SpdySession::CanPool(transport_security_state_, ssl_info,
server_host_port_.host(), hostname); server_host_port_->host(), hostname);
} }
QuicDataStream* QuicClientSession::CreateIncomingDataStream( QuicDataStream* QuicClientSession::CreateIncomingDataStream(
......
...@@ -87,22 +87,25 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase { ...@@ -87,22 +87,25 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase {
DISALLOW_COPY_AND_ASSIGN(StreamRequest); DISALLOW_COPY_AND_ASSIGN(StreamRequest);
}; };
// Constructs a new session connected to |server_id| which will own // Constructs a new session which will own |connection|, but not
// |connection|, but not |stream_factory|, which must outlive this session. // |stream_factory|, which must outlive this session.
// TODO(rch): decouple the factory from the session via a Delegate interface. // TODO(rch): decouple the factory from the session via a Delegate interface.
QuicClientSession(QuicConnection* connection, QuicClientSession(QuicConnection* connection,
scoped_ptr<DatagramClientSocket> socket, scoped_ptr<DatagramClientSocket> socket,
QuicStreamFactory* stream_factory, QuicStreamFactory* stream_factory,
QuicCryptoClientStreamFactory* crypto_client_stream_factory,
TransportSecurityState* transport_security_state, TransportSecurityState* transport_security_state,
scoped_ptr<QuicServerInfo> server_info, scoped_ptr<QuicServerInfo> server_info,
const QuicServerId& server_id,
const QuicConfig& config, const QuicConfig& config,
QuicCryptoClientConfig* crypto_config,
base::TaskRunner* task_runner, base::TaskRunner* task_runner,
NetLog* net_log); NetLog* net_log);
virtual ~QuicClientSession(); virtual ~QuicClientSession();
// Initialize session's connection to |server_id|.
void InitializeSession(
const QuicServerId& server_id,
QuicCryptoClientConfig* config,
QuicCryptoClientStreamFactory* crypto_client_stream_factory);
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
...@@ -219,7 +222,7 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase { ...@@ -219,7 +222,7 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase {
void OnConnectTimeout(); void OnConnectTimeout();
const HostPortPair server_host_port_; scoped_ptr<HostPortPair> server_host_port_;
bool require_confirmation_; bool require_confirmation_;
scoped_ptr<QuicCryptoClientStream> crypto_stream_; scoped_ptr<QuicCryptoClientStream> crypto_stream_;
QuicStreamFactory* stream_factory_; QuicStreamFactory* stream_factory_;
......
...@@ -43,15 +43,14 @@ class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { ...@@ -43,15 +43,14 @@ class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> {
QuicClientSessionTest() QuicClientSessionTest()
: connection_( : connection_(
new PacketSavingConnection(false, SupportedVersions(GetParam()))), new PacketSavingConnection(false, SupportedVersions(GetParam()))),
session_(connection_, GetSocket().Pass(), NULL, NULL, session_(connection_, GetSocket().Pass(), NULL,
&transport_security_state_, &transport_security_state_,
make_scoped_ptr((QuicServerInfo*)NULL), make_scoped_ptr((QuicServerInfo*)NULL), DefaultQuicConfig(),
QuicServerId(kServerHostname, kServerPort, false,
PRIVACY_MODE_DISABLED),
DefaultQuicConfig(), &crypto_config_,
base::MessageLoop::current()->message_loop_proxy().get(), base::MessageLoop::current()->message_loop_proxy().get(),
&net_log_) { &net_log_) {
session_.InitializeSession(); session_.InitializeSession(QuicServerId(kServerHostname, kServerPort, false,
PRIVACY_MODE_DISABLED),
&crypto_config_, NULL);
session_.config()->SetDefaults(); session_.config()->SetDefaults();
crypto_config_.SetDefaults(); crypto_config_.SetDefaults();
} }
......
...@@ -228,16 +228,16 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<QuicVersion> { ...@@ -228,16 +228,16 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<QuicVersion> {
new QuicClientSession(connection_, new QuicClientSession(connection_,
scoped_ptr<DatagramClientSocket>(socket), scoped_ptr<DatagramClientSocket>(socket),
NULL, NULL,
&crypto_client_stream_factory_,
&transport_security_state_, &transport_security_state_,
make_scoped_ptr((QuicServerInfo*)NULL), make_scoped_ptr((QuicServerInfo*)NULL),
QuicServerId(kServerHostname, kServerPort, DefaultQuicConfig(),
false, PRIVACY_MODE_DISABLED),
DefaultQuicConfig(), &crypto_config_,
base::MessageLoop::current()-> base::MessageLoop::current()->
message_loop_proxy().get(), message_loop_proxy().get(),
NULL)); NULL));
session_->InitializeSession(); session_->InitializeSession(QuicServerId(kServerHostname, kServerPort,
false, PRIVACY_MODE_DISABLED),
&crypto_config_,
&crypto_client_stream_factory_);
session_->GetCryptoStream()->CryptoConnect(); session_->GetCryptoStream()->CryptoConnect();
EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed()); EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed());
stream_.reset(use_closing_stream_ ? stream_.reset(use_closing_stream_ ?
......
...@@ -876,12 +876,12 @@ int QuicStreamFactory::CreateSession( ...@@ -876,12 +876,12 @@ int QuicStreamFactory::CreateSession(
} }
*session = new QuicClientSession( *session = new QuicClientSession(
connection, socket.Pass(), this, connection, socket.Pass(), this, transport_security_state_,
quic_crypto_client_stream_factory_, transport_security_state_, server_info.Pass(), config,
server_info.Pass(), server_id, config, &crypto_config_,
base::MessageLoop::current()->message_loop_proxy().get(), base::MessageLoop::current()->message_loop_proxy().get(),
net_log.net_log()); net_log.net_log());
(*session)->InitializeSession(); (*session)->InitializeSession(server_id, &crypto_config_,
quic_crypto_client_stream_factory_);
all_sessions_[*session] = server_id; // owning pointer all_sessions_[*session] = server_id; // owning pointer
return OK; return OK;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment