| Index: net/quic/quic_stream_factory.cc
|
| diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
|
| index 642914d3d9404ab103d0e4aed740538994b476f7..f57c2eeeafbb9a501cb55f67be620c8e23cc3317 100644
|
| --- a/net/quic/quic_stream_factory.cc
|
| +++ b/net/quic/quic_stream_factory.cc
|
| @@ -57,8 +57,8 @@ enum CreateSessionFailure {
|
| const int32 kInitialReceiveWindowSize = 10 * 1024 * 1024; // 10MB
|
|
|
| void HistogramCreateSessionFailure(enum CreateSessionFailure error) {
|
| - UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error,
|
| - CREATION_ERROR_MAX);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + "Net.QuicSession.CreationError", error, CREATION_ERROR_MAX);
|
| }
|
|
|
| bool IsEcdsaSupported() {
|
| @@ -72,14 +72,15 @@ bool IsEcdsaSupported() {
|
|
|
| } // namespace
|
|
|
| -QuicStreamFactory::IpAliasKey::IpAliasKey() {}
|
| +QuicStreamFactory::IpAliasKey::IpAliasKey() {
|
| +}
|
|
|
| -QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint,
|
| - bool is_https)
|
| - : ip_endpoint(ip_endpoint),
|
| - is_https(is_https) {}
|
| +QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint, bool is_https)
|
| + : ip_endpoint(ip_endpoint), is_https(is_https) {
|
| +}
|
|
|
| -QuicStreamFactory::IpAliasKey::~IpAliasKey() {}
|
| +QuicStreamFactory::IpAliasKey::~IpAliasKey() {
|
| +}
|
|
|
| bool QuicStreamFactory::IpAliasKey::operator<(
|
| const QuicStreamFactory::IpAliasKey& other) const {
|
| @@ -91,8 +92,7 @@ bool QuicStreamFactory::IpAliasKey::operator<(
|
|
|
| bool QuicStreamFactory::IpAliasKey::operator==(
|
| const QuicStreamFactory::IpAliasKey& other) const {
|
| - return is_https == other.is_https &&
|
| - ip_endpoint == other.ip_endpoint;
|
| + return is_https == other.is_https && ip_endpoint == other.ip_endpoint;
|
| };
|
|
|
| // Responsible for creating a new QUIC session to the specified server, and
|
| @@ -123,13 +123,9 @@ class QuicStreamFactory::Job {
|
|
|
| void OnIOComplete(int rv);
|
|
|
| - CompletionCallback callback() {
|
| - return callback_;
|
| - }
|
| + CompletionCallback callback() { return callback_; }
|
|
|
| - const QuicServerId server_id() const {
|
| - return server_id_;
|
| - }
|
| + const QuicServerId server_id() const { return server_id_; }
|
|
|
| private:
|
| enum IoState {
|
| @@ -176,7 +172,8 @@ QuicStreamFactory::Job::Job(QuicStreamFactory* factory,
|
| server_info_(server_info),
|
| net_log_(net_log),
|
| session_(NULL),
|
| - weak_factory_(this) {}
|
| + weak_factory_(this) {
|
| +}
|
|
|
| QuicStreamFactory::Job::~Job() {
|
| }
|
| @@ -271,9 +268,8 @@ int QuicStreamFactory::Job::DoLoadServerInfo() {
|
| if (!server_info_)
|
| return OK;
|
|
|
| - return server_info_->WaitForDataReady(
|
| - base::Bind(&QuicStreamFactory::Job::OnIOComplete,
|
| - weak_factory_.GetWeakPtr()));
|
| + return server_info_->WaitForDataReady(base::Bind(
|
| + &QuicStreamFactory::Job::OnIOComplete, weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) {
|
| @@ -293,8 +289,8 @@ int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) {
|
| int QuicStreamFactory::Job::DoConnect() {
|
| io_state_ = STATE_CONNECT_COMPLETE;
|
|
|
| - int rv = factory_->CreateSession(server_id_, server_info_.Pass(),
|
| - address_list_, net_log_, &session_);
|
| + int rv = factory_->CreateSession(
|
| + server_id_, server_info_.Pass(), address_list_, net_log_, &session_);
|
| if (rv != OK) {
|
| DCHECK(rv != ERR_IO_PENDING);
|
| DCHECK(!session_);
|
| @@ -305,13 +301,12 @@ int QuicStreamFactory::Job::DoConnect() {
|
| if (!session_->connection()->connected()) {
|
| return ERR_QUIC_PROTOCOL_ERROR;
|
| }
|
| - bool require_confirmation =
|
| - factory_->require_confirmation() || server_id_.is_https() || is_post_ ||
|
| - was_alternate_protocol_recently_broken_;
|
| - rv = session_->CryptoConnect(
|
| - require_confirmation,
|
| - base::Bind(&QuicStreamFactory::Job::OnIOComplete,
|
| - base::Unretained(this)));
|
| + bool require_confirmation = factory_->require_confirmation() ||
|
| + server_id_.is_https() || is_post_ ||
|
| + was_alternate_protocol_recently_broken_;
|
| + rv = session_->CryptoConnect(require_confirmation,
|
| + base::Bind(&QuicStreamFactory::Job::OnIOComplete,
|
| + base::Unretained(this)));
|
| return rv;
|
| }
|
|
|
| @@ -335,7 +330,8 @@ int QuicStreamFactory::Job::DoConnectComplete(int rv) {
|
| }
|
|
|
| QuicStreamRequest::QuicStreamRequest(QuicStreamFactory* factory)
|
| - : factory_(factory) {}
|
| + : factory_(factory) {
|
| +}
|
|
|
| QuicStreamRequest::~QuicStreamRequest() {
|
| if (factory_ && !callback_.is_null())
|
| @@ -351,8 +347,8 @@ int QuicStreamRequest::Request(const HostPortPair& host_port_pair,
|
| DCHECK(!stream_);
|
| DCHECK(callback_.is_null());
|
| DCHECK(factory_);
|
| - int rv = factory_->Create(host_port_pair, is_https, privacy_mode, method,
|
| - net_log, this);
|
| + int rv = factory_->Create(
|
| + host_port_pair, is_https, privacy_mode, method, net_log, this);
|
| if (rv == ERR_IO_PENDING) {
|
| host_port_pair_ = host_port_pair;
|
| is_https_ = is_https;
|
| @@ -413,9 +409,8 @@ QuicStreamFactory::QuicStreamFactory(
|
| config_.EnablePacing(enable_pacing_);
|
| if (enable_time_based_loss_detection)
|
| config_.SetLossDetectionToSend(kTIME);
|
| - config_.set_idle_connection_state_lifetime(
|
| - QuicTime::Delta::FromSeconds(30),
|
| - QuicTime::Delta::FromSeconds(30));
|
| + config_.set_idle_connection_state_lifetime(QuicTime::Delta::FromSeconds(30),
|
| + QuicTime::Delta::FromSeconds(30));
|
|
|
| crypto_config_.SetDefaults();
|
| crypto_config_.AddCanonicalSuffix(".c.youtube.com");
|
| @@ -469,11 +464,17 @@ int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
|
| http_server_properties_ &&
|
| http_server_properties_->WasAlternateProtocolRecentlyBroken(
|
| server_id.host_port_pair());
|
| - scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, is_https,
|
| + scoped_ptr<Job> job(new Job(this,
|
| + host_resolver_,
|
| + host_port_pair,
|
| + is_https,
|
| was_alternate_protocol_recently_broken,
|
| - privacy_mode, method, quic_server_info, net_log));
|
| - int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete,
|
| - base::Unretained(this), job.get()));
|
| + privacy_mode,
|
| + method,
|
| + quic_server_info,
|
| + net_log));
|
| + int rv = job->Run(base::Bind(
|
| + &QuicStreamFactory::OnJobComplete, base::Unretained(this), job.get()));
|
|
|
| if (rv == ERR_IO_PENDING) {
|
| active_requests_[request] = job.get();
|
| @@ -487,9 +488,8 @@ int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
|
| return rv;
|
| }
|
|
|
| -bool QuicStreamFactory::OnResolution(
|
| - const QuicServerId& server_id,
|
| - const AddressList& address_list) {
|
| +bool QuicStreamFactory::OnResolution(const QuicServerId& server_id,
|
| + const AddressList& address_list) {
|
| DCHECK(!HasActiveSession(server_id));
|
| for (size_t i = 0; i < address_list.size(); ++i) {
|
| const IPEndPoint& address = address_list[i];
|
| @@ -498,8 +498,8 @@ bool QuicStreamFactory::OnResolution(
|
| continue;
|
|
|
| const SessionSet& sessions = ip_aliases_[ip_alias_key];
|
| - for (SessionSet::const_iterator i = sessions.begin();
|
| - i != sessions.end(); ++i) {
|
| + for (SessionSet::const_iterator i = sessions.begin(); i != sessions.end();
|
| + ++i) {
|
| QuicClientSession* session = *i;
|
| if (!session->CanPool(server_id.host()))
|
| continue;
|
| @@ -517,10 +517,11 @@ void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
|
|
|
| // Create all the streams, but do not notify them yet.
|
| for (RequestSet::iterator it = job_requests_map_[job].begin();
|
| - it != job_requests_map_[job].end() ; ++it) {
|
| + it != job_requests_map_[job].end();
|
| + ++it) {
|
| DCHECK(HasActiveSession(job->server_id()));
|
| - (*it)->set_stream(CreateIfSessionExists(job->server_id(),
|
| - (*it)->net_log()));
|
| + (*it)->set_stream(
|
| + CreateIfSessionExists(job->server_id(), (*it)->net_log()));
|
| }
|
| }
|
| while (!job_requests_map_[job].empty()) {
|
| @@ -551,8 +552,7 @@ scoped_ptr<QuicHttpStream> QuicStreamFactory::CreateIfSessionExists(
|
|
|
| QuicClientSession* session = active_sessions_[server_id];
|
| DCHECK(session);
|
| - return scoped_ptr<QuicHttpStream>(
|
| - new QuicHttpStream(session->GetWeakPtr()));
|
| + return scoped_ptr<QuicHttpStream>(new QuicHttpStream(session->GetWeakPtr()));
|
| }
|
|
|
| void QuicStreamFactory::OnIdleSession(QuicClientSession* session) {
|
| @@ -617,7 +617,8 @@ base::Value* QuicStreamFactory::QuicStreamFactoryInfoToValue() const {
|
| base::ListValue* list = new base::ListValue();
|
|
|
| for (SessionMap::const_iterator it = active_sessions_.begin();
|
| - it != active_sessions_.end(); ++it) {
|
| + it != active_sessions_.end();
|
| + ++it) {
|
| const QuicServerId& server_id = it->first;
|
| QuicClientSession* session = it->second;
|
| const AliasSet& aliases = session_aliases_.find(session)->second;
|
| @@ -625,7 +626,8 @@ base::Value* QuicStreamFactory::QuicStreamFactoryInfoToValue() const {
|
| if (server_id == *aliases.begin()) {
|
| std::set<HostPortPair> hosts;
|
| for (AliasSet::const_iterator alias_it = aliases.begin();
|
| - alias_it != aliases.end(); ++alias_it) {
|
| + alias_it != aliases.end();
|
| + ++alias_it) {
|
| hosts.insert(alias_it->host_port_pair());
|
| }
|
| list->Append(session->GetInfoAsValue(hosts));
|
| @@ -660,20 +662,17 @@ void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) {
|
| CloseAllSessions(ERR_CERT_DATABASE_CHANGED);
|
| }
|
|
|
| -bool QuicStreamFactory::HasActiveSession(
|
| - const QuicServerId& server_id) const {
|
| +bool QuicStreamFactory::HasActiveSession(const QuicServerId& server_id) const {
|
| return ContainsKey(active_sessions_, server_id);
|
| }
|
|
|
| -int QuicStreamFactory::CreateSession(
|
| - const QuicServerId& server_id,
|
| - scoped_ptr<QuicServerInfo> server_info,
|
| - const AddressList& address_list,
|
| - const BoundNetLog& net_log,
|
| - QuicClientSession** session) {
|
| +int QuicStreamFactory::CreateSession(const QuicServerId& server_id,
|
| + scoped_ptr<QuicServerInfo> server_info,
|
| + const AddressList& address_list,
|
| + const BoundNetLog& net_log,
|
| + QuicClientSession** session) {
|
| bool enable_port_selection = enable_port_selection_;
|
| - if (enable_port_selection &&
|
| - ContainsKey(gone_away_aliases_, server_id)) {
|
| + if (enable_port_selection && ContainsKey(gone_away_aliases_, server_id)) {
|
| // Disable port selection when the server is going away.
|
| // There is no point in trying to return to the same server, if
|
| // that server is no longer handling requests.
|
| @@ -685,14 +684,16 @@ int QuicStreamFactory::CreateSession(
|
| IPEndPoint addr = *address_list.begin();
|
| scoped_refptr<PortSuggester> port_suggester =
|
| new PortSuggester(server_id.host_port_pair(), port_seed_);
|
| - DatagramSocket::BindType bind_type = enable_port_selection ?
|
| - DatagramSocket::RANDOM_BIND : // Use our callback.
|
| - DatagramSocket::DEFAULT_BIND; // Use OS to randomize.
|
| + DatagramSocket::BindType bind_type =
|
| + enable_port_selection ? DatagramSocket::RANDOM_BIND
|
| + : // Use our callback.
|
| + DatagramSocket::DEFAULT_BIND; // Use OS to randomize.
|
| scoped_ptr<DatagramClientSocket> socket(
|
| client_socket_factory_->CreateDatagramClientSocket(
|
| bind_type,
|
| base::Bind(&PortSuggester::SuggestPort, port_suggester),
|
| - net_log.net_log(), net_log.source()));
|
| + net_log.net_log(),
|
| + net_log.source()));
|
| int rv = socket->Connect(addr);
|
| if (rv != OK) {
|
| HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET);
|
| @@ -731,12 +732,17 @@ int QuicStreamFactory::CreateSession(
|
| if (!helper_.get()) {
|
| helper_.reset(new QuicConnectionHelper(
|
| base::MessageLoop::current()->message_loop_proxy().get(),
|
| - clock_.get(), random_generator_));
|
| + clock_.get(),
|
| + random_generator_));
|
| }
|
|
|
| - QuicConnection* connection =
|
| - new QuicConnection(connection_id, addr, helper_.get(), writer.get(),
|
| - false, supported_versions_, kInitialReceiveWindowSize);
|
| + QuicConnection* connection = new QuicConnection(connection_id,
|
| + addr,
|
| + helper_.get(),
|
| + writer.get(),
|
| + false,
|
| + supported_versions_,
|
| + kInitialReceiveWindowSize);
|
| writer->SetConnection(connection);
|
| connection->options()->max_packet_length = max_packet_length_;
|
|
|
| @@ -752,10 +758,16 @@ int QuicStreamFactory::CreateSession(
|
| }
|
| }
|
|
|
| - *session = new QuicClientSession(
|
| - connection, socket.Pass(), writer.Pass(), this,
|
| - quic_crypto_client_stream_factory_, server_info.Pass(), server_id,
|
| - config, &crypto_config_, net_log.net_log());
|
| + *session = new QuicClientSession(connection,
|
| + socket.Pass(),
|
| + writer.Pass(),
|
| + this,
|
| + quic_crypto_client_stream_factory_,
|
| + server_info.Pass(),
|
| + server_id,
|
| + config,
|
| + &crypto_config_,
|
| + net_log.net_log());
|
| all_sessions_[*session] = server_id; // owning pointer
|
| return OK;
|
| }
|
| @@ -764,9 +776,8 @@ bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const {
|
| return ContainsKey(active_jobs_, key);
|
| }
|
|
|
| -void QuicStreamFactory::ActivateSession(
|
| - const QuicServerId& server_id,
|
| - QuicClientSession* session) {
|
| +void QuicStreamFactory::ActivateSession(const QuicServerId& server_id,
|
| + QuicClientSession* session) {
|
| DCHECK(!HasActiveSession(server_id));
|
| active_sessions_[server_id] = session;
|
| session_aliases_[session].insert(server_id);
|
| @@ -800,9 +811,8 @@ void QuicStreamFactory::InitializeCachedStateInCryptoConfig(
|
| }
|
| }
|
|
|
| -void QuicStreamFactory::ProcessGoingAwaySession(
|
| - QuicClientSession* session,
|
| - const QuicServerId& server_id) {
|
| +void QuicStreamFactory::ProcessGoingAwaySession(QuicClientSession* session,
|
| + const QuicServerId& server_id) {
|
| if (!http_server_properties_)
|
| return;
|
|
|
|
|