OLD | NEW |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return; | 43 return; |
44 // Add the entries from persisted data. | 44 // Add the entries from persisted data. |
45 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); | 45 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); |
46 it != spdy_servers->rend(); ++it) { | 46 it != spdy_servers->rend(); ++it) { |
47 spdy_servers_map_.Put(*it, support_spdy); | 47 spdy_servers_map_.Put(*it, support_spdy); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 void HttpServerPropertiesImpl::InitializeAlternateProtocolServers( | 51 void HttpServerPropertiesImpl::InitializeAlternateProtocolServers( |
52 AlternateProtocolMap* alternate_protocol_map) { | 52 AlternateProtocolMap* alternate_protocol_map) { |
53 // Keep all the broken ones since those don't get persisted. | 53 for (AlternateProtocolMap::iterator alternate_protocols = |
54 for (AlternateProtocolMap::iterator it = alternate_protocol_map_.begin(); | 54 alternate_protocol_map_.begin(); |
55 it != alternate_protocol_map_.end();) { | 55 alternate_protocols != alternate_protocol_map_.end();) { |
56 AlternateProtocolMap::iterator old_it = it; | 56 // Keep all the broken ones since those don't get persisted. |
57 ++it; | 57 for (AlternateProtocols::iterator it = alternate_protocols->second.begin(); |
58 if (!old_it->second.is_broken) { | 58 it != alternate_protocols->second.end();) { |
59 alternate_protocol_map_.Erase(old_it); | 59 if (!it->is_broken) { |
| 60 it = alternate_protocols->second.erase(it); |
| 61 } else { |
| 62 ++it; |
| 63 } |
| 64 } |
| 65 if (alternate_protocols->second.size() == 0) { |
| 66 alternate_protocols = alternate_protocol_map_.Erase(alternate_protocols); |
| 67 } else { |
| 68 ++alternate_protocols; |
60 } | 69 } |
61 } | 70 } |
62 | 71 |
63 // Add the entries from persisted data. | 72 // Add the entries from persisted data. |
64 for (AlternateProtocolMap::reverse_iterator it = | 73 for (AlternateProtocolMap::reverse_iterator it = |
65 alternate_protocol_map->rbegin(); | 74 alternate_protocol_map->rbegin(); |
66 it != alternate_protocol_map->rend(); ++it) { | 75 it != alternate_protocol_map->rend(); ++it) { |
67 alternate_protocol_map_.Put(it->first, it->second); | 76 alternate_protocol_map_.Put(it->first, it->second); |
68 } | 77 } |
69 | 78 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 for (SpdyServerHostPortMap::const_iterator it = spdy_servers_map_.begin(); | 139 for (SpdyServerHostPortMap::const_iterator it = spdy_servers_map_.begin(); |
131 it != spdy_servers_map_.end() && count < max_size; ++it) { | 140 it != spdy_servers_map_.end() && count < max_size; ++it) { |
132 const std::string spdy_server_host_port = it->first; | 141 const std::string spdy_server_host_port = it->first; |
133 if (it->second) { | 142 if (it->second) { |
134 spdy_server_list->Append(new base::StringValue(spdy_server_host_port)); | 143 spdy_server_list->Append(new base::StringValue(spdy_server_host_port)); |
135 ++count; | 144 ++count; |
136 } | 145 } |
137 } | 146 } |
138 } | 147 } |
139 | 148 |
140 static const AlternateProtocolInfo* g_forced_alternate_protocol = NULL; | 149 static AlternateProtocols* g_forced_alternate_protocol = |
| 150 new AlternateProtocols(); |
141 | 151 |
142 // static | 152 // static |
143 void HttpServerPropertiesImpl::ForceAlternateProtocol( | 153 void HttpServerPropertiesImpl::ForceAlternateProtocol( |
144 const AlternateProtocolInfo& info) { | 154 const AlternateProtocolInfo& info) { |
| 155 DisableForcedAlternateProtocol(); |
145 // Note: we're going to leak this. | 156 // Note: we're going to leak this. |
146 if (g_forced_alternate_protocol) | 157 g_forced_alternate_protocol->push_back(info); |
147 delete g_forced_alternate_protocol; | |
148 g_forced_alternate_protocol = new AlternateProtocolInfo(info); | |
149 } | 158 } |
150 | 159 |
151 // static | 160 // static |
152 void HttpServerPropertiesImpl::DisableForcedAlternateProtocol() { | 161 void HttpServerPropertiesImpl::DisableForcedAlternateProtocol() { |
153 delete g_forced_alternate_protocol; | 162 g_forced_alternate_protocol->clear(); |
154 g_forced_alternate_protocol = NULL; | |
155 } | 163 } |
156 | 164 |
157 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { | 165 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { |
158 return weak_ptr_factory_.GetWeakPtr(); | 166 return weak_ptr_factory_.GetWeakPtr(); |
159 } | 167 } |
160 | 168 |
161 void HttpServerPropertiesImpl::Clear() { | 169 void HttpServerPropertiesImpl::Clear() { |
162 DCHECK(CalledOnValidThread()); | 170 DCHECK(CalledOnValidThread()); |
163 spdy_servers_map_.Clear(); | 171 spdy_servers_map_.Clear(); |
164 alternate_protocol_map_.Clear(); | 172 alternate_protocol_map_.Clear(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 226 |
219 void HttpServerPropertiesImpl::MaybeForceHTTP11(const HostPortPair& server, | 227 void HttpServerPropertiesImpl::MaybeForceHTTP11(const HostPortPair& server, |
220 SSLConfig* ssl_config) { | 228 SSLConfig* ssl_config) { |
221 if (RequiresHTTP11(server)) { | 229 if (RequiresHTTP11(server)) { |
222 ForceHTTP11(ssl_config); | 230 ForceHTTP11(ssl_config); |
223 } | 231 } |
224 } | 232 } |
225 | 233 |
226 bool HttpServerPropertiesImpl::HasAlternateProtocol( | 234 bool HttpServerPropertiesImpl::HasAlternateProtocol( |
227 const HostPortPair& server) { | 235 const HostPortPair& server) { |
228 if (g_forced_alternate_protocol) | 236 if (!g_forced_alternate_protocol->empty()) |
229 return true; | 237 return true; |
230 AlternateProtocolMap::const_iterator it = | 238 AlternateProtocolMap::const_iterator alternate_protocols = |
231 GetAlternateProtocolIterator(server); | 239 GetAlternateProtocolIterator(server); |
232 return it != alternate_protocol_map_.end() && | 240 if (alternate_protocols == alternate_protocol_map_.end()) |
233 it->second.probability >= alternate_protocol_probability_threshold_; | 241 return false; |
| 242 for (AlternateProtocols::const_iterator alternate_protocol = |
| 243 alternate_protocols->second.begin(); |
| 244 alternate_protocol != alternate_protocols->second.end(); |
| 245 alternate_protocol++) { |
| 246 if (alternate_protocol->probability >= |
| 247 alternate_protocol_probability_threshold_) { |
| 248 return true; |
| 249 } |
| 250 } |
| 251 return false; |
234 } | 252 } |
235 | 253 |
236 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( | 254 std::string HttpServerPropertiesImpl::GetCanonicalSuffix( |
237 const HostPortPair& server) { | 255 const HostPortPair& server) { |
238 // If this host ends with a canonical suffix, then return the canonical | 256 // If this host ends with a canonical suffix, then return the canonical |
239 // suffix. | 257 // suffix. |
240 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 258 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
241 std::string canonical_suffix = canonical_suffixes_[i]; | 259 std::string canonical_suffix = canonical_suffixes_[i]; |
242 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { | 260 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { |
243 return canonical_suffix; | 261 return canonical_suffix; |
244 } | 262 } |
245 } | 263 } |
246 return std::string(); | 264 return std::string(); |
247 } | 265 } |
248 | 266 |
249 AlternateProtocolInfo | 267 const AlternateProtocols& HttpServerPropertiesImpl::GetAlternateProtocols( |
250 HttpServerPropertiesImpl::GetAlternateProtocol( | |
251 const HostPortPair& server) { | 268 const HostPortPair& server) { |
252 DCHECK(HasAlternateProtocol(server)); | 269 DCHECK(HasAlternateProtocol(server)); |
253 | 270 |
254 AlternateProtocolMap::const_iterator it = | 271 AlternateProtocolMap::const_iterator it = |
255 GetAlternateProtocolIterator(server); | 272 GetAlternateProtocolIterator(server); |
256 if (it != alternate_protocol_map_.end()) | 273 if (it != alternate_protocol_map_.end()) |
257 return it->second; | 274 return it->second; |
258 | 275 |
259 // We must be forcing an alternate. | 276 // We must be forcing an alternate. |
260 DCHECK(g_forced_alternate_protocol); | 277 DCHECK(!g_forced_alternate_protocol->empty()); |
261 return *g_forced_alternate_protocol; | 278 return *g_forced_alternate_protocol; |
262 } | 279 } |
263 | 280 |
264 void HttpServerPropertiesImpl::SetAlternateProtocol( | 281 void HttpServerPropertiesImpl::AddAlternateProtocol( |
265 const HostPortPair& server, | 282 const HostPortPair& server, |
266 uint16 alternate_port, | 283 uint16 alternate_port, |
267 AlternateProtocol alternate_protocol, | 284 AlternateProtocol alternate_protocol, |
268 double alternate_probability) { | 285 double alternate_probability) { |
269 | 286 if (!IsAlternateProtocolValid(alternate_protocol)) |
| 287 return; |
270 AlternateProtocolInfo alternate(alternate_port, | 288 AlternateProtocolInfo alternate(alternate_port, |
271 alternate_protocol, | 289 alternate_protocol, |
272 alternate_probability); | 290 alternate_probability); |
273 AlternateProtocolMap::const_iterator it = | 291 AlternateProtocolMap::const_iterator map_it = |
274 GetAlternateProtocolIterator(server); | 292 GetAlternateProtocolIterator(server); |
275 if (it != alternate_protocol_map_.end()) { | 293 if (map_it != alternate_protocol_map_.end()) { |
276 const AlternateProtocolInfo existing_alternate = it->second; | 294 AlternateProtocols existing_alternates = map_it->second; |
277 | 295 AlternateProtocols::iterator it; |
278 if (existing_alternate.is_broken) { | 296 for (it = existing_alternates.begin(); it != existing_alternates.end(); |
279 DVLOG(1) << "Ignore alternate protocol since it's known to be broken."; | 297 ++it) { |
280 return; | 298 if (it->EqualsModuloProbability(alternate)) { |
| 299 break; |
| 300 } |
281 } | 301 } |
282 | 302 |
283 if (!existing_alternate.Equals(alternate)) { | 303 if (it != existing_alternates.end()) { |
284 LOG(WARNING) << "Changing the alternate protocol for: " | 304 if (it->is_broken) { |
285 << server.ToString() | 305 DVLOG(1) << "Ignore alternate protocol since it's known to be broken."; |
286 << " from [Port: " << existing_alternate.port | 306 return; |
287 << ", Protocol: " << existing_alternate.protocol | 307 } |
288 << ", Probability: " << existing_alternate.probability | 308 if (it->probability != alternate_probability) { |
289 << "] to [Port: " << alternate_port | 309 LOG(WARNING) << "Changing the probability of alternate protocol for: " |
290 << ", Protocol: " << alternate_protocol | 310 << server.ToString() << " Port: " << it->port |
291 << ", Probability: " << alternate_probability | 311 << ", Protocol: " << it->protocol |
292 << "]."; | 312 << ", Probability from: " << it->probability |
| 313 << " to: " << alternate_probability << "."; |
| 314 it->probability = alternate_probability; |
| 315 } |
| 316 } else { |
| 317 existing_alternates.push_back(alternate); |
293 } | 318 } |
| 319 |
| 320 alternate_protocol_map_.Put(server, existing_alternates); |
294 } else { | 321 } else { |
295 if (alternate_probability >= alternate_protocol_probability_threshold_) { | 322 if (alternate_probability >= alternate_protocol_probability_threshold_) { |
296 // TODO(rch): Consider the case where multiple requests are started | 323 // TODO(rch): Consider the case where multiple requests are started |
297 // before the first completes. In this case, only one of the jobs | 324 // before the first completes. In this case, only one of the jobs |
298 // would reach this code, whereas all of them should should have. | 325 // would reach this code, whereas all of them should should have. |
299 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); | 326 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); |
300 } | 327 } |
| 328 alternate_protocol_map_.Put(server, |
| 329 AlternateProtocols(/*size=*/1, alternate)); |
301 } | 330 } |
302 | 331 |
303 alternate_protocol_map_.Put(server, alternate); | |
304 | |
305 // If this host ends with a canonical suffix, then set it as the | 332 // If this host ends with a canonical suffix, then set it as the |
306 // canonical host. | 333 // canonical host. |
307 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 334 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
308 std::string canonical_suffix = canonical_suffixes_[i]; | 335 std::string canonical_suffix = canonical_suffixes_[i]; |
309 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { | 336 if (EndsWith(server.host(), canonical_suffixes_[i], false)) { |
310 HostPortPair canonical_host(canonical_suffix, server.port()); | 337 HostPortPair canonical_host(canonical_suffix, server.port()); |
311 canonical_host_to_origin_map_[canonical_host] = server; | 338 canonical_host_to_origin_map_[canonical_host] = server; |
312 break; | 339 break; |
313 } | 340 } |
314 } | 341 } |
315 } | 342 } |
316 | 343 |
317 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( | 344 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( |
318 const HostPortPair& server) { | 345 const HostPortPair& server, |
319 AlternateProtocolMap::iterator it = alternate_protocol_map_.Get(server); | 346 const AlternateProtocolInfo& broken_alternate_protocol) { |
320 if (it == alternate_protocol_map_.end()) { | 347 if (!IsAlternateProtocolValid(broken_alternate_protocol.protocol)) |
321 if (!HasAlternateProtocol(server)) { | 348 return; |
322 LOG(DFATAL) << "Trying to mark unknown alternate protocol broken."; | 349 AddAlternateProtocol(server, broken_alternate_protocol.port, |
323 return; | 350 broken_alternate_protocol.protocol, |
| 351 broken_alternate_protocol.probability); |
| 352 AlternateProtocolMap::iterator alternate_protocols = |
| 353 alternate_protocol_map_.Get(server); |
| 354 DCHECK(alternate_protocols != alternate_protocol_map_.end()); |
| 355 AlternateProtocols::iterator it; |
| 356 for (it = alternate_protocols->second.begin(); |
| 357 it != alternate_protocols->second.end(); ++it) { |
| 358 if (it->Equals(broken_alternate_protocol)) { |
| 359 it->is_broken = true; |
| 360 break; |
324 } | 361 } |
325 // This server's alternate protocol information is coming from a canonical | |
326 // server. Add an entry in the map for this server explicitly so that | |
327 // it can be marked as broken. | |
328 it = alternate_protocol_map_.Put(server, GetAlternateProtocol(server)); | |
329 } | 362 } |
330 it->second.is_broken = true; | 363 DCHECK(it != alternate_protocols->second.end()); |
331 int count = ++broken_alternate_protocol_map_[server]; | 364 |
| 365 const AlternativeService altsvc(broken_alternate_protocol.protocol, |
| 366 server.host(), |
| 367 broken_alternate_protocol.port); |
| 368 int count = ++broken_alternate_protocol_map_[altsvc]; |
332 base::TimeDelta delay = | 369 base::TimeDelta delay = |
333 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs); | 370 base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs); |
334 BrokenAlternateProtocolEntry entry; | 371 base::TimeTicks when = base::TimeTicks::Now() + delay * (1 << (count - 1)); |
335 entry.server = server; | 372 const BrokenAlternateProtocolEntry entry(altsvc, when); |
336 entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1)); | |
337 broken_alternate_protocol_list_.push_back(entry); | 373 broken_alternate_protocol_list_.push_back(entry); |
338 | 374 |
339 // Do not leave this host as canonical so that we don't infer the other | 375 // Do not leave this host as canonical so that we don't infer the other |
340 // hosts are also broken without testing them first. | 376 // hosts are also broken without testing them first. |
341 RemoveCanonicalHost(server); | 377 RemoveCanonicalHost(server); |
342 | 378 |
343 // If this is the only entry in the list, schedule an expiration task. | 379 // If this is the only entry in the list, schedule an expiration task. |
344 // Otherwse it will be rescheduled automatically when the pending | 380 // Otherwise it will be rescheduled automatically when the pending task runs. |
345 // task runs. | |
346 if (broken_alternate_protocol_list_.size() == 1) { | 381 if (broken_alternate_protocol_list_.size() == 1) { |
347 ScheduleBrokenAlternateProtocolMappingsExpiration(); | 382 ScheduleBrokenAlternateProtocolMappingsExpiration(); |
348 } | 383 } |
349 } | 384 } |
350 | 385 |
351 bool HttpServerPropertiesImpl::WasAlternateProtocolRecentlyBroken( | 386 bool HttpServerPropertiesImpl::WasAlternateProtocolRecentlyBroken( |
352 const HostPortPair& server) { | 387 const HostPortPair& server, |
353 return ContainsKey(broken_alternate_protocol_map_, server); | 388 const AlternateProtocolInfo& alternate_protocol) { |
| 389 const AlternativeService altsvc(alternate_protocol.protocol, server.host(), |
| 390 alternate_protocol.port); |
| 391 return ContainsKey(broken_alternate_protocol_map_, altsvc); |
354 } | 392 } |
355 | 393 |
356 void HttpServerPropertiesImpl::ConfirmAlternateProtocol( | 394 void HttpServerPropertiesImpl::ConfirmAlternateProtocol( |
357 const HostPortPair& server) { | 395 const HostPortPair& server, |
358 broken_alternate_protocol_map_.erase(server); | 396 const AlternateProtocolInfo& alternate_protocol) { |
| 397 const AlternativeService altsvc(alternate_protocol.protocol, server.host(), |
| 398 alternate_protocol.port); |
| 399 broken_alternate_protocol_map_.erase(altsvc); |
359 } | 400 } |
360 | 401 |
361 void HttpServerPropertiesImpl::ClearAlternateProtocol( | 402 void HttpServerPropertiesImpl::ClearAlternateProtocol( |
362 const HostPortPair& server) { | 403 const HostPortPair& server) { |
363 AlternateProtocolMap::iterator it = alternate_protocol_map_.Peek(server); | 404 AlternateProtocolMap::iterator it = alternate_protocol_map_.Peek(server); |
364 if (it != alternate_protocol_map_.end()) | 405 if (it != alternate_protocol_map_.end()) |
365 alternate_protocol_map_.Erase(it); | 406 alternate_protocol_map_.Erase(it); |
366 | 407 |
367 RemoveCanonicalHost(server); | 408 RemoveCanonicalHost(server); |
368 } | 409 } |
369 | 410 |
| 411 void HttpServerPropertiesImpl::ClearNonBrokenAlternateProtocols( |
| 412 const HostPortPair& server) { |
| 413 AlternateProtocolMap::iterator alternate_protocols = |
| 414 alternate_protocol_map_.Peek(server); |
| 415 if (alternate_protocols == alternate_protocol_map_.end()) { |
| 416 return; |
| 417 } |
| 418 for (AlternateProtocols::iterator it = alternate_protocols->second.begin(); |
| 419 it != alternate_protocols->second.end();) { |
| 420 if (!it->is_broken) { |
| 421 it = alternate_protocols->second.erase(it); |
| 422 } else { |
| 423 ++it; |
| 424 } |
| 425 } |
| 426 if (alternate_protocols->second.size() == 0) { |
| 427 alternate_protocol_map_.Erase(alternate_protocols); |
| 428 RemoveCanonicalHost(server); |
| 429 } |
| 430 } |
| 431 |
| 432 void HttpServerPropertiesImpl::RemoveAlternateProtocol( |
| 433 const HostPortPair& server, |
| 434 const AlternateProtocolInfo& alternate_protocol) { |
| 435 AlternateProtocolMap::iterator alternate_protocols = |
| 436 alternate_protocol_map_.Peek(server); |
| 437 if (alternate_protocols == alternate_protocol_map_.end()) { |
| 438 return; |
| 439 } |
| 440 for (AlternateProtocols::iterator it = alternate_protocols->second.begin(); |
| 441 it != alternate_protocols->second.end(); ++it) { |
| 442 if (it->EqualsModuloProbability(alternate_protocol)) { |
| 443 alternate_protocols->second.erase(it); |
| 444 break; |
| 445 } |
| 446 } |
| 447 if (alternate_protocols->second.size() == 0) { |
| 448 alternate_protocol_map_.Erase(alternate_protocols); |
| 449 RemoveCanonicalHost(server); |
| 450 } |
| 451 } |
| 452 |
370 const AlternateProtocolMap& | 453 const AlternateProtocolMap& |
371 HttpServerPropertiesImpl::alternate_protocol_map() const { | 454 HttpServerPropertiesImpl::alternate_protocol_map() const { |
372 return alternate_protocol_map_; | 455 return alternate_protocol_map_; |
373 } | 456 } |
374 | 457 |
375 const SettingsMap& HttpServerPropertiesImpl::GetSpdySettings( | 458 const SettingsMap& HttpServerPropertiesImpl::GetSpdySettings( |
376 const HostPortPair& host_port_pair) { | 459 const HostPortPair& host_port_pair) { |
377 SpdySettingsMap::iterator it = spdy_settings_map_.Get(host_port_pair); | 460 SpdySettingsMap::iterator it = spdy_settings_map_.Get(host_port_pair); |
378 if (it == spdy_settings_map_.end()) { | 461 if (it == spdy_settings_map_.end()) { |
379 CR_DEFINE_STATIC_LOCAL(SettingsMap, kEmptySettingsMap, ()); | 462 CR_DEFINE_STATIC_LOCAL(SettingsMap, kEmptySettingsMap, ()); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 591 |
509 void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() { | 592 void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() { |
510 base::TimeTicks now = base::TimeTicks::Now(); | 593 base::TimeTicks now = base::TimeTicks::Now(); |
511 while (!broken_alternate_protocol_list_.empty()) { | 594 while (!broken_alternate_protocol_list_.empty()) { |
512 BrokenAlternateProtocolEntry entry = | 595 BrokenAlternateProtocolEntry entry = |
513 broken_alternate_protocol_list_.front(); | 596 broken_alternate_protocol_list_.front(); |
514 if (now < entry.when) { | 597 if (now < entry.when) { |
515 break; | 598 break; |
516 } | 599 } |
517 | 600 |
518 ClearAlternateProtocol(entry.server); | 601 const HostPortPair server(entry.altsvc.host, entry.altsvc.port); |
| 602 const AlternateProtocolInfo alternate_protocol(entry.altsvc.port, |
| 603 entry.altsvc.protocol, 1.0); |
| 604 RemoveAlternateProtocol(server, alternate_protocol); |
519 broken_alternate_protocol_list_.pop_front(); | 605 broken_alternate_protocol_list_.pop_front(); |
520 } | 606 } |
521 ScheduleBrokenAlternateProtocolMappingsExpiration(); | 607 ScheduleBrokenAlternateProtocolMappingsExpiration(); |
522 } | 608 } |
523 | 609 |
524 void | 610 void |
525 HttpServerPropertiesImpl::ScheduleBrokenAlternateProtocolMappingsExpiration() { | 611 HttpServerPropertiesImpl::ScheduleBrokenAlternateProtocolMappingsExpiration() { |
526 if (broken_alternate_protocol_list_.empty()) { | 612 if (broken_alternate_protocol_list_.empty()) { |
527 return; | 613 return; |
528 } | 614 } |
529 base::TimeTicks now = base::TimeTicks::Now(); | 615 base::TimeTicks now = base::TimeTicks::Now(); |
530 base::TimeTicks when = broken_alternate_protocol_list_.front().when; | 616 base::TimeTicks when = broken_alternate_protocol_list_.front().when; |
531 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 617 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
532 base::MessageLoop::current()->PostDelayedTask( | 618 base::MessageLoop::current()->PostDelayedTask( |
533 FROM_HERE, | 619 FROM_HERE, |
534 base::Bind( | 620 base::Bind( |
535 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 621 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
536 weak_ptr_factory_.GetWeakPtr()), | 622 weak_ptr_factory_.GetWeakPtr()), |
537 delay); | 623 delay); |
538 } | 624 } |
539 | 625 |
540 } // namespace net | 626 } // namespace net |
OLD | NEW |