Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: net/http/http_server_properties_impl.cc

Issue 2171743002: Do not persist HttpServerProperties to disk that often. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698