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(
QuicConnection* connection,
scoped_ptr<DatagramClientSocket> socket,
QuicStreamFactory* stream_factory,
QuicCryptoClientStreamFactory* crypto_client_stream_factory,
TransportSecurityState* transport_security_state,
scoped_ptr<QuicServerInfo> server_info,
const QuicServerId& server_id,
const QuicConfig& config,
QuicCryptoClientConfig* crypto_config,
base::TaskRunner* task_runner,
NetLog* net_log)
: QuicClientSessionBase(connection, config),
server_host_port_(server_id.host_port_pair()),
require_confirmation_(false),
stream_factory_(stream_factory),
socket_(socket.Pass()),
......@@ -161,6 +157,14 @@ QuicClientSession::QuicClientSession(
num_packets_read_(0),
going_away_(false),
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_client_stream_factory ?
crypto_client_stream_factory->CreateQuicCryptoClientStream(
......@@ -168,8 +172,7 @@ QuicClientSession::QuicClientSession(
new QuicCryptoClientStream(server_id, this,
new ProofVerifyContextChromium(net_log_),
crypto_config));
connection->set_debug_visitor(logger_);
QuicClientSessionBase::InitializeSession();
// TODO(rch): pass in full host port proxy pair
net_log_.BeginEvent(
NetLog::TYPE_QUIC_SESSION,
......@@ -491,7 +494,7 @@ bool QuicClientSession::CanPool(const std::string& hostname) const {
}
return SpdySession::CanPool(transport_security_state_, ssl_info,
server_host_port_.host(), hostname);
server_host_port_->host(), hostname);
}
QuicDataStream* QuicClientSession::CreateIncomingDataStream(
......
......@@ -87,22 +87,25 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase {
DISALLOW_COPY_AND_ASSIGN(StreamRequest);
};
// Constructs a new session connected to |server_id| which will own
// |connection|, but not |stream_factory|, which must outlive this session.
// Constructs a new session which will own |connection|, but not
// |stream_factory|, which must outlive this session.
// TODO(rch): decouple the factory from the session via a Delegate interface.
QuicClientSession(QuicConnection* connection,
scoped_ptr<DatagramClientSocket> socket,
QuicStreamFactory* stream_factory,
QuicCryptoClientStreamFactory* crypto_client_stream_factory,
TransportSecurityState* transport_security_state,
scoped_ptr<QuicServerInfo> server_info,
const QuicServerId& server_id,
const QuicConfig& config,
QuicCryptoClientConfig* crypto_config,
base::TaskRunner* task_runner,
NetLog* net_log);
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 RemoveObserver(Observer* observer);
......@@ -219,7 +222,7 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase {
void OnConnectTimeout();
const HostPortPair server_host_port_;
scoped_ptr<HostPortPair> server_host_port_;
bool require_confirmation_;
scoped_ptr<QuicCryptoClientStream> crypto_stream_;
QuicStreamFactory* stream_factory_;
......
......@@ -43,15 +43,14 @@ class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> {
QuicClientSessionTest()
: connection_(
new PacketSavingConnection(false, SupportedVersions(GetParam()))),
session_(connection_, GetSocket().Pass(), NULL, NULL,
session_(connection_, GetSocket().Pass(), NULL,
&transport_security_state_,
make_scoped_ptr((QuicServerInfo*)NULL),
QuicServerId(kServerHostname, kServerPort, false,
PRIVACY_MODE_DISABLED),
DefaultQuicConfig(), &crypto_config_,
make_scoped_ptr((QuicServerInfo*)NULL), DefaultQuicConfig(),
base::MessageLoop::current()->message_loop_proxy().get(),
&net_log_) {
session_.InitializeSession();
session_.InitializeSession(QuicServerId(kServerHostname, kServerPort, false,
PRIVACY_MODE_DISABLED),
&crypto_config_, NULL);
session_.config()->SetDefaults();
crypto_config_.SetDefaults();
}
......
......@@ -228,16 +228,16 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<QuicVersion> {
new QuicClientSession(connection_,
scoped_ptr<DatagramClientSocket>(socket),
NULL,
&crypto_client_stream_factory_,
&transport_security_state_,
make_scoped_ptr((QuicServerInfo*)NULL),
QuicServerId(kServerHostname, kServerPort,
false, PRIVACY_MODE_DISABLED),
DefaultQuicConfig(), &crypto_config_,
DefaultQuicConfig(),
base::MessageLoop::current()->
message_loop_proxy().get(),
NULL));
session_->InitializeSession();
session_->InitializeSession(QuicServerId(kServerHostname, kServerPort,
false, PRIVACY_MODE_DISABLED),
&crypto_config_,
&crypto_client_stream_factory_);
session_->GetCryptoStream()->CryptoConnect();
EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed());
stream_.reset(use_closing_stream_ ?
......
......@@ -876,12 +876,12 @@ int QuicStreamFactory::CreateSession(
}
*session = new QuicClientSession(
connection, socket.Pass(), this,
quic_crypto_client_stream_factory_, transport_security_state_,
server_info.Pass(), server_id, config, &crypto_config_,
connection, socket.Pass(), this, transport_security_state_,
server_info.Pass(), config,
base::MessageLoop::current()->message_loop_proxy().get(),
net_log.net_log());
(*session)->InitializeSession();
(*session)->InitializeSession(server_id, &crypto_config_,
quic_crypto_client_stream_factory_);
all_sessions_[*session] = server_id; // owning pointer
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