Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Attempt to find canonical servers. | 108 // Attempt to find canonical servers. |
| 109 uint16_t canonical_ports[] = {80, 443}; | 109 uint16_t canonical_ports[] = {80, 443}; |
| 110 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 110 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
| 111 std::string canonical_suffix = canonical_suffixes_[i]; | 111 std::string canonical_suffix = canonical_suffixes_[i]; |
| 112 for (size_t j = 0; j < arraysize(canonical_ports); ++j) { | 112 for (size_t j = 0; j < arraysize(canonical_ports); ++j) { |
| 113 HostPortPair canonical_host(canonical_suffix, canonical_ports[j]); | 113 HostPortPair canonical_host(canonical_suffix, canonical_ports[j]); |
| 114 // If we already have a valid canonical server, we're done. | 114 // If we already have a valid canonical server, we're done. |
| 115 if (ContainsKey(canonical_host_to_origin_map_, canonical_host) && | 115 if (ContainsKey(canonical_host_to_origin_map_, canonical_host) && |
| 116 (alternative_service_map_.Peek( | 116 (alternative_service_map_.Peek(SchemeOriginPair( |
| 117 canonical_host_to_origin_map_[canonical_host]) != | 117 "https", canonical_host_to_origin_map_[canonical_host])) != |
|
Ryan Hamilton
2016/03/24 22:23:14
If we want canoncical suffixes to only apply to HT
Zhongyi Shi
2016/04/04 18:58:36
Done.
| |
| 118 alternative_service_map_.end())) { | 118 alternative_service_map_.end())) { |
| 119 continue; | 119 continue; |
| 120 } | 120 } |
| 121 // Now attempt to find a server which matches this origin and set it as | 121 // Now attempt to find a server which matches this origin and set it as |
| 122 // canonical. | 122 // canonical. |
| 123 for (AlternativeServiceMap::const_iterator it = | 123 for (AlternativeServiceMap::const_iterator it = |
| 124 alternative_service_map_.begin(); | 124 alternative_service_map_.begin(); |
| 125 it != alternative_service_map_.end(); ++it) { | 125 it != alternative_service_map_.end(); ++it) { |
| 126 if (base::EndsWith(it->first.host(), canonical_suffixes_[i], | 126 if (base::EndsWith(it->first.host(), canonical_suffixes_[i], |
| 127 base::CompareCase::INSENSITIVE_ASCII)) { | 127 base::CompareCase::INSENSITIVE_ASCII)) { |
| 128 canonical_host_to_origin_map_[canonical_host] = it->first; | 128 canonical_host_to_origin_map_[canonical_host] = |
| 129 it->first.host_port_pair(); | |
| 129 break; | 130 break; |
| 130 } | 131 } |
| 131 } | 132 } |
| 132 } | 133 } |
| 133 } | 134 } |
| 134 } | 135 } |
| 135 | 136 |
| 136 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( | 137 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( |
| 137 SpdySettingsMap* spdy_settings_map) { | 138 SpdySettingsMap* spdy_settings_map) { |
| 138 // Add the entries from persisted data. | 139 // Add the entries from persisted data. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 spdy_servers_map_.Clear(); | 229 spdy_servers_map_.Clear(); |
| 229 alternative_service_map_.Clear(); | 230 alternative_service_map_.Clear(); |
| 230 canonical_host_to_origin_map_.clear(); | 231 canonical_host_to_origin_map_.clear(); |
| 231 spdy_settings_map_.Clear(); | 232 spdy_settings_map_.Clear(); |
| 232 last_quic_address_ = IPAddress(); | 233 last_quic_address_ = IPAddress(); |
| 233 server_network_stats_map_.Clear(); | 234 server_network_stats_map_.Clear(); |
| 234 quic_server_info_map_.Clear(); | 235 quic_server_info_map_.Clear(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 bool HttpServerPropertiesImpl::SupportsRequestPriority( | 238 bool HttpServerPropertiesImpl::SupportsRequestPriority( |
| 238 const HostPortPair& host_port_pair) { | 239 const SchemeOriginPair& server) { |
| 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.host_port_pair())) |
| 244 return true; | 245 return true; |
| 245 | 246 |
| 246 const AlternativeServiceVector alternative_service_vector = | 247 const AlternativeServiceVector alternative_service_vector = |
| 247 GetAlternativeServices(host_port_pair); | 248 GetAlternativeServices(server); |
| 248 for (const AlternativeService& alternative_service : | 249 for (const AlternativeService& alternative_service : |
| 249 alternative_service_vector) { | 250 alternative_service_vector) { |
| 250 if (alternative_service.protocol == QUIC) { | 251 if (alternative_service.protocol == QUIC) { |
| 251 return true; | 252 return true; |
| 252 } | 253 } |
| 253 } | 254 } |
| 254 return false; | 255 return false; |
| 255 } | 256 } |
| 256 | 257 |
| 257 bool HttpServerPropertiesImpl::GetSupportsSpdy( | 258 bool HttpServerPropertiesImpl::GetSupportsSpdy( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 std::string canonical_suffix = canonical_suffixes_[i]; | 316 std::string canonical_suffix = canonical_suffixes_[i]; |
| 316 if (base::EndsWith(host, canonical_suffixes_[i], | 317 if (base::EndsWith(host, canonical_suffixes_[i], |
| 317 base::CompareCase::INSENSITIVE_ASCII)) { | 318 base::CompareCase::INSENSITIVE_ASCII)) { |
| 318 return canonical_suffix; | 319 return canonical_suffix; |
| 319 } | 320 } |
| 320 } | 321 } |
| 321 return std::string(); | 322 return std::string(); |
| 322 } | 323 } |
| 323 | 324 |
| 324 AlternativeServiceVector HttpServerPropertiesImpl::GetAlternativeServices( | 325 AlternativeServiceVector HttpServerPropertiesImpl::GetAlternativeServices( |
| 325 const HostPortPair& origin) { | 326 const SchemeOriginPair& origin) { |
| 326 // Copy alternative services with probability greater than or equal to the | 327 // Copy alternative services with probability greater than or equal to the |
| 327 // threshold into |alternative_services_above_threshold|. | 328 // threshold into |alternative_services_above_threshold|. |
| 328 AlternativeServiceVector alternative_services_above_threshold; | 329 AlternativeServiceVector alternative_services_above_threshold; |
| 329 const base::Time now = base::Time::Now(); | 330 const base::Time now = base::Time::Now(); |
| 330 AlternativeServiceMap::iterator map_it = alternative_service_map_.Get(origin); | 331 AlternativeServiceMap::iterator map_it = alternative_service_map_.Get(origin); |
| 331 if (map_it != alternative_service_map_.end()) { | 332 if (map_it != alternative_service_map_.end()) { |
| 332 for (AlternativeServiceInfoVector::iterator it = map_it->second.begin(); | 333 for (AlternativeServiceInfoVector::iterator it = map_it->second.begin(); |
| 333 it != map_it->second.end();) { | 334 it != map_it->second.end();) { |
| 334 if (it->expiration < now) { | 335 if (it->expiration < now) { |
| 335 it = map_it->second.erase(it); | 336 it = map_it->second.erase(it); |
| 336 continue; | 337 continue; |
| 337 } | 338 } |
| 338 if (it->probability == 0 || | 339 if (it->probability == 0 || |
| 339 it->probability < alternative_service_probability_threshold_) { | 340 it->probability < alternative_service_probability_threshold_) { |
| 340 ++it; | 341 ++it; |
| 341 continue; | 342 continue; |
| 342 } | 343 } |
| 343 AlternativeService alternative_service(it->alternative_service); | 344 AlternativeService alternative_service(it->alternative_service); |
| 344 if (alternative_service.host.empty()) { | 345 if (alternative_service.host.empty()) { |
| 345 alternative_service.host = origin.host(); | 346 alternative_service.host = origin.host(); |
| 346 } | 347 } |
| 347 // If the alternative service is equivalent to the origin (same host, same | 348 // If the alternative service is equivalent to the origin (same host, same |
| 348 // port, and both TCP), then there is already a Job for it, so do not | 349 // port, and both TCP), then there is already a Job for it, so do not |
| 349 // return it here. | 350 // return it here. |
| 350 if (origin.Equals(alternative_service.host_port_pair()) && | 351 if (origin.scheme() == "https" && |
|
Ryan Hamilton
2016/03/24 22:23:14
I don't understand this check. Can you say more?
Zhongyi Shi
2016/04/04 18:58:35
I thought we want to check whether the alt-svc is
| |
| 352 origin.host_port_pair().Equals( | |
| 353 alternative_service.host_port_pair()) && | |
| 351 NPN_SPDY_MINIMUM_VERSION <= alternative_service.protocol && | 354 NPN_SPDY_MINIMUM_VERSION <= alternative_service.protocol && |
| 352 alternative_service.protocol <= NPN_SPDY_MAXIMUM_VERSION) { | 355 alternative_service.protocol <= NPN_SPDY_MAXIMUM_VERSION) { |
| 353 ++it; | 356 ++it; |
| 354 continue; | 357 continue; |
| 355 } | 358 } |
| 356 alternative_services_above_threshold.push_back(alternative_service); | 359 alternative_services_above_threshold.push_back(alternative_service); |
| 357 ++it; | 360 ++it; |
| 358 } | 361 } |
| 359 if (map_it->second.empty()) { | 362 if (map_it->second.empty()) { |
| 360 alternative_service_map_.Erase(map_it); | 363 alternative_service_map_.Erase(map_it); |
| 361 } | 364 } |
| 362 return alternative_services_above_threshold; | 365 return alternative_services_above_threshold; |
| 363 } | 366 } |
| 364 | 367 |
| 365 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin); | 368 if (origin.scheme() != "https") |
|
Ryan Hamilton
2016/03/24 22:23:14
Comments.
Zhongyi Shi
2016/04/04 18:58:35
Changing the CanonicalHostMap to be <SHP, SHP>, no
| |
| 369 return AlternativeServiceVector(); | |
| 370 | |
| 371 CanonicalHostMap::const_iterator canonical = | |
| 372 GetCanonicalHost(origin.host_port_pair()); | |
| 366 if (canonical == canonical_host_to_origin_map_.end()) { | 373 if (canonical == canonical_host_to_origin_map_.end()) { |
| 367 return AlternativeServiceVector(); | 374 return AlternativeServiceVector(); |
| 368 } | 375 } |
| 369 map_it = alternative_service_map_.Get(canonical->second); | 376 map_it = alternative_service_map_.Get( |
| 377 SchemeOriginPair("https", canonical->second)); | |
|
Ryan Hamilton
2016/03/24 22:23:14
can you use origin.scheme() instead?
Zhongyi Shi
2016/04/04 18:58:35
Acknowledged.
| |
| 370 if (map_it == alternative_service_map_.end()) { | 378 if (map_it == alternative_service_map_.end()) { |
| 371 return AlternativeServiceVector(); | 379 return AlternativeServiceVector(); |
| 372 } | 380 } |
| 373 for (AlternativeServiceInfoVector::iterator it = map_it->second.begin(); | 381 for (AlternativeServiceInfoVector::iterator it = map_it->second.begin(); |
| 374 it != map_it->second.end();) { | 382 it != map_it->second.end();) { |
| 375 if (it->expiration < now) { | 383 if (it->expiration < now) { |
| 376 it = map_it->second.erase(it); | 384 it = map_it->second.erase(it); |
| 377 continue; | 385 continue; |
| 378 } | 386 } |
| 379 if (it->probability < alternative_service_probability_threshold_) { | 387 if (it->probability < alternative_service_probability_threshold_) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 395 alternative_services_above_threshold.push_back(alternative_service); | 403 alternative_services_above_threshold.push_back(alternative_service); |
| 396 ++it; | 404 ++it; |
| 397 } | 405 } |
| 398 if (map_it->second.empty()) { | 406 if (map_it->second.empty()) { |
| 399 alternative_service_map_.Erase(map_it); | 407 alternative_service_map_.Erase(map_it); |
| 400 } | 408 } |
| 401 return alternative_services_above_threshold; | 409 return alternative_services_above_threshold; |
| 402 } | 410 } |
| 403 | 411 |
| 404 bool HttpServerPropertiesImpl::SetAlternativeService( | 412 bool HttpServerPropertiesImpl::SetAlternativeService( |
| 405 const HostPortPair& origin, | 413 const SchemeOriginPair& origin, |
| 406 const AlternativeService& alternative_service, | 414 const AlternativeService& alternative_service, |
| 407 double alternative_probability, | 415 double alternative_probability, |
| 408 base::Time expiration) { | 416 base::Time expiration) { |
| 409 return SetAlternativeServices( | 417 return SetAlternativeServices( |
| 410 origin, AlternativeServiceInfoVector( | 418 origin, AlternativeServiceInfoVector( |
| 411 /*size=*/1, | 419 /*size=*/1, |
| 412 AlternativeServiceInfo(alternative_service, | 420 AlternativeServiceInfo(alternative_service, |
| 413 alternative_probability, expiration))); | 421 alternative_probability, expiration))); |
| 414 } | 422 } |
| 415 | 423 |
| 416 bool HttpServerPropertiesImpl::SetAlternativeServices( | 424 bool HttpServerPropertiesImpl::SetAlternativeServices( |
| 417 const HostPortPair& origin, | 425 const SchemeOriginPair& origin, |
| 418 const AlternativeServiceInfoVector& alternative_service_info_vector) { | 426 const AlternativeServiceInfoVector& alternative_service_info_vector) { |
| 419 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); | 427 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); |
| 420 | 428 |
| 421 if (alternative_service_info_vector.empty()) { | 429 if (alternative_service_info_vector.empty()) { |
| 422 if (it == alternative_service_map_.end()) { | 430 if (it == alternative_service_map_.end()) { |
| 423 return false; | 431 return false; |
| 424 } | 432 } |
| 425 ClearAlternativeServices(origin); | 433 ClearAlternativeServices(origin); |
| 426 return true; | 434 return true; |
| 427 } | 435 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 445 // TODO(rch): Consider the case where multiple requests are started | 453 // TODO(rch): Consider the case where multiple requests are started |
| 446 // before the first completes. In this case, only one of the jobs | 454 // before the first completes. In this case, only one of the jobs |
| 447 // would reach this code, whereas all of them should should have. | 455 // would reach this code, whereas all of them should should have. |
| 448 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); | 456 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); |
| 449 } | 457 } |
| 450 | 458 |
| 451 // If this host ends with a canonical suffix, then set it as the | 459 // If this host ends with a canonical suffix, then set it as the |
| 452 // canonical host. | 460 // canonical host. |
| 453 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { | 461 for (size_t i = 0; i < canonical_suffixes_.size(); ++i) { |
| 454 std::string canonical_suffix = canonical_suffixes_[i]; | 462 std::string canonical_suffix = canonical_suffixes_[i]; |
| 455 if (base::EndsWith(origin.host(), canonical_suffixes_[i], | 463 if (origin.scheme() == "https" && |
|
Ryan Hamilton
2016/03/24 22:23:14
comments.
Zhongyi Shi
2016/04/04 18:58:35
Done.
| |
| 464 base::EndsWith(origin.host(), canonical_suffixes_[i], | |
| 456 base::CompareCase::INSENSITIVE_ASCII)) { | 465 base::CompareCase::INSENSITIVE_ASCII)) { |
| 457 HostPortPair canonical_host(canonical_suffix, origin.port()); | 466 HostPortPair canonical_host(canonical_suffix, origin.port()); |
| 458 canonical_host_to_origin_map_[canonical_host] = origin; | 467 canonical_host_to_origin_map_[canonical_host] = origin.host_port_pair(); |
| 459 break; | 468 break; |
| 460 } | 469 } |
| 461 } | 470 } |
| 462 | 471 |
| 463 return changed; | 472 return changed; |
| 464 } | 473 } |
| 465 | 474 |
| 466 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( | 475 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( |
| 467 const AlternativeService& alternative_service) { | 476 const AlternativeService& alternative_service) { |
| 468 // Empty host means use host of origin, callers are supposed to substitute. | 477 // Empty host means use host of origin, callers are supposed to substitute. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 | 521 |
| 513 void HttpServerPropertiesImpl::ConfirmAlternativeService( | 522 void HttpServerPropertiesImpl::ConfirmAlternativeService( |
| 514 const AlternativeService& alternative_service) { | 523 const AlternativeService& alternative_service) { |
| 515 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) | 524 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 516 return; | 525 return; |
| 517 broken_alternative_services_.erase(alternative_service); | 526 broken_alternative_services_.erase(alternative_service); |
| 518 recently_broken_alternative_services_.erase(alternative_service); | 527 recently_broken_alternative_services_.erase(alternative_service); |
| 519 } | 528 } |
| 520 | 529 |
| 521 void HttpServerPropertiesImpl::ClearAlternativeServices( | 530 void HttpServerPropertiesImpl::ClearAlternativeServices( |
| 522 const HostPortPair& origin) { | 531 const SchemeOriginPair& origin) { |
| 523 RemoveCanonicalHost(origin); | 532 if (origin.scheme() == "https") |
|
Ryan Hamilton
2016/03/24 22:23:14
comments.
Zhongyi Shi
2016/04/04 18:58:35
Acknowledged.
| |
| 533 RemoveCanonicalHost(origin.host_port_pair()); | |
| 524 | 534 |
| 525 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); | 535 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); |
| 526 if (it == alternative_service_map_.end()) { | 536 if (it == alternative_service_map_.end()) { |
| 527 return; | 537 return; |
| 528 } | 538 } |
| 529 alternative_service_map_.Erase(it); | 539 alternative_service_map_.Erase(it); |
| 530 } | 540 } |
| 531 | 541 |
| 532 const AlternativeServiceMap& HttpServerPropertiesImpl::alternative_service_map() | 542 const AlternativeServiceMap& HttpServerPropertiesImpl::alternative_service_map() |
| 533 const { | 543 const { |
| 534 return alternative_service_map_; | 544 return alternative_service_map_; |
| 535 } | 545 } |
| 536 | 546 |
| 537 scoped_ptr<base::Value> | 547 scoped_ptr<base::Value> |
| 538 HttpServerPropertiesImpl::GetAlternativeServiceInfoAsValue() | 548 HttpServerPropertiesImpl::GetAlternativeServiceInfoAsValue() |
| 539 const { | 549 const { |
| 540 scoped_ptr<base::ListValue> dict_list(new base::ListValue); | 550 scoped_ptr<base::ListValue> dict_list(new base::ListValue); |
| 541 for (const auto& alternative_service_map_item : alternative_service_map_) { | 551 for (const auto& alternative_service_map_item : alternative_service_map_) { |
| 542 scoped_ptr<base::ListValue> alternative_service_list(new base::ListValue); | 552 scoped_ptr<base::ListValue> alternative_service_list(new base::ListValue); |
| 543 const HostPortPair& host_port_pair = alternative_service_map_item.first; | 553 const HostPortPair& host_port_pair = |
| 554 alternative_service_map_item.first.host_port_pair(); | |
| 544 for (const AlternativeServiceInfo& alternative_service_info : | 555 for (const AlternativeServiceInfo& alternative_service_info : |
| 545 alternative_service_map_item.second) { | 556 alternative_service_map_item.second) { |
| 546 std::string alternative_service_string( | 557 std::string alternative_service_string( |
| 547 alternative_service_info.ToString()); | 558 alternative_service_info.ToString()); |
| 548 AlternativeService alternative_service( | 559 AlternativeService alternative_service( |
| 549 alternative_service_info.alternative_service); | 560 alternative_service_info.alternative_service); |
| 550 if (alternative_service.host.empty()) { | 561 if (alternative_service.host.empty()) { |
| 551 alternative_service.host = host_port_pair.host(); | 562 alternative_service.host = host_port_pair.host(); |
| 552 } | 563 } |
| 553 if (IsAlternativeServiceBroken(alternative_service)) { | 564 if (IsAlternativeServiceBroken(alternative_service)) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 697 quic_server_info_map_.Swap(temp_map); | 708 quic_server_info_map_.Swap(temp_map); |
| 698 } | 709 } |
| 699 | 710 |
| 700 void HttpServerPropertiesImpl::SetAlternativeServiceProbabilityThreshold( | 711 void HttpServerPropertiesImpl::SetAlternativeServiceProbabilityThreshold( |
| 701 double threshold) { | 712 double threshold) { |
| 702 alternative_service_probability_threshold_ = threshold; | 713 alternative_service_probability_threshold_ = threshold; |
| 703 } | 714 } |
| 704 | 715 |
| 705 AlternativeServiceMap::const_iterator | 716 AlternativeServiceMap::const_iterator |
| 706 HttpServerPropertiesImpl::GetAlternateProtocolIterator( | 717 HttpServerPropertiesImpl::GetAlternateProtocolIterator( |
| 707 const HostPortPair& server) { | 718 const SchemeOriginPair& server) { |
| 708 AlternativeServiceMap::const_iterator it = | 719 AlternativeServiceMap::const_iterator it = |
| 709 alternative_service_map_.Get(server); | 720 alternative_service_map_.Get(server); |
| 710 if (it != alternative_service_map_.end()) | 721 if (it != alternative_service_map_.end()) |
| 711 return it; | 722 return it; |
| 712 | 723 |
| 713 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(server); | 724 if (server.scheme() != "https") |
| 725 return alternative_service_map_.end(); | |
| 726 | |
| 727 CanonicalHostMap::const_iterator canonical = | |
| 728 GetCanonicalHost(server.host_port_pair()); | |
| 714 if (canonical == canonical_host_to_origin_map_.end()) { | 729 if (canonical == canonical_host_to_origin_map_.end()) { |
| 715 return alternative_service_map_.end(); | 730 return alternative_service_map_.end(); |
| 716 } | 731 } |
| 717 | 732 |
| 718 const HostPortPair canonical_host_port = canonical->second; | 733 const HostPortPair canonical_host_port = canonical->second; |
| 719 it = alternative_service_map_.Get(canonical_host_port); | 734 it = alternative_service_map_.Get( |
| 735 SchemeOriginPair("https", canonical_host_port)); | |
| 720 if (it == alternative_service_map_.end()) { | 736 if (it == alternative_service_map_.end()) { |
| 721 return alternative_service_map_.end(); | 737 return alternative_service_map_.end(); |
| 722 } | 738 } |
| 723 | 739 |
| 724 for (const AlternativeServiceInfo& alternative_service_info : it->second) { | 740 for (const AlternativeServiceInfo& alternative_service_info : it->second) { |
| 725 AlternativeService alternative_service( | 741 AlternativeService alternative_service( |
| 726 alternative_service_info.alternative_service); | 742 alternative_service_info.alternative_service); |
| 727 if (alternative_service.host.empty()) { | 743 if (alternative_service.host.empty()) { |
| 728 alternative_service.host = canonical_host_port.host(); | 744 alternative_service.host = canonical_host_port.host(); |
| 729 } | 745 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 790 if (alternative_service == expired_alternative_service) { | 806 if (alternative_service == expired_alternative_service) { |
| 791 it = map_it->second.erase(it); | 807 it = map_it->second.erase(it); |
| 792 continue; | 808 continue; |
| 793 } | 809 } |
| 794 ++it; | 810 ++it; |
| 795 } | 811 } |
| 796 // If an origin has an empty list of alternative services, then remove it | 812 // If an origin has an empty list of alternative services, then remove it |
| 797 // from both |canonical_host_to_origin_map_| and | 813 // from both |canonical_host_to_origin_map_| and |
| 798 // |alternative_service_map_|. | 814 // |alternative_service_map_|. |
| 799 if (map_it->second.empty()) { | 815 if (map_it->second.empty()) { |
| 800 RemoveCanonicalHost(map_it->first); | 816 RemoveCanonicalHost(map_it->first.host_port_pair()); |
| 801 map_it = alternative_service_map_.Erase(map_it); | 817 map_it = alternative_service_map_.Erase(map_it); |
| 802 continue; | 818 continue; |
| 803 } | 819 } |
| 804 ++map_it; | 820 ++map_it; |
| 805 } | 821 } |
| 806 } | 822 } |
| 807 ScheduleBrokenAlternateProtocolMappingsExpiration(); | 823 ScheduleBrokenAlternateProtocolMappingsExpiration(); |
| 808 } | 824 } |
| 809 | 825 |
| 810 void | 826 void |
| 811 HttpServerPropertiesImpl::ScheduleBrokenAlternateProtocolMappingsExpiration() { | 827 HttpServerPropertiesImpl::ScheduleBrokenAlternateProtocolMappingsExpiration() { |
| 812 if (broken_alternative_services_.empty()) { | 828 if (broken_alternative_services_.empty()) { |
| 813 return; | 829 return; |
| 814 } | 830 } |
| 815 base::TimeTicks now = base::TimeTicks::Now(); | 831 base::TimeTicks now = base::TimeTicks::Now(); |
| 816 base::TimeTicks when = broken_alternative_services_.front().second; | 832 base::TimeTicks when = broken_alternative_services_.front().second; |
| 817 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 833 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 818 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 834 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 819 FROM_HERE, | 835 FROM_HERE, |
| 820 base::Bind( | 836 base::Bind( |
| 821 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 837 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 822 weak_ptr_factory_.GetWeakPtr()), | 838 weak_ptr_factory_.GetWeakPtr()), |
| 823 delay); | 839 delay); |
| 824 } | 840 } |
| 825 | 841 |
| 826 } // namespace net | 842 } // namespace net |
| OLD | NEW |