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

Unified Diff: net/http/http_server_properties_manager.cc

Issue 1546493002: HttpServerProperties - Minor reorganization of code in preperation of (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ServerList - fix comments for PatchSet 1 Created 5 years 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
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 65a5662994e2bf88e2d957b0c1ee9eb9e59a4ca0..ffe234a685344fc6f9ab310114f718029f1a4895 100644
--- a/net/http/http_server_properties_manager.cc
+++ b/net/http/http_server_properties_manager.cc
@@ -37,8 +37,6 @@ const int kMissingVersion = 0;
// The version number of persisted http_server_properties.
const int kVersionNumber = 3;
-typedef std::vector<std::string> StringVector;
-
// Persist 200 MRU AlternateProtocolHostPortPairs.
const int kMaxAlternateProtocolHostsToPersist = 200;
@@ -449,6 +447,16 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() {
// The properties for a given server is in
// http_server_properties_dict["servers"][server].
+ // Server data was stored in the following format in alphabetical order.
+ //
+ // "http_server_properties": {
+ // "servers": {
+ // "accounts.google.com:443": {...},
+ // "accounts.youtube.com:443": {...},
+ // "android.clients.google.com:443": {...},
+ // ...
+ // }, ...
+ // },
const base::DictionaryValue* servers_dict = NULL;
if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion(
kServersKey, &servers_dict)) {
@@ -460,7 +468,7 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() {
ReadSupportsQuic(http_server_properties_dict, addr);
// String is host/port pair of spdy server.
- scoped_ptr<StringVector> spdy_servers(new StringVector);
+ scoped_ptr<ServerList> spdy_servers(new ServerList);
scoped_ptr<SpdySettingsMap> spdy_settings_map(
new SpdySettingsMap(kMaxSpdySettingsHostsToPersist));
scoped_ptr<AlternativeServiceMap> alternative_service_map(
@@ -470,22 +478,49 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() {
scoped_ptr<QuicServerInfoMap> quic_server_info_map(
new QuicServerInfoMap(kMaxQuicServersToPersist));
- for (base::DictionaryValue::Iterator it(*servers_dict); !it.IsAtEnd();
+ if (!AddServersData(*servers_dict, spdy_servers.get(),
+ spdy_settings_map.get(), alternative_service_map.get(),
+ server_network_stats_map.get())) {
+ detected_corrupted_prefs = true;
+ }
+
+ if (!AddToQuicServerInfoMap(http_server_properties_dict,
+ quic_server_info_map.get())) {
+ detected_corrupted_prefs = true;
+ }
+
+ network_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &HttpServerPropertiesManager::UpdateCacheFromPrefsOnNetworkThread,
+ base::Unretained(this), base::Owned(spdy_servers.release()),
+ base::Owned(spdy_settings_map.release()),
+ base::Owned(alternative_service_map.release()), base::Owned(addr),
+ base::Owned(server_network_stats_map.release()),
+ base::Owned(quic_server_info_map.release()),
+ detected_corrupted_prefs));
+}
+
+bool HttpServerPropertiesManager::AddServersData(
+ const base::DictionaryValue& servers_dict,
+ ServerList* spdy_servers,
+ SpdySettingsMap* spdy_settings_map,
+ AlternativeServiceMap* alternative_service_map,
+ ServerNetworkStatsMap* network_stats_map) {
+ for (base::DictionaryValue::Iterator it(servers_dict); !it.IsAtEnd();
it.Advance()) {
// Get server's host/pair.
const std::string& server_str = it.key();
HostPortPair server = HostPortPair::FromString(server_str);
if (server.host().empty()) {
DVLOG(1) << "Malformed http_server_properties for server: " << server_str;
- detected_corrupted_prefs = true;
- continue;
+ return false;
}
const base::DictionaryValue* server_pref_dict = NULL;
if (!it.value().GetAsDictionary(&server_pref_dict)) {
DVLOG(1) << "Malformed http_server_properties server: " << server_str;
- detected_corrupted_prefs = true;
- continue;
+ return false;
}
// Get if server supports Spdy.
@@ -495,30 +530,14 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() {
spdy_servers->push_back(server_str);
}
- AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map.get());
+ AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map);
if (!AddToAlternativeServiceMap(server, *server_pref_dict,
- alternative_service_map.get()) ||
- !AddToNetworkStatsMap(server, *server_pref_dict,
- server_network_stats_map.get())) {
- detected_corrupted_prefs = true;
+ alternative_service_map) ||
+ !AddToNetworkStatsMap(server, *server_pref_dict, network_stats_map)) {
+ return false;
}
}
-
- if (!AddToQuicServerInfoMap(http_server_properties_dict,
- quic_server_info_map.get())) {
- detected_corrupted_prefs = true;
- }
-
- network_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &HttpServerPropertiesManager::UpdateCacheFromPrefsOnNetworkThread,
- base::Unretained(this), base::Owned(spdy_servers.release()),
- base::Owned(spdy_settings_map.release()),
- base::Owned(alternative_service_map.release()), base::Owned(addr),
- base::Owned(server_network_stats_map.release()),
- base::Owned(quic_server_info_map.release()),
- detected_corrupted_prefs));
+ return true;
}
void HttpServerPropertiesManager::AddToSpdySettingsMap(
@@ -768,7 +787,7 @@ bool HttpServerPropertiesManager::AddToQuicServerInfoMap(
}
void HttpServerPropertiesManager::UpdateCacheFromPrefsOnNetworkThread(
- StringVector* spdy_servers,
+ ServerList* spdy_servers,
SpdySettingsMap* spdy_settings_map,
AlternativeServiceMap* alternative_service_map,
IPAddressNumber* last_quic_address,
« no previous file with comments | « 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