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

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: Re: #7. 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..6f0c1ea1f8ba1e73bbfb0958610e471bf6e80fbe 100644
--- a/net/http/http_server_properties_impl.cc
+++ b/net/http/http_server_properties_impl.cc
@@ -413,8 +413,18 @@ bool HttpServerPropertiesImpl::SetAlternativeServices(
if (it != alternative_service_map_.end()) {
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());
+ changed = false;
+ auto new_it = alternative_service_info_vector.begin();
+ for (const auto& old : it->second) {
+ // Persist to disk immediately if new entry has different scheme, host,
+ // or port, or if it expires sooner.
+ if (old.alternative_service != new_it->alternative_service ||
+ old.expiration > new_it->expiration) {
+ changed = true;
+ break;
+ }
+ ++new_it;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698