Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: net/http/http_server_properties_impl.cc

Issue 275953002: Remove HTTP pipelining support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_server_properties_impl.h" 5 #include "net/http/http_server_properties_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "net/http/http_pipelined_host_capability.h"
15 14
16 namespace net { 15 namespace net {
17 16
18 namespace { 17 namespace {
19 18
20 // TODO(simonjam): Run experiments with different values of this to see what
21 // value is good at avoiding evictions without eating too much memory. Until
22 // then, this is just a bad guess.
23 const int kDefaultNumHostsToRemember = 200;
24
25 const uint64 kBrokenAlternateProtocolDelaySecs = 300; 19 const uint64 kBrokenAlternateProtocolDelaySecs = 300;
26 20
27 } // namespace 21 } // namespace
28 22
29 HttpServerPropertiesImpl::HttpServerPropertiesImpl() 23 HttpServerPropertiesImpl::HttpServerPropertiesImpl()
30 : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT), 24 : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT),
31 alternate_protocol_map_(AlternateProtocolMap::NO_AUTO_EVICT), 25 alternate_protocol_map_(AlternateProtocolMap::NO_AUTO_EVICT),
32 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT), 26 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT),
33 pipeline_capability_map_(
34 new CachedPipelineCapabilityMap(kDefaultNumHostsToRemember)),
35 weak_ptr_factory_(this) { 27 weak_ptr_factory_(this) {
36 canoncial_suffixes_.push_back(".c.youtube.com"); 28 canoncial_suffixes_.push_back(".c.youtube.com");
37 canoncial_suffixes_.push_back(".googlevideo.com"); 29 canoncial_suffixes_.push_back(".googlevideo.com");
38 } 30 }
39 31
40 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { 32 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
41 } 33 }
42 34
43 void HttpServerPropertiesImpl::InitializeSpdyServers( 35 void HttpServerPropertiesImpl::InitializeSpdyServers(
44 std::vector<std::string>* spdy_servers, 36 std::vector<std::string>* spdy_servers,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 92 }
101 93
102 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( 94 void HttpServerPropertiesImpl::InitializeSpdySettingsServers(
103 SpdySettingsMap* spdy_settings_map) { 95 SpdySettingsMap* spdy_settings_map) {
104 for (SpdySettingsMap::reverse_iterator it = spdy_settings_map->rbegin(); 96 for (SpdySettingsMap::reverse_iterator it = spdy_settings_map->rbegin();
105 it != spdy_settings_map->rend(); ++it) { 97 it != spdy_settings_map->rend(); ++it) {
106 spdy_settings_map_.Put(it->first, it->second); 98 spdy_settings_map_.Put(it->first, it->second);
107 } 99 }
108 } 100 }
109 101
110 void HttpServerPropertiesImpl::InitializePipelineCapabilities(
111 const PipelineCapabilityMap* pipeline_capability_map) {
112 PipelineCapabilityMap::const_iterator it;
113 pipeline_capability_map_->Clear();
114 for (it = pipeline_capability_map->begin();
115 it != pipeline_capability_map->end(); ++it) {
116 pipeline_capability_map_->Put(it->first, it->second);
117 }
118 }
119
120 void HttpServerPropertiesImpl::SetNumPipelinedHostsToRemember(int max_size) {
121 DCHECK(pipeline_capability_map_->empty());
122 pipeline_capability_map_.reset(new CachedPipelineCapabilityMap(max_size));
123 }
124
125 void HttpServerPropertiesImpl::GetSpdyServerList( 102 void HttpServerPropertiesImpl::GetSpdyServerList(
126 base::ListValue* spdy_server_list, 103 base::ListValue* spdy_server_list,
127 size_t max_size) const { 104 size_t max_size) const {
128 DCHECK(CalledOnValidThread()); 105 DCHECK(CalledOnValidThread());
129 DCHECK(spdy_server_list); 106 DCHECK(spdy_server_list);
130 spdy_server_list->Clear(); 107 spdy_server_list->Clear();
131 size_t count = 0; 108 size_t count = 0;
132 // Get the list of servers (host/port) that support SPDY. 109 // Get the list of servers (host/port) that support SPDY.
133 for (SpdyServerHostPortMap::const_iterator it = spdy_servers_map_.begin(); 110 for (SpdyServerHostPortMap::const_iterator it = spdy_servers_map_.begin();
134 it != spdy_servers_map_.end() && count < max_size; ++it) { 111 it != spdy_servers_map_.end() && count < max_size; ++it) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 146
170 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { 147 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() {
171 return weak_ptr_factory_.GetWeakPtr(); 148 return weak_ptr_factory_.GetWeakPtr();
172 } 149 }
173 150
174 void HttpServerPropertiesImpl::Clear() { 151 void HttpServerPropertiesImpl::Clear() {
175 DCHECK(CalledOnValidThread()); 152 DCHECK(CalledOnValidThread());
176 spdy_servers_map_.Clear(); 153 spdy_servers_map_.Clear();
177 alternate_protocol_map_.Clear(); 154 alternate_protocol_map_.Clear();
178 spdy_settings_map_.Clear(); 155 spdy_settings_map_.Clear();
179 pipeline_capability_map_->Clear();
180 } 156 }
181 157
182 bool HttpServerPropertiesImpl::SupportsSpdy( 158 bool HttpServerPropertiesImpl::SupportsSpdy(
183 const net::HostPortPair& host_port_pair) { 159 const net::HostPortPair& host_port_pair) {
184 DCHECK(CalledOnValidThread()); 160 DCHECK(CalledOnValidThread());
185 if (host_port_pair.host().empty()) 161 if (host_port_pair.host().empty())
186 return false; 162 return false;
187 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair); 163 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair);
188 164
189 SpdyServerHostPortMap::iterator spdy_host_port = 165 SpdyServerHostPortMap::iterator spdy_host_port =
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 HttpServerPropertiesImpl::GetServerNetworkStats( 373 HttpServerPropertiesImpl::GetServerNetworkStats(
398 const HostPortPair& host_port_pair) const { 374 const HostPortPair& host_port_pair) const {
399 ServerNetworkStatsMap::const_iterator it = 375 ServerNetworkStatsMap::const_iterator it =
400 server_network_stats_map_.find(host_port_pair); 376 server_network_stats_map_.find(host_port_pair);
401 if (it == server_network_stats_map_.end()) { 377 if (it == server_network_stats_map_.end()) {
402 return NULL; 378 return NULL;
403 } 379 }
404 return &it->second; 380 return &it->second;
405 } 381 }
406 382
407 HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability(
408 const HostPortPair& origin) {
409 HttpPipelinedHostCapability capability = PIPELINE_UNKNOWN;
410 CachedPipelineCapabilityMap::const_iterator it =
411 pipeline_capability_map_->Get(origin);
412 if (it != pipeline_capability_map_->end()) {
413 capability = it->second;
414 }
415 return capability;
416 }
417
418 void HttpServerPropertiesImpl::SetPipelineCapability(
419 const HostPortPair& origin,
420 HttpPipelinedHostCapability capability) {
421 CachedPipelineCapabilityMap::iterator it =
422 pipeline_capability_map_->Peek(origin);
423 if (it == pipeline_capability_map_->end() ||
424 it->second != PIPELINE_INCAPABLE) {
425 pipeline_capability_map_->Put(origin, capability);
426 }
427 }
428
429 void HttpServerPropertiesImpl::ClearPipelineCapabilities() {
430 pipeline_capability_map_->Clear();
431 }
432
433 PipelineCapabilityMap
434 HttpServerPropertiesImpl::GetPipelineCapabilityMap() const {
435 PipelineCapabilityMap result;
436 CachedPipelineCapabilityMap::const_iterator it;
437 for (it = pipeline_capability_map_->begin();
438 it != pipeline_capability_map_->end(); ++it) {
439 result[it->first] = it->second;
440 }
441 return result;
442 }
443
444 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator 383 HttpServerPropertiesImpl::CanonicalHostMap::const_iterator
445 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const { 384 HttpServerPropertiesImpl::GetCanonicalHost(HostPortPair server) const {
446 for (size_t i = 0; i < canoncial_suffixes_.size(); ++i) { 385 for (size_t i = 0; i < canoncial_suffixes_.size(); ++i) {
447 std::string canonical_suffix = canoncial_suffixes_[i]; 386 std::string canonical_suffix = canoncial_suffixes_[i];
448 if (EndsWith(server.host(), canoncial_suffixes_[i], false)) { 387 if (EndsWith(server.host(), canoncial_suffixes_[i], false)) {
449 HostPortPair canonical_host(canonical_suffix, server.port()); 388 HostPortPair canonical_host(canonical_suffix, server.port());
450 return canonical_host_to_origin_map_.find(canonical_host); 389 return canonical_host_to_origin_map_.find(canonical_host);
451 } 390 }
452 } 391 }
453 392
(...skipping 25 matching lines...) Expand all
479 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 418 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
480 base::MessageLoop::current()->PostDelayedTask( 419 base::MessageLoop::current()->PostDelayedTask(
481 FROM_HERE, 420 FROM_HERE,
482 base::Bind( 421 base::Bind(
483 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 422 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
484 weak_ptr_factory_.GetWeakPtr()), 423 weak_ptr_factory_.GetWeakPtr()),
485 delay); 424 delay);
486 } 425 }
487 426
488 } // namespace net 427 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698