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

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

Issue 180743026: Relanding 255326 "HttpServerProperties - Implement MRU for AlternateProtocolMap. Persist" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use Erase to fix compilation error Created 6 years, 9 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
« no previous file with comments | « chrome/browser/net/http_server_properties_manager.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 08f8ee2df5fb59edf7e4ec79c3f549d97b9f83c2..c24e588770ae4f7c6e32ca548840150168d55744 100644
--- a/chrome/browser/net/http_server_properties_manager.cc
+++ b/chrome/browser/net/http_server_properties_manager.cc
@@ -43,6 +43,9 @@ const int kVersionNumber = 2;
typedef std::vector<std::string> StringVector;
+// Persist 200 MRU AlternateProtocolHostPortPairs.
+const int kMaxAlternateProtocolHostsToPersist = 200;
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -148,14 +151,14 @@ void HttpServerPropertiesManager::SetSupportsSpdy(
}
bool HttpServerPropertiesManager::HasAlternateProtocol(
- const net::HostPortPair& server) const {
+ const net::HostPortPair& server) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
return http_server_properties_impl_->HasAlternateProtocol(server);
}
net::PortAlternateProtocolPair
HttpServerPropertiesManager::GetAlternateProtocol(
- const net::HostPortPair& server) const {
+ const net::HostPortPair& server) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
return http_server_properties_impl_->GetAlternateProtocol(server);
}
@@ -327,7 +330,7 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() {
scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map(
new net::PipelineCapabilityMap);
scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map(
- new net::AlternateProtocolMap);
+ new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist));
for (base::DictionaryValue::Iterator it(*servers_dict); !it.IsAtEnd();
it.Advance()) {
@@ -393,7 +396,8 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() {
}
// Get alternate_protocol server.
- DCHECK(!ContainsKey(*alternate_protocol_map, server));
+ DCHECK(alternate_protocol_map->Peek(server) ==
+ alternate_protocol_map->end());
const base::DictionaryValue* port_alternate_protocol_dict = NULL;
if (!server_pref_dict->GetDictionaryWithoutPathExpansion(
"alternate_protocol", &port_alternate_protocol_dict)) {
@@ -427,7 +431,7 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnUI() {
port_alternate_protocol.port = port;
port_alternate_protocol.protocol = protocol;
- (*alternate_protocol_map)[server] = port_alternate_protocol;
+ alternate_protocol_map->Put(server, port_alternate_protocol);
} while (false);
}
@@ -516,9 +520,15 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnIO(
*spdy_settings_map = http_server_properties_impl_->spdy_settings_map();
net::AlternateProtocolMap* alternate_protocol_map =
- new net::AlternateProtocolMap;
- *alternate_protocol_map =
+ new net::AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist);
+ const net::AlternateProtocolMap& map =
http_server_properties_impl_->alternate_protocol_map();
+ int count = 0;
+ for (net::AlternateProtocolMap::const_iterator it = map.begin();
+ it != map.end() && count < kMaxAlternateProtocolHostsToPersist;
+ ++it, ++count) {
+ alternate_protocol_map->Put(it->first, it->second);
+ }
net::PipelineCapabilityMap* pipeline_capability_map =
new net::PipelineCapabilityMap;
@@ -569,6 +579,8 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI(
net::PipelineCapabilityMap* pipeline_capability_map,
const base::Closure& completion) {
+ // TODO(rtenneti): Fix ServerPrefMap to preserve MRU order of
+ // alternate_protocol_map and pipeline_capability_map.
typedef std::map<net::HostPortPair, ServerPref> ServerPrefMap;
ServerPrefMap server_pref_map;
@@ -592,8 +604,7 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI(
}
// Add servers that have SpdySettings to server_pref_map.
- for (net::SpdySettingsMap::iterator map_it =
- spdy_settings_map->begin();
+ for (net::SpdySettingsMap::iterator map_it = spdy_settings_map->begin();
map_it != spdy_settings_map->end(); ++map_it) {
const net::HostPortPair& server = map_it->first;
@@ -608,7 +619,7 @@ void HttpServerPropertiesManager::UpdatePrefsOnUI(
// Add AlternateProtocol servers to server_pref_map.
for (net::AlternateProtocolMap::const_iterator map_it =
- alternate_protocol_map->begin();
+ alternate_protocol_map->begin();
map_it != alternate_protocol_map->end(); ++map_it) {
const net::HostPortPair& server = map_it->first;
const net::PortAlternateProtocolPair& port_alternate_protocol =
« no previous file with comments | « chrome/browser/net/http_server_properties_manager.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698