| 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 if (it == alternative_service_map_.end()) { | 410 bool found = it != alternative_service_map_.end(); |
| 411 return false; | |
| 412 } | |
| 413 ClearAlternativeServices(origin); | 411 ClearAlternativeServices(origin); |
| 414 return true; | 412 return found; |
| 415 } | 413 } |
| 416 | 414 |
| 417 bool changed = true; | 415 bool changed = true; |
| 418 if (it != alternative_service_map_.end()) { | 416 if (it != alternative_service_map_.end()) { |
| 419 DCHECK(!it->second.empty()); | 417 DCHECK(!it->second.empty()); |
| 420 if (it->second.size() == alternative_service_info_vector.size()) { | 418 if (it->second.size() == alternative_service_info_vector.size()) { |
| 421 changed = !std::equal(it->second.begin(), it->second.end(), | 419 changed = !std::equal(it->second.begin(), it->second.end(), |
| 422 alternative_service_info_vector.begin()); | 420 alternative_service_info_vector.begin()); |
| 423 } | 421 } |
| 424 } | 422 } |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 | 737 |
| 740 return canonical_host_to_origin_map_.end(); | 738 return canonical_host_to_origin_map_.end(); |
| 741 } | 739 } |
| 742 | 740 |
| 743 void HttpServerPropertiesImpl::RemoveCanonicalHost( | 741 void HttpServerPropertiesImpl::RemoveCanonicalHost( |
| 744 const url::SchemeHostPort& server) { | 742 const url::SchemeHostPort& server) { |
| 745 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(server); | 743 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(server); |
| 746 if (canonical == canonical_host_to_origin_map_.end()) | 744 if (canonical == canonical_host_to_origin_map_.end()) |
| 747 return; | 745 return; |
| 748 | 746 |
| 749 if (!canonical->second.Equals(server)) | |
| 750 return; | |
| 751 | |
| 752 canonical_host_to_origin_map_.erase(canonical->first); | 747 canonical_host_to_origin_map_.erase(canonical->first); |
| 753 } | 748 } |
| 754 | 749 |
| 755 void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() { | 750 void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() { |
| 756 base::TimeTicks now = base::TimeTicks::Now(); | 751 base::TimeTicks now = base::TimeTicks::Now(); |
| 757 while (!broken_alternative_services_.empty()) { | 752 while (!broken_alternative_services_.empty()) { |
| 758 BrokenAlternativeServices::iterator it = | 753 BrokenAlternativeServices::iterator it = |
| 759 broken_alternative_services_.begin(); | 754 broken_alternative_services_.begin(); |
| 760 if (now < it->second) { | 755 if (now < it->second) { |
| 761 break; | 756 break; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 802 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 808 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 803 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 809 FROM_HERE, | 804 FROM_HERE, |
| 810 base::Bind( | 805 base::Bind( |
| 811 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 806 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 812 weak_ptr_factory_.GetWeakPtr()), | 807 weak_ptr_factory_.GetWeakPtr()), |
| 813 delay); | 808 delay); |
| 814 } | 809 } |
| 815 | 810 |
| 816 } // namespace net | 811 } // namespace net |
| OLD | NEW |