| 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 <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 AlternativeServiceInfoVector( | 400 AlternativeServiceInfoVector( |
| 401 /*size=*/1, AlternativeServiceInfo(alternative_service, expiration))); | 401 /*size=*/1, AlternativeServiceInfo(alternative_service, expiration))); |
| 402 } | 402 } |
| 403 | 403 |
| 404 bool HttpServerPropertiesImpl::SetAlternativeServices( | 404 bool HttpServerPropertiesImpl::SetAlternativeServices( |
| 405 const url::SchemeHostPort& origin, | 405 const url::SchemeHostPort& origin, |
| 406 const AlternativeServiceInfoVector& alternative_service_info_vector) { | 406 const AlternativeServiceInfoVector& alternative_service_info_vector) { |
| 407 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); | 407 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); |
| 408 | 408 |
| 409 if (alternative_service_info_vector.empty()) { | 409 if (alternative_service_info_vector.empty()) { |
| 410 bool found = it != alternative_service_map_.end(); | 410 RemoveCanonicalHost(origin); |
| 411 ClearAlternativeServices(origin); | 411 if (it == alternative_service_map_.end()) |
| 412 return found; | 412 return false; |
| 413 |
| 414 alternative_service_map_.Erase(it); |
| 415 return true; |
| 413 } | 416 } |
| 414 | 417 |
| 415 bool changed = true; | 418 bool changed = true; |
| 416 if (it != alternative_service_map_.end()) { | 419 if (it != alternative_service_map_.end()) { |
| 417 DCHECK(!it->second.empty()); | 420 DCHECK(!it->second.empty()); |
| 418 if (it->second.size() == alternative_service_info_vector.size()) { | 421 if (it->second.size() == alternative_service_info_vector.size()) { |
| 419 changed = !std::equal(it->second.begin(), it->second.end(), | 422 changed = !std::equal(it->second.begin(), it->second.end(), |
| 420 alternative_service_info_vector.begin()); | 423 alternative_service_info_vector.begin()); |
| 421 } | 424 } |
| 422 } | 425 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 504 } |
| 502 | 505 |
| 503 void HttpServerPropertiesImpl::ConfirmAlternativeService( | 506 void HttpServerPropertiesImpl::ConfirmAlternativeService( |
| 504 const AlternativeService& alternative_service) { | 507 const AlternativeService& alternative_service) { |
| 505 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) | 508 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 506 return; | 509 return; |
| 507 broken_alternative_services_.erase(alternative_service); | 510 broken_alternative_services_.erase(alternative_service); |
| 508 recently_broken_alternative_services_.erase(alternative_service); | 511 recently_broken_alternative_services_.erase(alternative_service); |
| 509 } | 512 } |
| 510 | 513 |
| 511 void HttpServerPropertiesImpl::ClearAlternativeServices( | |
| 512 const url::SchemeHostPort& origin) { | |
| 513 RemoveCanonicalHost(origin); | |
| 514 | |
| 515 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); | |
| 516 if (it == alternative_service_map_.end()) { | |
| 517 return; | |
| 518 } | |
| 519 alternative_service_map_.Erase(it); | |
| 520 } | |
| 521 | |
| 522 const AlternativeServiceMap& HttpServerPropertiesImpl::alternative_service_map() | 514 const AlternativeServiceMap& HttpServerPropertiesImpl::alternative_service_map() |
| 523 const { | 515 const { |
| 524 return alternative_service_map_; | 516 return alternative_service_map_; |
| 525 } | 517 } |
| 526 | 518 |
| 527 std::unique_ptr<base::Value> | 519 std::unique_ptr<base::Value> |
| 528 HttpServerPropertiesImpl::GetAlternativeServiceInfoAsValue() const { | 520 HttpServerPropertiesImpl::GetAlternativeServiceInfoAsValue() const { |
| 529 std::unique_ptr<base::ListValue> dict_list(new base::ListValue); | 521 std::unique_ptr<base::ListValue> dict_list(new base::ListValue); |
| 530 for (const auto& alternative_service_map_item : alternative_service_map_) { | 522 for (const auto& alternative_service_map_item : alternative_service_map_) { |
| 531 std::unique_ptr<base::ListValue> alternative_service_list( | 523 std::unique_ptr<base::ListValue> alternative_service_list( |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 794 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 803 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 795 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 804 FROM_HERE, | 796 FROM_HERE, |
| 805 base::Bind( | 797 base::Bind( |
| 806 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 798 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 807 weak_ptr_factory_.GetWeakPtr()), | 799 weak_ptr_factory_.GetWeakPtr()), |
| 808 delay); | 800 delay); |
| 809 } | 801 } |
| 810 | 802 |
| 811 } // namespace net | 803 } // namespace net |
| OLD | NEW |