Chromium Code Reviews| Index: net/http/http_server_properties_impl.cc |
| diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc |
| index 9e6e92e719d66a5dbf7711e29367b468b0117b20..d6fe2396fcadebc5e3d063806c75579da892d41e 100644 |
| --- a/net/http/http_server_properties_impl.cc |
| +++ b/net/http/http_server_properties_impl.cc |
| @@ -409,12 +409,32 @@ bool HttpServerPropertiesImpl::SetAlternativeServices( |
| return true; |
| } |
| - bool changed = true; |
| - if (it != alternative_service_map_.end()) { |
| + bool changed; |
|
Ryan Hamilton
2016/07/21 22:27:05
I think you can simplify this slightly:
bool chan
Bence
2016/07/22 16:28:54
Done.
|
| + if (it == alternative_service_map_.end()) { |
| + changed = true; |
| + } else { |
| DCHECK(!it->second.empty()); |
| if (it->second.size() == alternative_service_info_vector.size()) { |
| - changed = !std::equal(it->second.begin(), it->second.end(), |
| - alternative_service_info_vector.begin()); |
| + const base::Time now = base::Time::Now(); |
| + changed = false; |
| + auto new_it = alternative_service_info_vector.begin(); |
| + for (const auto& old : it->second) { |
| + if (old.alternative_service != new_it->alternative_service) { |
| + changed = true; |
| + break; |
| + } |
| + base::Time old_time = old.expiration; |
| + base::Time new_time = new_it->expiration; |
| + if (new_time < old_time || |
| + new_time < now + base::TimeDelta::FromHours(12) || |
| + new_time - now > 2 * (old_time - now)) { |
|
Ryan Hamilton
2016/07/21 22:27:04
nit: Can you add a comment before the if(...) whic
Bence
2016/07/22 16:28:54
Your proposed (2) is redundant with (1), so I'll j
Ryan Hamilton
2016/07/22 23:31:35
That's true. :) It makes me wonder if we would be
Bence
2016/07/27 16:30:55
Done.
|
| + changed = true; |
| + break; |
| + } |
| + ++new_it; |
| + } |
| + } else { |
| + changed = true; |
| } |
| } |