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

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

Issue 1860343002: SHP 1: Change SupportsSpdy dict to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use proxy server scheme, remove hardcode Created 4 years, 8 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
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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace net { 22 namespace net {
23 23
24 namespace { 24 namespace {
25 25
26 const uint64_t kBrokenAlternativeProtocolDelaySecs = 300; 26 const uint64_t kBrokenAlternativeProtocolDelaySecs = 300;
27 27
28 } // namespace 28 } // namespace
29 29
30 HttpServerPropertiesImpl::HttpServerPropertiesImpl() 30 HttpServerPropertiesImpl::HttpServerPropertiesImpl()
31 : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT), 31 : spdy_servers_map_(SpdyServerMap::NO_AUTO_EVICT),
32 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), 32 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT),
33 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT), 33 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT),
34 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), 34 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT),
35 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), 35 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT),
36 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist), 36 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist),
37 weak_ptr_factory_(this) { 37 weak_ptr_factory_(this) {
38 canonical_suffixes_.push_back(".c.youtube.com"); 38 canonical_suffixes_.push_back(".c.youtube.com");
39 canonical_suffixes_.push_back(".googlevideo.com"); 39 canonical_suffixes_.push_back(".googlevideo.com");
40 canonical_suffixes_.push_back(".googleusercontent.com"); 40 canonical_suffixes_.push_back(".googleusercontent.com");
41 } 41 }
42 42
43 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { 43 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
44 } 44 }
45 45
46 void HttpServerPropertiesImpl::InitializeSpdyServers( 46 void HttpServerPropertiesImpl::InitializeSpdyServers(
47 std::vector<std::string>* spdy_servers, 47 std::vector<std::string>* spdy_servers,
48 bool support_spdy) { 48 bool support_spdy) {
49 DCHECK(CalledOnValidThread()); 49 DCHECK(CalledOnValidThread());
50 if (!spdy_servers) 50 if (!spdy_servers)
51 return; 51 return;
52 52
53 // Add the entries from persisted data. 53 // Add the entries from persisted data.
54 SpdyServerHostPortMap spdy_servers_map(SpdyServerHostPortMap::NO_AUTO_EVICT); 54 SpdyServerMap spdy_servers_map(SpdyServerMap::NO_AUTO_EVICT);
55 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); 55 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin();
56 it != spdy_servers->rend(); ++it) { 56 it != spdy_servers->rend(); ++it) {
57 spdy_servers_map.Put(*it, support_spdy); 57 spdy_servers_map.Put(*it, support_spdy);
58 } 58 }
59 59
60 // |spdy_servers_map| will have the memory cache. 60 // |spdy_servers_map| will have the memory cache.
61 spdy_servers_map_.Swap(spdy_servers_map); 61 spdy_servers_map_.Swap(spdy_servers_map);
62 62
63 // Add the entries from the memory cache. 63 // Add the entries from the memory cache.
64 for (SpdyServerHostPortMap::reverse_iterator it = spdy_servers_map.rbegin(); 64 for (SpdyServerMap::reverse_iterator it = spdy_servers_map.rbegin();
65 it != spdy_servers_map.rend(); ++it) { 65 it != spdy_servers_map.rend(); ++it) {
66 // Add the entry if it is not in the cache, otherwise move it to the front 66 // Add the entry if it is not in the cache, otherwise move it to the front
67 // of recency list. 67 // of recency list.
68 if (spdy_servers_map_.Get(it->first) == spdy_servers_map_.end()) 68 if (spdy_servers_map_.Get(it->first) == spdy_servers_map_.end())
69 spdy_servers_map_.Put(it->first, it->second); 69 spdy_servers_map_.Put(it->first, it->second);
70 } 70 }
71 } 71 }
72 72
73 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers( 73 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers(
74 AlternativeServiceMap* alternative_service_map) { 74 AlternativeServiceMap* alternative_service_map) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 } 201 }
202 202
203 void HttpServerPropertiesImpl::GetSpdyServerList( 203 void HttpServerPropertiesImpl::GetSpdyServerList(
204 base::ListValue* spdy_server_list, 204 base::ListValue* spdy_server_list,
205 size_t max_size) const { 205 size_t max_size) const {
206 DCHECK(CalledOnValidThread()); 206 DCHECK(CalledOnValidThread());
207 DCHECK(spdy_server_list); 207 DCHECK(spdy_server_list);
208 spdy_server_list->Clear(); 208 spdy_server_list->Clear();
209 size_t count = 0; 209 size_t count = 0;
210 // Get the list of servers (host/port) that support SPDY. 210 // Get the list of servers (scheme/host/port) that support SPDY.
211 for (SpdyServerHostPortMap::const_iterator it = spdy_servers_map_.begin(); 211 for (SpdyServerMap::const_iterator it = spdy_servers_map_.begin();
212 it != spdy_servers_map_.end() && count < max_size; ++it) { 212 it != spdy_servers_map_.end() && count < max_size; ++it) {
213 const std::string spdy_server_host_port = it->first; 213 const std::string spdy_server = it->first;
214 if (it->second) { 214 if (it->second) {
215 spdy_server_list->Append(new base::StringValue(spdy_server_host_port)); 215 spdy_server_list->Append(new base::StringValue(spdy_server));
216 ++count; 216 ++count;
217 } 217 }
218 } 218 }
219 } 219 }
220 220
221 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { 221 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() {
222 return weak_ptr_factory_.GetWeakPtr(); 222 return weak_ptr_factory_.GetWeakPtr();
223 } 223 }
224 224
225 void HttpServerPropertiesImpl::Clear() { 225 void HttpServerPropertiesImpl::Clear() {
226 DCHECK(CalledOnValidThread()); 226 DCHECK(CalledOnValidThread());
227 spdy_servers_map_.Clear(); 227 spdy_servers_map_.Clear();
228 alternative_service_map_.Clear(); 228 alternative_service_map_.Clear();
229 canonical_host_to_origin_map_.clear(); 229 canonical_host_to_origin_map_.clear();
230 spdy_settings_map_.Clear(); 230 spdy_settings_map_.Clear();
231 last_quic_address_ = IPAddress(); 231 last_quic_address_ = IPAddress();
232 server_network_stats_map_.Clear(); 232 server_network_stats_map_.Clear();
233 quic_server_info_map_.Clear(); 233 quic_server_info_map_.Clear();
234 } 234 }
235 235
236 bool HttpServerPropertiesImpl::SupportsRequestPriority( 236 bool HttpServerPropertiesImpl::SupportsRequestPriority(
237 const HostPortPair& host_port_pair) { 237 const url::SchemeHostPort& server) {
238 HostPortPair host_port_pair(server.host(), server.port());
238 DCHECK(CalledOnValidThread()); 239 DCHECK(CalledOnValidThread());
239 if (host_port_pair.host().empty()) 240 if (server.host().empty())
240 return false; 241 return false;
241 242
242 if (GetSupportsSpdy(host_port_pair)) 243 if (GetSupportsSpdy(server))
243 return true; 244 return true;
244
245 const AlternativeServiceVector alternative_service_vector = 245 const AlternativeServiceVector alternative_service_vector =
246 GetAlternativeServices(host_port_pair); 246 GetAlternativeServices(host_port_pair);
247 for (const AlternativeService& alternative_service : 247 for (const AlternativeService& alternative_service :
248 alternative_service_vector) { 248 alternative_service_vector) {
249 if (alternative_service.protocol == QUIC) { 249 if (alternative_service.protocol == QUIC) {
250 return true; 250 return true;
251 } 251 }
252 } 252 }
253 return false; 253 return false;
254 } 254 }
255 255
256 bool HttpServerPropertiesImpl::GetSupportsSpdy( 256 bool HttpServerPropertiesImpl::GetSupportsSpdy(
257 const HostPortPair& host_port_pair) { 257 const url::SchemeHostPort& server) {
258 DCHECK(CalledOnValidThread()); 258 DCHECK(CalledOnValidThread());
259 if (host_port_pair.host().empty()) 259 if (server.host().empty())
260 return false; 260 return false;
261 261
262 SpdyServerHostPortMap::iterator spdy_host_port = 262 SpdyServerMap::iterator spdy_server =
263 spdy_servers_map_.Get(host_port_pair.ToString()); 263 spdy_servers_map_.Get(server.Serialize());
264 return spdy_host_port != spdy_servers_map_.end() && spdy_host_port->second; 264 return spdy_server != spdy_servers_map_.end() && spdy_server->second;
265 } 265 }
266 266
267 void HttpServerPropertiesImpl::SetSupportsSpdy( 267 void HttpServerPropertiesImpl::SetSupportsSpdy(
268 const HostPortPair& host_port_pair, 268 const url::SchemeHostPort& server,
269 bool support_spdy) { 269 bool support_spdy) {
270 DCHECK(CalledOnValidThread()); 270 DCHECK(CalledOnValidThread());
271 if (host_port_pair.host().empty()) 271 if (server.host().empty())
272 return; 272 return;
273 273
274 SpdyServerHostPortMap::iterator spdy_host_port = 274 SpdyServerMap::iterator spdy_server =
275 spdy_servers_map_.Get(host_port_pair.ToString()); 275 spdy_servers_map_.Get(server.Serialize());
276 if ((spdy_host_port != spdy_servers_map_.end()) && 276 if ((spdy_server != spdy_servers_map_.end()) &&
277 (spdy_host_port->second == support_spdy)) { 277 (spdy_server->second == support_spdy)) {
278 return; 278 return;
279 } 279 }
280 // Cache the data. 280 // Cache the data.
281 spdy_servers_map_.Put(host_port_pair.ToString(), support_spdy); 281 spdy_servers_map_.Put(server.Serialize(), support_spdy);
282 } 282 }
283 283
284 bool HttpServerPropertiesImpl::RequiresHTTP11( 284 bool HttpServerPropertiesImpl::RequiresHTTP11(
285 const HostPortPair& host_port_pair) { 285 const HostPortPair& host_port_pair) {
286 DCHECK(CalledOnValidThread()); 286 DCHECK(CalledOnValidThread());
287 if (host_port_pair.host().empty()) 287 if (host_port_pair.host().empty())
288 return false; 288 return false;
289 289
290 return (http11_servers_.find(host_port_pair) != http11_servers_.end()); 290 return (http11_servers_.find(host_port_pair) != http11_servers_.end());
291 } 291 }
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 799 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
800 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 800 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
801 FROM_HERE, 801 FROM_HERE,
802 base::Bind( 802 base::Bind(
803 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 803 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
804 weak_ptr_factory_.GetWeakPtr()), 804 weak_ptr_factory_.GetWeakPtr()),
805 delay); 805 delay);
806 } 806 }
807 807
808 } // namespace net 808 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698