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

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: git sync 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 <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...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_(SpdyServersMap::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(".ggpht.com"); 38 canonical_suffixes_.push_back(".ggpht.com");
39 canonical_suffixes_.push_back(".c.youtube.com"); 39 canonical_suffixes_.push_back(".c.youtube.com");
40 canonical_suffixes_.push_back(".googlevideo.com"); 40 canonical_suffixes_.push_back(".googlevideo.com");
41 canonical_suffixes_.push_back(".googleusercontent.com"); 41 canonical_suffixes_.push_back(".googleusercontent.com");
42 } 42 }
43 43
44 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { 44 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
45 } 45 }
46 46
47 void HttpServerPropertiesImpl::InitializeSpdyServers( 47 void HttpServerPropertiesImpl::InitializeSpdyServers(
48 std::vector<std::string>* spdy_servers, 48 std::vector<std::string>* spdy_servers,
49 bool support_spdy) { 49 bool support_spdy) {
50 DCHECK(CalledOnValidThread()); 50 DCHECK(CalledOnValidThread());
51 if (!spdy_servers) 51 if (!spdy_servers)
52 return; 52 return;
53 53
54 // Add the entries from persisted data. 54 // Add the entries from persisted data.
55 SpdyServerHostPortMap spdy_servers_map(SpdyServerHostPortMap::NO_AUTO_EVICT); 55 SpdyServersMap spdy_servers_map(SpdyServersMap::NO_AUTO_EVICT);
56 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); 56 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin();
57 it != spdy_servers->rend(); ++it) { 57 it != spdy_servers->rend(); ++it) {
58 spdy_servers_map.Put(*it, support_spdy); 58 spdy_servers_map.Put(*it, support_spdy);
59 } 59 }
60 60
61 // |spdy_servers_map| will have the memory cache. 61 // |spdy_servers_map| will have the memory cache.
62 spdy_servers_map_.Swap(spdy_servers_map); 62 spdy_servers_map_.Swap(spdy_servers_map);
63 63
64 // Add the entries from the memory cache. 64 // Add the entries from the memory cache.
65 for (SpdyServerHostPortMap::reverse_iterator it = spdy_servers_map.rbegin(); 65 for (SpdyServersMap::reverse_iterator it = spdy_servers_map.rbegin();
66 it != spdy_servers_map.rend(); ++it) { 66 it != spdy_servers_map.rend(); ++it) {
67 // Add the entry if it is not in the cache, otherwise move it to the front 67 // Add the entry if it is not in the cache, otherwise move it to the front
68 // of recency list. 68 // of recency list.
69 if (spdy_servers_map_.Get(it->first) == spdy_servers_map_.end()) 69 if (spdy_servers_map_.Get(it->first) == spdy_servers_map_.end())
70 spdy_servers_map_.Put(it->first, it->second); 70 spdy_servers_map_.Put(it->first, it->second);
71 } 71 }
72 } 72 }
73 73
74 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers( 74 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers(
75 AlternativeServiceMap* alternative_service_map) { 75 AlternativeServiceMap* alternative_service_map) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 } 202 }
203 203
204 void HttpServerPropertiesImpl::GetSpdyServerList( 204 void HttpServerPropertiesImpl::GetSpdyServerList(
205 base::ListValue* spdy_server_list, 205 base::ListValue* spdy_server_list,
206 size_t max_size) const { 206 size_t max_size) const {
207 DCHECK(CalledOnValidThread()); 207 DCHECK(CalledOnValidThread());
208 DCHECK(spdy_server_list); 208 DCHECK(spdy_server_list);
209 spdy_server_list->Clear(); 209 spdy_server_list->Clear();
210 size_t count = 0; 210 size_t count = 0;
211 // Get the list of servers (host/port) that support SPDY. 211 // Get the list of servers (scheme/host/port) that support SPDY.
212 for (SpdyServerHostPortMap::const_iterator it = spdy_servers_map_.begin(); 212 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin();
213 it != spdy_servers_map_.end() && count < max_size; ++it) { 213 it != spdy_servers_map_.end() && count < max_size; ++it) {
214 const std::string spdy_server_host_port = it->first; 214 const std::string spdy_server = it->first;
215 if (it->second) { 215 if (it->second) {
216 spdy_server_list->Append(new base::StringValue(spdy_server_host_port)); 216 spdy_server_list->Append(new base::StringValue(spdy_server));
217 ++count; 217 ++count;
218 } 218 }
219 } 219 }
220 } 220 }
221 221
222 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { 222 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() {
223 return weak_ptr_factory_.GetWeakPtr(); 223 return weak_ptr_factory_.GetWeakPtr();
224 } 224 }
225 225
226 void HttpServerPropertiesImpl::Clear() { 226 void HttpServerPropertiesImpl::Clear() {
227 DCHECK(CalledOnValidThread()); 227 DCHECK(CalledOnValidThread());
228 spdy_servers_map_.Clear(); 228 spdy_servers_map_.Clear();
229 alternative_service_map_.Clear(); 229 alternative_service_map_.Clear();
230 canonical_host_to_origin_map_.clear(); 230 canonical_host_to_origin_map_.clear();
231 spdy_settings_map_.Clear(); 231 spdy_settings_map_.Clear();
232 last_quic_address_ = IPAddress(); 232 last_quic_address_ = IPAddress();
233 server_network_stats_map_.Clear(); 233 server_network_stats_map_.Clear();
234 quic_server_info_map_.Clear(); 234 quic_server_info_map_.Clear();
235 } 235 }
236 236
237 bool HttpServerPropertiesImpl::SupportsRequestPriority( 237 bool HttpServerPropertiesImpl::SupportsRequestPriority(
238 const HostPortPair& host_port_pair) { 238 const url::SchemeHostPort& server) {
239 HostPortPair host_port_pair(server.host(), server.port());
239 DCHECK(CalledOnValidThread()); 240 DCHECK(CalledOnValidThread());
240 if (host_port_pair.host().empty()) 241 if (server.host().empty())
241 return false; 242 return false;
242 243
243 if (GetSupportsSpdy(host_port_pair)) 244 if (GetSupportsSpdy(server))
244 return true; 245 return true;
245
246 const AlternativeServiceVector alternative_service_vector = 246 const AlternativeServiceVector alternative_service_vector =
247 GetAlternativeServices(host_port_pair); 247 GetAlternativeServices(host_port_pair);
248 for (const AlternativeService& alternative_service : 248 for (const AlternativeService& alternative_service :
249 alternative_service_vector) { 249 alternative_service_vector) {
250 if (alternative_service.protocol == QUIC) { 250 if (alternative_service.protocol == QUIC) {
251 return true; 251 return true;
252 } 252 }
253 } 253 }
254 return false; 254 return false;
255 } 255 }
256 256
257 bool HttpServerPropertiesImpl::GetSupportsSpdy( 257 bool HttpServerPropertiesImpl::GetSupportsSpdy(
258 const HostPortPair& host_port_pair) { 258 const url::SchemeHostPort& server) {
259 DCHECK(CalledOnValidThread()); 259 DCHECK(CalledOnValidThread());
260 if (host_port_pair.host().empty()) 260 if (server.host().empty())
261 return false; 261 return false;
262 262
263 SpdyServerHostPortMap::iterator spdy_host_port = 263 SpdyServersMap::iterator spdy_server =
264 spdy_servers_map_.Get(host_port_pair.ToString()); 264 spdy_servers_map_.Get(server.Serialize());
265 return spdy_host_port != spdy_servers_map_.end() && spdy_host_port->second; 265 return spdy_server != spdy_servers_map_.end() && spdy_server->second;
266 } 266 }
267 267
268 void HttpServerPropertiesImpl::SetSupportsSpdy( 268 void HttpServerPropertiesImpl::SetSupportsSpdy(
269 const HostPortPair& host_port_pair, 269 const url::SchemeHostPort& server,
270 bool support_spdy) { 270 bool support_spdy) {
271 DCHECK(CalledOnValidThread()); 271 DCHECK(CalledOnValidThread());
272 if (host_port_pair.host().empty()) 272 if (server.host().empty())
273 return; 273 return;
274 274
275 SpdyServerHostPortMap::iterator spdy_host_port = 275 SpdyServersMap::iterator spdy_server =
276 spdy_servers_map_.Get(host_port_pair.ToString()); 276 spdy_servers_map_.Get(server.Serialize());
277 if ((spdy_host_port != spdy_servers_map_.end()) && 277 if ((spdy_server != spdy_servers_map_.end()) &&
278 (spdy_host_port->second == support_spdy)) { 278 (spdy_server->second == support_spdy)) {
279 return; 279 return;
280 } 280 }
281 // Cache the data. 281 // Cache the data.
282 spdy_servers_map_.Put(host_port_pair.ToString(), support_spdy); 282 spdy_servers_map_.Put(server.Serialize(), support_spdy);
283 } 283 }
284 284
285 bool HttpServerPropertiesImpl::RequiresHTTP11( 285 bool HttpServerPropertiesImpl::RequiresHTTP11(
286 const HostPortPair& host_port_pair) { 286 const HostPortPair& host_port_pair) {
287 DCHECK(CalledOnValidThread()); 287 DCHECK(CalledOnValidThread());
288 if (host_port_pair.host().empty()) 288 if (host_port_pair.host().empty())
289 return false; 289 return false;
290 290
291 return (http11_servers_.find(host_port_pair) != http11_servers_.end()); 291 return (http11_servers_.find(host_port_pair) != http11_servers_.end());
292 } 292 }
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 800 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
801 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 801 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
802 FROM_HERE, 802 FROM_HERE,
803 base::Bind( 803 base::Bind(
804 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 804 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
805 weak_ptr_factory_.GetWeakPtr()), 805 weak_ptr_factory_.GetWeakPtr()),
806 delay); 806 delay);
807 } 807 }
808 808
809 } // namespace net 809 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.h ('k') | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698