| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 738 |
| 741 return canonical_host_to_origin_map_.end(); | 739 return canonical_host_to_origin_map_.end(); |
| 742 } | 740 } |
| 743 | 741 |
| 744 void HttpServerPropertiesImpl::RemoveCanonicalHost( | 742 void HttpServerPropertiesImpl::RemoveCanonicalHost( |
| 745 const url::SchemeHostPort& server) { | 743 const url::SchemeHostPort& server) { |
| 746 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(server); | 744 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(server); |
| 747 if (canonical == canonical_host_to_origin_map_.end()) | 745 if (canonical == canonical_host_to_origin_map_.end()) |
| 748 return; | 746 return; |
| 749 | 747 |
| 750 if (!canonical->second.Equals(server)) | |
| 751 return; | |
| 752 | |
| 753 canonical_host_to_origin_map_.erase(canonical->first); | 748 canonical_host_to_origin_map_.erase(canonical->first); |
| 754 } | 749 } |
| 755 | 750 |
| 756 void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() { | 751 void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() { |
| 757 base::TimeTicks now = base::TimeTicks::Now(); | 752 base::TimeTicks now = base::TimeTicks::Now(); |
| 758 while (!broken_alternative_services_.empty()) { | 753 while (!broken_alternative_services_.empty()) { |
| 759 BrokenAlternativeServices::iterator it = | 754 BrokenAlternativeServices::iterator it = |
| 760 broken_alternative_services_.begin(); | 755 broken_alternative_services_.begin(); |
| 761 if (now < it->second) { | 756 if (now < it->second) { |
| 762 break; | 757 break; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 803 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 809 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 804 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 810 FROM_HERE, | 805 FROM_HERE, |
| 811 base::Bind( | 806 base::Bind( |
| 812 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 807 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 813 weak_ptr_factory_.GetWeakPtr()), | 808 weak_ptr_factory_.GetWeakPtr()), |
| 814 delay); | 809 delay); |
| 815 } | 810 } |
| 816 | 811 |
| 817 } // namespace net | 812 } // namespace net |
| OLD | NEW |