summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrtenneti <rtenneti@chromium.org>2015-09-21 12:51:13 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-21 19:51:48 +0000
commit8a80a6dc00d191cfa11f1285c979f9fa3ab9ca64 (patch)
tree3f4393557ecda070278a1b26585c1905801f9692 /net
parent756fba96076ff1f9701bb9ce92272dd147240c8b (diff)
downloadchromium_src-8a80a6dc00d191cfa11f1285c979f9fa3ab9ca64.zip
chromium_src-8a80a6dc00d191cfa11f1285c979f9fa3ab9ca64.tar.gz
chromium_src-8a80a6dc00d191cfa11f1285c979f9fa3ab9ca64.tar.bz2
QUIC - wait for disk cache to load server config if the server is among
the list of servers that have supported QUIC at startup. Other servers are considered as new servers and we will assume that they won't have server config in the disk. R=rch@chromium.org Review URL: https://codereview.chromium.org/1354223005 Cr-Commit-Position: refs/heads/master@{#349995}
Diffstat (limited to 'net')
-rw-r--r--net/quic/quic_stream_factory.cc51
-rw-r--r--net/quic/quic_stream_factory.h5
-rw-r--r--net/quic/quic_stream_factory_test.cc44
3 files changed, 72 insertions, 28 deletions
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index 2f75005..4aa8b76 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -629,6 +629,7 @@ QuicStreamFactory::QuicStreamFactory(
delay_tcp_race_(delay_tcp_race),
port_seed_(random_generator_->RandUint64()),
check_persisted_supports_quic_(true),
+ quic_supported_servers_at_startup_initialzied_(false),
task_runner_(nullptr),
weak_factory_(this) {
DCHECK(transport_security_state_);
@@ -726,23 +727,13 @@ int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
if (quic_server_info_factory_) {
bool load_from_disk_cache = !disable_disk_cache_;
if (http_server_properties_) {
- const AlternativeServiceMap& alternative_service_map =
- http_server_properties_->alternative_service_map();
- AlternativeServiceMap::const_iterator map_it =
- alternative_service_map.Peek(server_id.host_port_pair());
- if (map_it != alternative_service_map.end()) {
- const AlternativeServiceInfoVector& alternative_service_info_vector =
- map_it->second;
- AlternativeServiceInfoVector::const_iterator it;
- for (it = alternative_service_info_vector.begin();
- it != alternative_service_info_vector.end(); ++it) {
- if (it->alternative_service.protocol == QUIC)
- break;
- }
+ if (!quic_supported_servers_at_startup_initialzied_)
+ InitializeQuicSupportedServersAtStartup();
+ if (!ContainsKey(quic_supported_servers_at_startup_,
+ server_id.host_port_pair())) {
// If there is no entry for QUIC, consider that as a new server and
// don't wait for Cache thread to load the data for that server.
- if (it == alternative_service_info_vector.end())
- load_from_disk_cache = false;
+ load_from_disk_cache = false;
}
}
if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) {
@@ -1361,19 +1352,7 @@ void QuicStreamFactory::InitializeCachedStateInCryptoConfig(
return;
if (http_server_properties_) {
- if (quic_supported_servers_at_startup_.empty()) {
- for (const std::pair<const HostPortPair, AlternativeServiceInfoVector>&
- key_value : http_server_properties_->alternative_service_map()) {
- for (const AlternativeServiceInfo& alternative_service_info :
- key_value.second) {
- if (alternative_service_info.alternative_service.protocol == QUIC) {
- quic_supported_servers_at_startup_.insert(key_value.first);
- break;
- }
- }
- }
- }
-
+ DCHECK(quic_supported_servers_at_startup_initialzied_);
// TODO(rtenneti): Delete the following histogram after collecting stats.
// If the AlternativeServiceMap contained an entry for this host, check if
// the disk cache contained an entry for it.
@@ -1398,6 +1377,22 @@ void QuicStreamFactory::InitializeCachedStateInCryptoConfig(
}
}
+void QuicStreamFactory::InitializeQuicSupportedServersAtStartup() {
+ DCHECK(http_server_properties_);
+ DCHECK(!quic_supported_servers_at_startup_initialzied_);
+ quic_supported_servers_at_startup_initialzied_ = true;
+ for (const std::pair<const HostPortPair, AlternativeServiceInfoVector>&
+ key_value : http_server_properties_->alternative_service_map()) {
+ for (const AlternativeServiceInfo& alternative_service_info :
+ key_value.second) {
+ if (alternative_service_info.alternative_service.protocol == QUIC) {
+ quic_supported_servers_at_startup_.insert(key_value.first);
+ break;
+ }
+ }
+ }
+}
+
void QuicStreamFactory::ProcessGoingAwaySession(
QuicChromiumClientSession* session,
const QuicServerId& server_id,
diff --git a/net/quic/quic_stream_factory.h b/net/quic/quic_stream_factory.h
index c127362..b61ab237 100644
--- a/net/quic/quic_stream_factory.h
+++ b/net/quic/quic_stream_factory.h
@@ -326,6 +326,10 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
const QuicServerId& server_id,
const scoped_ptr<QuicServerInfo>& server_info);
+ // Initialize |quic_supported_servers_at_startup_| with the list of servers
+ // that supported QUIC at start up.
+ void InitializeQuicSupportedServersAtStartup();
+
void ProcessGoingAwaySession(QuicChromiumClientSession* session,
const QuicServerId& server_id,
bool was_session_active);
@@ -443,6 +447,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
// Local address of socket that was created in CreateSession.
IPEndPoint local_address_;
bool check_persisted_supports_quic_;
+ bool quic_supported_servers_at_startup_initialzied_;
std::set<HostPortPair> quic_supported_servers_at_startup_;
NetworkConnection network_connection_;
diff --git a/net/quic/quic_stream_factory_test.cc b/net/quic/quic_stream_factory_test.cc
index 0e35d64..3c2afbf 100644
--- a/net/quic/quic_stream_factory_test.cc
+++ b/net/quic/quic_stream_factory_test.cc
@@ -189,6 +189,22 @@ class QuicStreamFactoryPeer {
static int GetNumPublicResetsPostHandshake(QuicStreamFactory* factory) {
return factory->num_public_resets_post_handshake_;
}
+
+ static void InitializeQuicSupportedServersAtStartup(
+ QuicStreamFactory* factory) {
+ factory->InitializeQuicSupportedServersAtStartup();
+ }
+
+ static bool GetQuicSupportedServersAtStartupInitialzied(
+ QuicStreamFactory* factory) {
+ return factory->quic_supported_servers_at_startup_initialzied_;
+ }
+
+ static bool SupportsQuicAtStartUp(QuicStreamFactory* factory,
+ HostPortPair host_port_pair) {
+ return ContainsKey(factory->quic_supported_servers_at_startup_,
+ host_port_pair);
+ }
};
class MockQuicServerInfo : public QuicServerInfo {
@@ -2591,5 +2607,33 @@ TEST_P(QuicStreamFactoryTest, EnableDelayTcpRace) {
QuicStreamFactoryPeer::SetDelayTcpRace(&factory_, delay_tcp_race);
}
+TEST_P(QuicStreamFactoryTest, QuicSupportedServersAtStartup) {
+ factory_.set_quic_server_info_factory(&quic_server_info_factory_);
+ QuicStreamFactoryPeer::SetTaskRunner(&factory_, runner_.get());
+
+ // Set up data in HttpServerProperties.
+ scoped_ptr<HttpServerProperties> http_server_properties(
+ new HttpServerPropertiesImpl());
+ QuicStreamFactoryPeer::SetHttpServerProperties(
+ &factory_, http_server_properties->GetWeakPtr());
+
+ const AlternativeService alternative_service1(QUIC, host_port_pair_.host(),
+ host_port_pair_.port());
+ AlternativeServiceInfoVector alternative_service_info_vector;
+ base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
+ alternative_service_info_vector.push_back(
+ AlternativeServiceInfo(alternative_service1, 1.0, expiration));
+
+ http_server_properties->SetAlternativeServices(
+ host_port_pair_, alternative_service_info_vector);
+
+ QuicStreamFactoryPeer::InitializeQuicSupportedServersAtStartup(&factory_);
+ EXPECT_TRUE(
+ QuicStreamFactoryPeer::GetQuicSupportedServersAtStartupInitialzied(
+ &factory_));
+ EXPECT_TRUE(
+ QuicStreamFactoryPeer::SupportsQuicAtStartUp(&factory_, host_port_pair_));
+}
+
} // namespace test
} // namespace net