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

Unified Diff: net/http/http_server_properties_manager.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_manager.cc
diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc
index 467c5b804545251f3a0dfde3271165d2be0c2e18..75edfc499575d94691479db9a98dfe60f50e3679 100644
--- a/net/http/http_server_properties_manager.cc
+++ b/net/http/http_server_properties_manager.cc
@@ -32,6 +32,10 @@ const int64_t kUpdateCacheDelayMs = 1000;
// period will reset the timer.
const int64_t kUpdatePrefsDelayMs = 60000;
+// Maximum time to wait between ScheduleUpdatePrefsOnNetworkThread() calls from
+// SetAlternativeService() and SetAlternativeServices(), in seconds.
+const int64_t kAlternativeServicesUpdatePrefsS = 3600;
Ryan Hamilton 2016/07/21 22:27:05 This is one hour, right? That seems like a LONG ti
Bence 2016/07/22 16:28:54 Well, then how about five minutes? Then I can cha
+
// "version" 0 indicates, http_server_properties doesn't have "version"
// property.
const int kMissingVersion = 0;
@@ -81,7 +85,8 @@ HttpServerPropertiesManager::HttpServerPropertiesManager(
: pref_task_runner_(base::ThreadTaskRunnerHandle::Get()),
pref_delegate_(pref_delegate),
setting_prefs_(false),
- network_task_runner_(network_task_runner) {
+ network_task_runner_(network_task_runner),
+ last_update_prefs_from_cache_(base::Time::Now()) {
Bence 2016/07/22 16:28:54 Oops.
DCHECK(pref_delegate_);
pref_weak_ptr_factory_.reset(
new base::WeakPtrFactory<HttpServerPropertiesManager>(this));
@@ -195,8 +200,12 @@ bool HttpServerPropertiesManager::SetAlternativeService(
const AlternativeService& alternative_service,
base::Time expiration) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
- const bool changed = http_server_properties_impl_->SetAlternativeService(
- origin, alternative_service, expiration);
+ const bool changed =
+ http_server_properties_impl_->SetAlternativeService(
+ origin, alternative_service, expiration) ||
+ (last_update_prefs_from_cache_ +
+ base::TimeDelta::FromSeconds(kAlternativeServicesUpdatePrefsS) <
+ base::Time::Now());
if (changed) {
ScheduleUpdatePrefsOnNetworkThread(SET_ALTERNATIVE_SERVICES);
}
@@ -207,8 +216,12 @@ bool HttpServerPropertiesManager::SetAlternativeServices(
const url::SchemeHostPort& origin,
const AlternativeServiceInfoVector& alternative_service_info_vector) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
- const bool changed = http_server_properties_impl_->SetAlternativeServices(
- origin, alternative_service_info_vector);
+ const bool changed =
+ http_server_properties_impl_->SetAlternativeServices(
+ origin, alternative_service_info_vector) ||
+ (last_update_prefs_from_cache_ +
+ base::TimeDelta::FromSeconds(kAlternativeServicesUpdatePrefsS) <
+ base::Time::Now());
Ryan Hamilton 2016/07/21 22:27:05 Hm. If nothing has changed, why bother persisting
Bence 2016/07/22 16:28:54 Because old_time in HttpServerPropertiesImpl is th
Ryan Hamilton 2016/07/22 23:31:35 I'm not sure this bothers me. If the user only hit
Bence 2016/07/27 16:30:55 All right then. I think you convinced me that the
if (changed) {
ScheduleUpdatePrefsOnNetworkThread(SET_ALTERNATIVE_SERVICES);
}
@@ -896,6 +909,7 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread() {
void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread(
const base::Closure& completion) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
+ last_update_prefs_from_cache_ = base::Time::Now();
// It is in MRU order.
base::ListValue* spdy_server_list = new base::ListValue;
« net/http/http_server_properties_impl.cc ('K') | « net/http/http_server_properties_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698