summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 22:08:51 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 22:08:51 +0000
commit3b8cf7f403950054b3e8d4398146ce4b8854f36b (patch)
treebf10ca8507ebeac325c700f810453ec98bd91607
parent33ed5f8e92e48ad85f9a81f6c6c7b1d8c56ffb02 (diff)
downloadchromium_src-3b8cf7f403950054b3e8d4398146ce4b8854f36b.zip
chromium_src-3b8cf7f403950054b3e8d4398146ce4b8854f36b.tar.gz
chromium_src-3b8cf7f403950054b3e8d4398146ce4b8854f36b.tar.bz2
Save the clients RTT estimate to the HTTP server properties and send it
to the server in CHLO packets. Review URL: https://codereview.chromium.org/143983004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247313 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/net/http_server_properties_manager.cc12
-rw-r--r--chrome/browser/net/http_server_properties_manager.h6
-rw-r--r--net/http/http_server_properties.h12
-rw-r--r--net/http/http_server_properties_impl.cc17
-rw-r--r--net/http/http_server_properties_impl.h8
-rw-r--r--net/quic/quic_stream_factory.cc25
6 files changed, 78 insertions, 2 deletions
diff --git a/chrome/browser/net/http_server_properties_manager.cc b/chrome/browser/net/http_server_properties_manager.cc
index 77579d3..1bde25e 100644
--- a/chrome/browser/net/http_server_properties_manager.cc
+++ b/chrome/browser/net/http_server_properties_manager.cc
@@ -222,6 +222,18 @@ HttpServerPropertiesManager::spdy_settings_map() const {
return http_server_properties_impl_->spdy_settings_map();
}
+void HttpServerPropertiesManager::SetServerNetworkStats(
+ const net::HostPortPair& host_port_pair,
+ NetworkStats stats) {
+ http_server_properties_impl_->SetServerNetworkStats(host_port_pair, stats);
+}
+
+const HttpServerPropertiesManager::NetworkStats*
+HttpServerPropertiesManager::GetServerNetworkStats(
+ const net::HostPortPair& host_port_pair) const {
+ return http_server_properties_impl_->GetServerNetworkStats(host_port_pair);
+}
+
net::HttpPipelinedHostCapability
HttpServerPropertiesManager::GetPipelineCapability(
const net::HostPortPair& origin) {
diff --git a/chrome/browser/net/http_server_properties_manager.h b/chrome/browser/net/http_server_properties_manager.h
index a2a52a7..83b49f6 100644
--- a/chrome/browser/net/http_server_properties_manager.h
+++ b/chrome/browser/net/http_server_properties_manager.h
@@ -141,6 +141,12 @@ class HttpServerPropertiesManager
// Returns all SPDY persistent settings.
virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE;
+ virtual void SetServerNetworkStats(const net::HostPortPair& host_port_pair,
+ NetworkStats stats) OVERRIDE;
+
+ virtual const NetworkStats* GetServerNetworkStats(
+ const net::HostPortPair& host_port_pair) const OVERRIDE;
+
virtual net::HttpPipelinedHostCapability GetPipelineCapability(
const net::HostPortPair& origin) OVERRIDE;
diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h
index 72fda43..e10d2de 100644
--- a/net/http/http_server_properties.h
+++ b/net/http/http_server_properties.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
#include "net/base/host_port_pair.h"
#include "net/base/net_export.h"
#include "net/http/http_pipelined_host_capability.h"
@@ -75,6 +76,11 @@ extern const char kAlternateProtocolHeader[];
// * Spdy Settings (like CWND ID field)
class NET_EXPORT HttpServerProperties {
public:
+ struct NetworkStats {
+ base::TimeDelta rtt;
+ uint64 bandwidth_estimate;
+ };
+
HttpServerProperties() {}
virtual ~HttpServerProperties() {}
@@ -132,6 +138,12 @@ class NET_EXPORT HttpServerProperties {
// Returns all persistent SPDY settings.
virtual const SpdySettingsMap& spdy_settings_map() const = 0;
+ virtual void SetServerNetworkStats(const HostPortPair& host_port_pair,
+ NetworkStats stats) = 0;
+
+ virtual const NetworkStats* GetServerNetworkStats(
+ const HostPortPair& host_port_pair) const = 0;
+
virtual HttpPipelinedHostCapability GetPipelineCapability(
const HostPortPair& origin) = 0;
diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc
index a4ac6dc..13a42af 100644
--- a/net/http/http_server_properties_impl.cc
+++ b/net/http/http_server_properties_impl.cc
@@ -263,6 +263,23 @@ HttpServerPropertiesImpl::spdy_settings_map() const {
return spdy_settings_map_;
}
+void HttpServerPropertiesImpl::SetServerNetworkStats(
+ const HostPortPair& host_port_pair,
+ NetworkStats stats) {
+ server_network_stats_map_[host_port_pair] = stats;
+}
+
+const HttpServerProperties::NetworkStats*
+HttpServerPropertiesImpl::GetServerNetworkStats(
+ const HostPortPair& host_port_pair) const {
+ ServerNetworkStatsMap::const_iterator it =
+ server_network_stats_map_.find(host_port_pair);
+ if (it == server_network_stats_map_.end()) {
+ return NULL;
+ }
+ return &it->second;
+}
+
HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability(
const HostPortPair& origin) {
HttpPipelinedHostCapability capability = PIPELINE_UNKNOWN;
diff --git a/net/http/http_server_properties_impl.h b/net/http/http_server_properties_impl.h
index cf96b7d..68b6ca9 100644
--- a/net/http/http_server_properties_impl.h
+++ b/net/http/http_server_properties_impl.h
@@ -127,6 +127,12 @@ class NET_EXPORT HttpServerPropertiesImpl
// Returns all persistent SPDY settings.
virtual const SpdySettingsMap& spdy_settings_map() const OVERRIDE;
+ virtual void SetServerNetworkStats(const HostPortPair& host_port_pair,
+ NetworkStats stats) OVERRIDE;
+
+ virtual const NetworkStats* GetServerNetworkStats(
+ const HostPortPair& host_port_pair) const OVERRIDE;
+
virtual HttpPipelinedHostCapability GetPipelineCapability(
const HostPortPair& origin) OVERRIDE;
@@ -144,11 +150,13 @@ class NET_EXPORT HttpServerPropertiesImpl
// |spdy_servers_table_| has flattened representation of servers (host/port
// pair) that either support or not support SPDY protocol.
typedef base::hash_map<std::string, bool> SpdyServerHostPortTable;
+ typedef std::map<HostPortPair, NetworkStats> ServerNetworkStatsMap;
SpdyServerHostPortTable spdy_servers_table_;
AlternateProtocolMap alternate_protocol_map_;
SpdySettingsMap spdy_settings_map_;
+ ServerNetworkStatsMap server_network_stats_map_;
scoped_ptr<CachedPipelineCapabilityMap> pipeline_capability_map_;
base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_;
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index 06e7825..8e50615 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -421,12 +421,22 @@ void QuicStreamFactory::OnSessionGoingAway(QuicClientSession* session) {
DCHECK(active_sessions_.count(*it));
DCHECK_EQ(session, active_sessions_[*it]);
active_sessions_.erase(*it);
- if (!session->IsCryptoHandshakeConfirmed() && http_server_properties_) {
+ if (!http_server_properties_)
+ continue;
+
+ if (!session->IsCryptoHandshakeConfirmed()) {
// TODO(rch): In the special case where the session has received no
// packets from the peer, we should consider blacklisting this
// differently so that we still race TCP but we don't consider the
// session connected until the handshake has been confirmed.
http_server_properties_->SetBrokenAlternateProtocol(it->first);
+ } else {
+ QuicConnectionStats stats = session->connection()->GetStats();
+ HttpServerProperties::NetworkStats network_stats;
+ network_stats.rtt = base::TimeDelta::FromMicroseconds(stats.rtt);
+ network_stats.bandwidth_estimate = stats.estimated_bandwidth;
+ http_server_properties_->SetServerNetworkStats(
+ it->first, network_stats);
}
}
IPEndPoint peer_address = session->connection()->peer_address();
@@ -568,10 +578,21 @@ int QuicStreamFactory::CreateSession(
GetOrCreateCryptoConfig(host_port_proxy_pair);
DCHECK(crypto_config);
+ QuicConfig config = config_;
+ if (http_server_properties_) {
+ const HttpServerProperties::NetworkStats* stats =
+ http_server_properties_->GetServerNetworkStats(
+ host_port_proxy_pair.first);
+ if (stats != NULL) {
+ config.set_initial_round_trip_time_us(stats->rtt.InMicroseconds(),
+ stats->rtt.InMicroseconds());
+ }
+ }
+
*session = new QuicClientSession(
connection, socket.Pass(), writer.Pass(), this,
quic_crypto_client_stream_factory_, host_port_proxy_pair.first.host(),
- config_, crypto_config, net_log.net_log());
+ config, crypto_config, net_log.net_log());
all_sessions_.insert(*session); // owning pointer
if (is_https) {
crypto_config->SetProofVerifier(