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

QUIC - Persist if we have used Quic (and IP Address of local

machine) in prefs persistent store.

It is temporarily saved under kDummyHostname
(quic.global.props). Will change the code to save it in
globals in the next CL.

R=rch@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#296867}
parent 385034b4
...@@ -71,6 +71,9 @@ const int32 kServerSecureInitialCongestionWindow = 32; ...@@ -71,6 +71,9 @@ const int32 kServerSecureInitialCongestionWindow = 32;
// Be conservative, and just use double a typical TCP ICWND for HTTP. // Be conservative, and just use double a typical TCP ICWND for HTTP.
const int32 kServerInecureInitialCongestionWindow = 20; const int32 kServerInecureInitialCongestionWindow = 20;
const char kDummyHostname[] = "quic.global.props";
const uint16 kDummyPort = 0;
void HistogramCreateSessionFailure(enum CreateSessionFailure error) { void HistogramCreateSessionFailure(enum CreateSessionFailure error) {
UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error,
CREATION_ERROR_MAX); CREATION_ERROR_MAX);
...@@ -510,6 +513,7 @@ QuicStreamFactory::QuicStreamFactory( ...@@ -510,6 +513,7 @@ QuicStreamFactory::QuicStreamFactory(
always_require_handshake_confirmation), always_require_handshake_confirmation),
disable_connection_pooling_(disable_connection_pooling), disable_connection_pooling_(disable_connection_pooling),
port_seed_(random_generator_->RandUint64()), port_seed_(random_generator_->RandUint64()),
check_persisted_supports_quic_(true),
weak_factory_(this) { weak_factory_(this) {
DCHECK(transport_security_state_); DCHECK(transport_security_state_);
crypto_config_.SetDefaults(); crypto_config_.SetDefaults();
...@@ -536,6 +540,17 @@ QuicStreamFactory::~QuicStreamFactory() { ...@@ -536,6 +540,17 @@ QuicStreamFactory::~QuicStreamFactory() {
STLDeleteValues(&active_jobs_); STLDeleteValues(&active_jobs_);
} }
void QuicStreamFactory::set_require_confirmation(bool require_confirmation) {
require_confirmation_ = require_confirmation;
if (http_server_properties_ && (!(local_address_ == IPEndPoint()))) {
// TODO(rtenneti): Delete host_port_pair and persist data in globals.
HostPortPair host_port_pair(kDummyHostname, kDummyPort);
http_server_properties_->SetSupportsQuic(
host_port_pair, !require_confirmation,
local_address_.ToStringWithoutPort());
}
}
int QuicStreamFactory::Create(const HostPortPair& host_port_pair, int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
bool is_https, bool is_https,
PrivacyMode privacy_mode, PrivacyMode privacy_mode,
...@@ -616,7 +631,7 @@ bool QuicStreamFactory::OnResolution( ...@@ -616,7 +631,7 @@ bool QuicStreamFactory::OnResolution(
void QuicStreamFactory::OnJobComplete(Job* job, int rv) { void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
if (rv == OK) { if (rv == OK) {
if (!always_require_handshake_confirmation_) if (!always_require_handshake_confirmation_)
require_confirmation_ = false; set_require_confirmation(false);
// Create all the streams, but do not notify them yet. // Create all the streams, but do not notify them yet.
for (RequestSet::iterator it = job_requests_map_[job].begin(); for (RequestSet::iterator it = job_requests_map_[job].begin();
...@@ -772,7 +787,7 @@ void QuicStreamFactory::ClearCachedStatesInCryptoConfig() { ...@@ -772,7 +787,7 @@ void QuicStreamFactory::ClearCachedStatesInCryptoConfig() {
void QuicStreamFactory::OnIPAddressChanged() { void QuicStreamFactory::OnIPAddressChanged() {
CloseAllSessions(ERR_NETWORK_CHANGED); CloseAllSessions(ERR_NETWORK_CHANGED);
require_confirmation_ = true; set_require_confirmation(true);
} }
void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) {
...@@ -857,6 +872,18 @@ int QuicStreamFactory::CreateSession( ...@@ -857,6 +872,18 @@ int QuicStreamFactory::CreateSession(
return rv; return rv;
} }
socket->GetLocalAddress(&local_address_);
if (check_persisted_supports_quic_ && http_server_properties_) {
check_persisted_supports_quic_ = false;
// TODO(rtenneti): Delete host_port_pair and persist data in globals.
HostPortPair host_port_pair(kDummyHostname, kDummyPort);
SupportsQuic supports_quic(true, local_address_.ToStringWithoutPort());
if (http_server_properties_->GetSupportsQuic(
host_port_pair).Equals(supports_quic)) {
require_confirmation_ = false;
}
}
DefaultPacketWriterFactory packet_writer_factory(socket.get()); DefaultPacketWriterFactory packet_writer_factory(socket.get());
if (!helper_.get()) { if (!helper_.get()) {
......
...@@ -160,9 +160,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory ...@@ -160,9 +160,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
return require_confirmation_; return require_confirmation_;
} }
void set_require_confirmation(bool require_confirmation) { void set_require_confirmation(bool require_confirmation);
require_confirmation_ = require_confirmation;
}
QuicConnectionHelper* helper() { return helper_.get(); } QuicConnectionHelper* helper() { return helper_.get(); }
...@@ -293,6 +291,10 @@ class NET_EXPORT_PRIVATE QuicStreamFactory ...@@ -293,6 +291,10 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
// port requests. // port requests.
uint64 port_seed_; uint64 port_seed_;
// Local address of socket that was created in CreateSession.
IPEndPoint local_address_;
bool check_persisted_supports_quic_;
base::WeakPtrFactory<QuicStreamFactory> weak_factory_; base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
......
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