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

Unified Diff: chrome/browser/net/http_server_properties_manager.cc

Issue 11238034: Added completion notification to Profile's ClearNetworkingHistorySince. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missing newline at EOF. Created 8 years, 2 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: chrome/browser/net/http_server_properties_manager.cc
diff --git a/chrome/browser/net/http_server_properties_manager.cc b/chrome/browser/net/http_server_properties_manager.cc
index 94e4e02598363a8525aa7fcc3bcd5c377ef2c8e1..c8e9e5b09cc2354ee34c80ceaeedc4b39c9e48ad 100644
--- a/chrome/browser/net/http_server_properties_manager.cc
+++ b/chrome/browser/net/http_server_properties_manager.cc
@@ -91,11 +91,16 @@ void HttpServerPropertiesManager::RegisterPrefs(PrefService* prefs) {
PrefService::UNSYNCABLE_PREF);
}
+// This is required for conformance with the HttpServerProperties interface.
void HttpServerPropertiesManager::Clear() {
+ Clear(base::Closure());
+}
+
+void HttpServerPropertiesManager::Clear(const base::Closure& completion) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
http_server_properties_impl_->Clear();
- ScheduleUpdatePrefsOnIO();
+ UpdatePrefsFromCacheOnIO(completion);
}
bool HttpServerPropertiesManager::SupportsSpdy(
@@ -441,7 +446,13 @@ void HttpServerPropertiesManager::StartPrefsUpdateTimerOnIO(
&HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO);
}
+// This is required so we can set this as the callback for a timer.
void HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO() {
+ UpdatePrefsFromCacheOnIO(base::Closure());
+}
+
+void HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO(
+ const base::Closure& completion) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
base::ListValue* spdy_server_list = new base::ListValue;
@@ -469,7 +480,8 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO() {
base::Owned(spdy_server_list),
base::Owned(spdy_settings_map),
base::Owned(alternate_protocol_map),
- base::Owned(pipeline_capability_map)));
+ base::Owned(pipeline_capability_map),
+ completion));
}
// A local or temporary data structure to hold |supports_spdy|, SpdySettings,
@@ -500,7 +512,8 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI(
base::ListValue* spdy_server_list,
net::SpdySettingsMap* spdy_settings_map,
net::AlternateProtocolMap* alternate_protocol_map,
- net::PipelineCapabilityMap* pipeline_capability_map) {
+ net::PipelineCapabilityMap* pipeline_capability_map,
+ const base::Closure& completion) {
typedef std::map<net::HostPortPair, ServerPref> ServerPrefMap;
ServerPrefMap server_pref_map;
@@ -634,6 +647,14 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI(
pref_service_->Set(prefs::kHttpServerProperties,
http_server_properties_dict);
setting_prefs_ = false;
+
+ // Note that |completion| will be fired after we have written everything to
+ // the Preferences, but likely before these changes are serialized to disk.
+ // This is not a problem though, as JSONPrefStore guarantees that this will
+ // happen soon, even if we shut down immediately.
+ if (!completion.is_null()) {
+ completion.Run();
+ }
battre 2012/10/23 08:38:33 nit: no {}
engedy 2012/10/23 10:40:09 Done.
}
void HttpServerPropertiesManager::Observe(

Powered by Google App Engine
This is Rietveld 408576698