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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 "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"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void HttpServerPropertiesImpl::Clear() { 161 void HttpServerPropertiesImpl::Clear() {
162 DCHECK(CalledOnValidThread()); 162 DCHECK(CalledOnValidThread());
163 spdy_servers_map_.Clear(); 163 spdy_servers_map_.Clear();
164 alternate_protocol_map_.Clear(); 164 alternate_protocol_map_.Clear();
165 canonical_host_to_origin_map_.clear(); 165 canonical_host_to_origin_map_.clear();
166 spdy_settings_map_.Clear(); 166 spdy_settings_map_.Clear();
167 supports_quic_map_.clear(); 167 supports_quic_map_.clear();
168 server_network_stats_map_.Clear(); 168 server_network_stats_map_.Clear();
169 } 169 }
170 170
171 bool HttpServerPropertiesImpl::SupportsSpdy( 171 bool HttpServerPropertiesImpl::SupportsRequestPriority(
172 const HostPortPair& host_port_pair) { 172 const HostPortPair& host_port_pair) {
173 DCHECK(CalledOnValidThread()); 173 DCHECK(CalledOnValidThread());
174 if (host_port_pair.host().empty()) 174 if (host_port_pair.host().empty())
175 return false; 175 return false;
176 176
177 SpdyServerHostPortMap::iterator spdy_host_port = 177 SpdyServerHostPortMap::iterator spdy_host_port =
178 spdy_servers_map_.Get(host_port_pair.ToString()); 178 spdy_servers_map_.Get(host_port_pair.ToString());
179 if (spdy_host_port != spdy_servers_map_.end()) 179 if (spdy_host_port != spdy_servers_map_.end() && spdy_host_port->second)
180 return spdy_host_port->second; 180 return true;
181 return false; 181
182 if (!HasAlternateProtocol(host_port_pair))
183 return false;
184
185 AlternateProtocolInfo info = GetAlternateProtocol(host_port_pair);
186 return info.protocol == QUIC;
182 } 187 }
183 188
184 void HttpServerPropertiesImpl::SetSupportsSpdy( 189 void HttpServerPropertiesImpl::SetSupportsSpdy(
185 const HostPortPair& host_port_pair, 190 const HostPortPair& host_port_pair,
186 bool support_spdy) { 191 bool support_spdy) {
187 DCHECK(CalledOnValidThread()); 192 DCHECK(CalledOnValidThread());
188 if (host_port_pair.host().empty()) 193 if (host_port_pair.host().empty())
189 return; 194 return;
190 195
191 SpdyServerHostPortMap::iterator spdy_host_port = 196 SpdyServerHostPortMap::iterator spdy_host_port =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 const HostPortPair& server) { 232 const HostPortPair& server) {
228 if (g_forced_alternate_protocol) 233 if (g_forced_alternate_protocol)
229 return true; 234 return true;
230 AlternateProtocolMap::const_iterator it = 235 AlternateProtocolMap::const_iterator it =
231 GetAlternateProtocolIterator(server); 236 GetAlternateProtocolIterator(server);
232 return it != alternate_protocol_map_.end() && 237 return it != alternate_protocol_map_.end() &&
233 it->second.probability >= alternate_protocol_probability_threshold_; 238 it->second.probability >= alternate_protocol_probability_threshold_;
234 } 239 }
235 240
236 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( 241 std::string HttpServerPropertiesImpl::GetCanonicalSuffix(
237 const HostPortPair& server) { 242 const std::string& host) {
238 // If this host ends with a canonical suffix, then return the canonical 243 // If this host ends with a canonical suffix, then return the canonical
239 // suffix. 244 // suffix.
240 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { 245 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) {
241 std::string canonical_suffix = canonical_suffixes_[i]; 246 std::string canonical_suffix = canonical_suffixes_[i];
242 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { 247 if (EndsWith(host, canonical_suffixes_[i], false)) {
243 return canonical_suffix; 248 return canonical_suffix;
244 } 249 }
245 } 250 }
246 return std::string(); 251 return std::string();
247 } 252 }
248 253
249 AlternateProtocolInfo 254 AlternateProtocolInfo
250 HttpServerPropertiesImpl::GetAlternateProtocol( 255 HttpServerPropertiesImpl::GetAlternateProtocol(
251 const HostPortPair& server) { 256 const HostPortPair& server) {
252 DCHECK(HasAlternateProtocol(server)); 257 DCHECK(HasAlternateProtocol(server));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 BrokenAlternateProtocolEntry entry; 339 BrokenAlternateProtocolEntry entry;
335 entry.server = server; 340 entry.server = server;
336 entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1)); 341 entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1));
337 broken_alternate_protocol_list_.push_back(entry); 342 broken_alternate_protocol_list_.push_back(entry);
338 343
339 // Do not leave this host as canonical so that we don't infer the other 344 // Do not leave this host as canonical so that we don't infer the other
340 // hosts are also broken without testing them first. 345 // hosts are also broken without testing them first.
341 RemoveCanonicalHost(server); 346 RemoveCanonicalHost(server);
342 347
343 // If this is the only entry in the list, schedule an expiration task. 348 // If this is the only entry in the list, schedule an expiration task.
344 // Otherwse it will be rescheduled automatically when the pending 349 // Otherwise it will be rescheduled automatically when the pending task runs.
345 // task runs.
346 if (broken_alternate_protocol_list_.size() == 1) { 350 if (broken_alternate_protocol_list_.size() == 1) {
347 ScheduleBrokenAlternateProtocolMappingsExpiration(); 351 ScheduleBrokenAlternateProtocolMappingsExpiration();
348 } 352 }
349 } 353 }
350 354
351 bool HttpServerPropertiesImpl::WasAlternateProtocolRecentlyBroken( 355 bool HttpServerPropertiesImpl::WasAlternateProtocolRecentlyBroken(
352 const HostPortPair& server) { 356 const HostPortPair& server) {
353 return ContainsKey(broken_alternate_protocol_map_, server); 357 return ContainsKey(broken_alternate_protocol_map_, server);
354 } 358 }
355 359
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 535 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
532 base::MessageLoop::current()->PostDelayedTask( 536 base::MessageLoop::current()->PostDelayedTask(
533 FROM_HERE, 537 FROM_HERE,
534 base::Bind( 538 base::Bind(
535 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 539 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
536 weak_ptr_factory_.GetWeakPtr()), 540 weak_ptr_factory_.GetWeakPtr()),
537 delay); 541 delay);
538 } 542 }
539 543
540 } // namespace net 544 } // 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