Index: net/http/http_server_properties_impl_unittest.cc |
diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc |
index 607eb1babbeaa053061598dd25b66de87170f5f2..31a6074e248231d86662d1a87f1b2ca1ee34574b 100644 |
--- a/net/http/http_server_properties_impl_unittest.cc |
+++ b/net/http/http_server_properties_impl_unittest.cc |
@@ -108,10 +108,11 @@ TEST_F(SpdyServerPropertiesTest, SetWithSchemeHostPort) { |
// Initializing https://www.google.com:443 and https://photos.google.com:443 |
// as spdy servers. |
- std::vector<std::string> spdy_servers1; |
- spdy_servers1.push_back(spdy_server_g); // Will be 0th index. |
- spdy_servers1.push_back(spdy_server_p); // Will be 1st index. |
- impl_.SetSpdyServers(&spdy_servers1, true); |
+ std::unique_ptr<SpdyServersMap> spdy_servers1 = |
+ base::MakeUnique<SpdyServersMap>(SpdyServersMap::NO_AUTO_EVICT); |
+ spdy_servers1->Put(spdy_server_g, true); |
+ spdy_servers1->Put(spdy_server_p, true); |
+ impl_.SetSpdyServers(std::move(spdy_servers1)); |
EXPECT_TRUE(impl_.SupportsRequestPriority(http_photo_server)); |
EXPECT_TRUE(impl_.SupportsRequestPriority(https_www_server)); |
EXPECT_FALSE(impl_.SupportsRequestPriority(http_google_server)); |
@@ -132,88 +133,81 @@ TEST_F(SpdyServerPropertiesTest, Set) { |
url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443); |
std::string spdy_server_m = spdy_server_mail.Serialize(); |
- // Check by initializing NULL spdy servers. |
- impl_.SetSpdyServers(NULL, true); |
- EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); |
- |
// Check by initializing empty spdy servers. |
- std::vector<std::string> spdy_servers; |
- impl_.SetSpdyServers(&spdy_servers, true); |
+ std::unique_ptr<SpdyServersMap> spdy_servers = |
+ base::MakeUnique<SpdyServersMap>(SpdyServersMap::NO_AUTO_EVICT); |
+ impl_.SetSpdyServers(std::move(spdy_servers)); |
EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); |
// Check by initializing www.google.com:443 and photos.google.com:443 as spdy |
// servers. |
- std::vector<std::string> spdy_servers1; |
- spdy_servers1.push_back(spdy_server_g); // Will be 0th index. |
- spdy_servers1.push_back(spdy_server_p); // Will be 1st index. |
- impl_.SetSpdyServers(&spdy_servers1, true); |
- EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos)); |
+ std::unique_ptr<SpdyServersMap> spdy_servers1 = |
+ base::MakeUnique<SpdyServersMap>(SpdyServersMap::NO_AUTO_EVICT); |
+ spdy_servers1->Put(spdy_server_g, true); |
+ spdy_servers1->Put(spdy_server_p, true); |
+ impl_.SetSpdyServers(std::move(spdy_servers1)); |
+ // Note: these calls affect MRU order. |
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos)); |
- // Verify spdy_server_g and spdy_server_d are in the list in the same order. |
- base::ListValue spdy_server_list; |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- EXPECT_EQ(2U, spdy_server_list.GetSize()); |
- std::string string_value_g; |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); // 0th index. |
- ASSERT_EQ(spdy_server_g, string_value_g); |
- std::string string_value_p; |
- ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_p)); // 1st index. |
- ASSERT_EQ(spdy_server_p, string_value_p); |
+ // Verify spdy_server_g and spdy_server_d are in the list in MRU order. |
+ std::vector<std::string> returned_spdy_servers; |
+ impl_.GetSpdyServerList(&returned_spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(2U, returned_spdy_servers.size()); |
+ EXPECT_EQ(spdy_server_p, returned_spdy_servers[0]); |
+ EXPECT_EQ(spdy_server_g, returned_spdy_servers[1]); |
// Check by initializing mail.google.com:443 and docs.google.com:443 as spdy |
// servers. |
- std::vector<std::string> spdy_servers2; |
- spdy_servers2.push_back(spdy_server_m); // Will be 2nd index. |
- spdy_servers2.push_back(spdy_server_d); // Will be 3rd index. |
- impl_.SetSpdyServers(&spdy_servers2, true); |
- |
- // Verify all the servers are in the list in the same order. |
- spdy_server_list.Clear(); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- EXPECT_EQ(4U, spdy_server_list.GetSize()); |
- |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
- ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_p)); |
- ASSERT_EQ(spdy_server_p, string_value_p); |
- std::string string_value_m; |
- ASSERT_TRUE(spdy_server_list.GetString(2, &string_value_m)); |
- ASSERT_EQ(spdy_server_m, string_value_m); |
- std::string string_value_d; |
- ASSERT_TRUE(spdy_server_list.GetString(3, &string_value_d)); |
- ASSERT_EQ(spdy_server_d, string_value_d); |
- |
- EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); |
+ std::unique_ptr<SpdyServersMap> spdy_servers2 = |
+ base::MakeUnique<SpdyServersMap>(SpdyServersMap::NO_AUTO_EVICT); |
+ spdy_servers2->Put(spdy_server_m, true); |
+ spdy_servers2->Put(spdy_server_d, true); |
+ impl_.SetSpdyServers(std::move(spdy_servers2)); |
+ |
+ // Verify all the servers are in the list in MRU order. Note that |
+ // SetSpdyServers will put existing spdy server entries in front of newly |
+ // added entries. |
+ returned_spdy_servers.clear(); |
+ impl_.GetSpdyServerList(&returned_spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(4U, returned_spdy_servers.size()); |
+ |
+ EXPECT_EQ(spdy_server_p, returned_spdy_servers[0]); |
+ EXPECT_EQ(spdy_server_g, returned_spdy_servers[1]); |
+ EXPECT_EQ(spdy_server_d, returned_spdy_servers[2]); |
+ EXPECT_EQ(spdy_server_m, returned_spdy_servers[3]); |
+ |
+ // Check these in reverse MRU order so that MRU order stays the same. |
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail)); |
- EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); |
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos)); |
// Verify new data that is being initialized overwrites what is already in the |
// memory and also verify the recency list order. |
// |
// Change supports SPDY value for photos and mails servers and order of |
// initalization shouldn't matter. |
- std::vector<std::string> spdy_servers3; |
- spdy_servers3.push_back(spdy_server_m); |
- spdy_servers3.push_back(spdy_server_p); |
- impl_.SetSpdyServers(&spdy_servers3, false); |
+ std::unique_ptr<SpdyServersMap> spdy_servers3 = |
+ base::MakeUnique<SpdyServersMap>(SpdyServersMap::NO_AUTO_EVICT); |
+ spdy_servers3->Put(spdy_server_m, false); |
+ spdy_servers3->Put(spdy_server_p, false); |
+ impl_.SetSpdyServers(std::move(spdy_servers3)); |
// Verify the entries are in the same order. |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- EXPECT_EQ(2U, spdy_server_list.GetSize()); |
+ returned_spdy_servers.clear(); |
+ impl_.GetSpdyServerList(&returned_spdy_servers, kMaxSupportsSpdyServerHosts); |
+ EXPECT_EQ(2U, returned_spdy_servers.size()); |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
- ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_d)); |
- ASSERT_EQ(spdy_server_d, string_value_d); |
+ ASSERT_EQ(spdy_server_g, returned_spdy_servers[0]); |
+ ASSERT_EQ(spdy_server_d, returned_spdy_servers[1]); |
// Verify photos and mail servers don't support SPDY and other servers support |
// SPDY. |
- EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); |
EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); |
- EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos)); |
+ EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); |
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
+ EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos)); |
} |
TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) { |
@@ -272,20 +266,18 @@ TEST_F(SpdyServerPropertiesTest, Clear) { |
} |
TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) { |
- base::ListValue spdy_server_list; |
+ std::vector<std::string> spdy_servers; |
// Check there are no spdy_servers. |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- EXPECT_EQ(0U, spdy_server_list.GetSize()); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ EXPECT_EQ(0U, spdy_servers.size()); |
// Check empty server is not added. |
url::SchemeHostPort spdy_server_empty("https", std::string(), 443); |
impl_.SetSupportsSpdy(spdy_server_empty, true); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- EXPECT_EQ(0U, spdy_server_list.GetSize()); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ EXPECT_EQ(0U, spdy_servers.size()); |
- std::string string_value_g; |
- std::string string_value_m; |
url::SchemeHostPort spdy_server_google("https", "www.google.com", 443); |
std::string spdy_server_g = spdy_server_google.Serialize(); |
url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443); |
@@ -293,46 +285,39 @@ TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) { |
// Add www.google.com:443 as not supporting SPDY. |
impl_.SetSupportsSpdy(spdy_server_google, false); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- EXPECT_EQ(0U, spdy_server_list.GetSize()); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ EXPECT_EQ(0U, spdy_servers.size()); |
// Add www.google.com:443 as supporting SPDY. |
impl_.SetSupportsSpdy(spdy_server_google, true); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- ASSERT_EQ(1U, spdy_server_list.GetSize()); |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(1U, spdy_servers.size()); |
+ ASSERT_EQ(spdy_server_g, spdy_servers[0]); |
// Add mail.google.com:443 as not supporting SPDY. |
impl_.SetSupportsSpdy(spdy_server_mail, false); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- ASSERT_EQ(1U, spdy_server_list.GetSize()); |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(1U, spdy_servers.size()); |
+ ASSERT_EQ(spdy_server_g, spdy_servers[0]); |
// Add mail.google.com:443 as supporting SPDY. |
impl_.SetSupportsSpdy(spdy_server_mail, true); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- ASSERT_EQ(2U, spdy_server_list.GetSize()); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(2U, spdy_servers.size()); |
// Verify www.google.com:443 and mail.google.com:443 are in the list. |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m)); |
- ASSERT_EQ(spdy_server_m, string_value_m); |
- ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
+ ASSERT_EQ(spdy_server_m, spdy_servers[0]); |
+ ASSERT_EQ(spdy_server_g, spdy_servers[1]); |
// Request for only one server and verify that we get only one server. |
- impl_.GetSpdyServerList(&spdy_server_list, 1); |
- ASSERT_EQ(1U, spdy_server_list.GetSize()); |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m)); |
- ASSERT_EQ(spdy_server_m, string_value_m); |
+ impl_.GetSpdyServerList(&spdy_servers, 1); |
+ ASSERT_EQ(1U, spdy_servers.size()); |
+ ASSERT_EQ(spdy_server_m, spdy_servers[0]); |
} |
-TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) { |
- base::ListValue spdy_server_list; |
+TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServers) { |
+ std::vector<std::string> spdy_servers; |
- std::string string_value_g; |
- std::string string_value_m; |
url::SchemeHostPort spdy_server_google("https", "www.google.com", 443); |
std::string spdy_server_g = spdy_server_google.Serialize(); |
url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443); |
@@ -340,30 +325,25 @@ TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) { |
// Add www.google.com:443 as supporting SPDY. |
impl_.SetSupportsSpdy(spdy_server_google, true); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- ASSERT_EQ(1U, spdy_server_list.GetSize()); |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(1U, spdy_servers.size()); |
+ ASSERT_EQ(spdy_server_g, spdy_servers[0]); |
// Add mail.google.com:443 as supporting SPDY. Verify mail.google.com:443 and |
// www.google.com:443 are in the list. |
impl_.SetSupportsSpdy(spdy_server_mail, true); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- ASSERT_EQ(2U, spdy_server_list.GetSize()); |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m)); |
- ASSERT_EQ(spdy_server_m, string_value_m); |
- ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(2U, spdy_servers.size()); |
+ ASSERT_EQ(spdy_server_m, spdy_servers[0]); |
+ ASSERT_EQ(spdy_server_g, spdy_servers[1]); |
// Get www.google.com:443 should reorder SpdyServerHostPortMap. Verify that it |
// is www.google.com:443 is the MRU server. |
EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); |
- impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); |
- ASSERT_EQ(2U, spdy_server_list.GetSize()); |
- ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); |
- ASSERT_EQ(spdy_server_g, string_value_g); |
- ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_m)); |
- ASSERT_EQ(spdy_server_m, string_value_m); |
+ impl_.GetSpdyServerList(&spdy_servers, kMaxSupportsSpdyServerHosts); |
+ ASSERT_EQ(2U, spdy_servers.size()); |
+ ASSERT_EQ(spdy_server_g, spdy_servers[0]); |
+ ASSERT_EQ(spdy_server_m, spdy_servers[1]); |
} |
typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest; |
@@ -442,14 +422,15 @@ TEST_F(AlternateProtocolServerPropertiesTest, Set) { |
// Prepare |alternative_service_map| to be loaded by |
// SetAlternativeServiceServers(). |
- AlternativeServiceMap alternative_service_map( |
- AlternativeServiceMap::NO_AUTO_EVICT); |
+ std::unique_ptr<AlternativeServiceMap> alternative_service_map = |
+ base::MakeUnique<AlternativeServiceMap>( |
+ AlternativeServiceMap::NO_AUTO_EVICT); |
const AlternativeService alternative_service3(kProtoHTTP2, "bar3", 123); |
base::Time expiration3 = now + base::TimeDelta::FromDays(3); |
const AlternativeServiceInfo alternative_service_info1(alternative_service3, |
expiration3); |
// Simulate updating data for 0th entry with data from Preferences. |
- alternative_service_map.Put( |
+ alternative_service_map->Put( |
test_server2, |
AlternativeServiceInfoVector(/*size=*/1, alternative_service_info1)); |
@@ -460,12 +441,12 @@ TEST_F(AlternateProtocolServerPropertiesTest, Set) { |
expiration4); |
// Add an old entry from Preferences, this will be added to end of recency |
// list. |
- alternative_service_map.Put( |
+ alternative_service_map->Put( |
test_server3, |
AlternativeServiceInfoVector(/*size=*/1, alternative_service_info2)); |
// MRU list will be test_server2, test_server1, test_server3. |
- impl_.SetAlternativeServiceServers(&alternative_service_map); |
+ impl_.SetAlternativeServiceServers(std::move(alternative_service_map)); |
// Verify alternative_service_map. |
const AlternativeServiceMap& map = impl_.alternative_service_map(); |
@@ -500,9 +481,10 @@ TEST_F(AlternateProtocolServerPropertiesTest, SetWithEmptyHostname) { |
SetAlternativeService(server, alternative_service_with_empty_hostname); |
impl_.MarkAlternativeServiceBroken(alternative_service_with_foo_hostname); |
- AlternativeServiceMap alternative_service_map( |
- AlternativeServiceMap::NO_AUTO_EVICT); |
- impl_.SetAlternativeServiceServers(&alternative_service_map); |
+ std::unique_ptr<AlternativeServiceMap> alternative_service_map = |
+ base::MakeUnique<AlternativeServiceMap>( |
+ AlternativeServiceMap::NO_AUTO_EVICT); |
+ impl_.SetAlternativeServiceServers(std::move(alternative_service_map)); |
EXPECT_TRUE( |
impl_.IsAlternativeServiceBroken(alternative_service_with_foo_hostname)); |
@@ -522,15 +504,16 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) { |
base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1); |
const AlternativeServiceInfo alternative_service_info(alternative_service, |
expiration); |
- AlternativeServiceMap alternative_service_map( |
- AlternativeServiceMap::NO_AUTO_EVICT); |
- alternative_service_map.Put( |
+ std::unique_ptr<AlternativeServiceMap> alternative_service_map = |
+ base::MakeUnique<AlternativeServiceMap>( |
+ AlternativeServiceMap::NO_AUTO_EVICT); |
+ alternative_service_map->Put( |
server, |
AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); |
// Prepare |alternative_service_map_| with a single key that has a single |
// AlternativeServiceInfo with identical hostname and port. |
- impl_.SetAlternativeServiceServers(&alternative_service_map); |
+ impl_.SetAlternativeServiceServers(std::move(alternative_service_map)); |
// GetAlternativeServiceInfos() should remove such AlternativeServiceInfo from |
// |alternative_service_map_|, emptying the AlternativeServiceInfoVector |
@@ -555,15 +538,16 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) { |
base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1); |
const AlternativeServiceInfo alternative_service_info(alternative_service, |
expiration); |
- AlternativeServiceMap alternative_service_map( |
- AlternativeServiceMap::NO_AUTO_EVICT); |
- alternative_service_map.Put( |
+ std::unique_ptr<AlternativeServiceMap> alternative_service_map = |
+ base::MakeUnique<AlternativeServiceMap>( |
+ AlternativeServiceMap::NO_AUTO_EVICT); |
+ alternative_service_map->Put( |
canonical_server, |
AlternativeServiceInfoVector(/*size=*/1, alternative_service_info)); |
// Prepare |alternative_service_map_| with a single key that has a single |
// AlternativeServiceInfo with identical hostname and port. |
- impl_.SetAlternativeServiceServers(&alternative_service_map); |
+ impl_.SetAlternativeServiceServers(std::move(alternative_service_map)); |
// GetAlternativeServiceInfos() should remove such AlternativeServiceInfo from |
// |alternative_service_map_|, emptying the AlternativeServiceInfoVector |
@@ -1093,7 +1077,7 @@ TEST_F(SupportsQuicServerPropertiesTest, Set) { |
// Check by initializing empty address. |
IPAddress initial_address; |
- impl_.SetSupportsQuic(&initial_address); |
+ impl_.SetSupportsQuic(initial_address); |
IPAddress address; |
EXPECT_FALSE(impl_.GetSupportsQuic(&address)); |
@@ -1101,7 +1085,7 @@ TEST_F(SupportsQuicServerPropertiesTest, Set) { |
// Check by initializing with a valid address. |
initial_address = IPAddress::IPv4Localhost(); |
- impl_.SetSupportsQuic(&initial_address); |
+ impl_.SetSupportsQuic(initial_address); |
EXPECT_TRUE(impl_.GetSupportsQuic(&address)); |
EXPECT_EQ(initial_address, address); |
@@ -1129,9 +1113,10 @@ TEST_F(ServerNetworkStatsServerPropertiesTest, Set) { |
url::SchemeHostPort google_server("https", "www.google.com", 443); |
// Check by initializing empty ServerNetworkStats. |
- ServerNetworkStatsMap init_server_network_stats_map( |
- ServerNetworkStatsMap::NO_AUTO_EVICT); |
- impl_.SetServerNetworkStats(&init_server_network_stats_map); |
+ std::unique_ptr<ServerNetworkStatsMap> init_server_network_stats_map = |
+ base::MakeUnique<ServerNetworkStatsMap>( |
+ ServerNetworkStatsMap::NO_AUTO_EVICT); |
+ impl_.SetServerNetworkStats(std::move(init_server_network_stats_map)); |
const ServerNetworkStats* stats = impl_.GetServerNetworkStats(google_server); |
EXPECT_EQ(NULL, stats); |
@@ -1139,8 +1124,10 @@ TEST_F(ServerNetworkStatsServerPropertiesTest, Set) { |
ServerNetworkStats stats_google; |
stats_google.srtt = base::TimeDelta::FromMicroseconds(10); |
stats_google.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(100); |
- init_server_network_stats_map.Put(google_server, stats_google); |
- impl_.SetServerNetworkStats(&init_server_network_stats_map); |
+ init_server_network_stats_map = base::MakeUnique<ServerNetworkStatsMap>( |
+ ServerNetworkStatsMap::NO_AUTO_EVICT); |
+ init_server_network_stats_map->Put(google_server, stats_google); |
+ impl_.SetServerNetworkStats(std::move(init_server_network_stats_map)); |
// Verify data for www.google.com:443. |
ASSERT_EQ(1u, impl_.server_network_stats_map().size()); |
@@ -1160,23 +1147,24 @@ TEST_F(ServerNetworkStatsServerPropertiesTest, Set) { |
// Prepare |server_network_stats_map| to be loaded by |
// SetServerNetworkStats(). |
- ServerNetworkStatsMap server_network_stats_map( |
- ServerNetworkStatsMap::NO_AUTO_EVICT); |
+ std::unique_ptr<ServerNetworkStatsMap> server_network_stats_map = |
+ base::MakeUnique<ServerNetworkStatsMap>( |
+ ServerNetworkStatsMap::NO_AUTO_EVICT); |
// Change the values for |docs_server|. |
ServerNetworkStats new_stats_docs; |
new_stats_docs.srtt = base::TimeDelta::FromMicroseconds(25); |
new_stats_docs.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(250); |
- server_network_stats_map.Put(docs_server, new_stats_docs); |
+ server_network_stats_map->Put(docs_server, new_stats_docs); |
// Add data for mail.google.com:443. |
url::SchemeHostPort mail_server("https", "mail.google.com", 443); |
ServerNetworkStats stats_mail; |
stats_mail.srtt = base::TimeDelta::FromMicroseconds(30); |
stats_mail.bandwidth_estimate = QuicBandwidth::FromBitsPerSecond(300); |
- server_network_stats_map.Put(mail_server, stats_mail); |
+ server_network_stats_map->Put(mail_server, stats_mail); |
// Recency order will be |docs_server|, |google_server| and |mail_server|. |
- impl_.SetServerNetworkStats(&server_network_stats_map); |
+ impl_.SetServerNetworkStats(std::move(server_network_stats_map)); |
const ServerNetworkStatsMap& map = impl_.server_network_stats_map(); |
ASSERT_EQ(3u, map.size()); |
@@ -1238,14 +1226,17 @@ TEST_F(QuicServerInfoServerPropertiesTest, Set) { |
EXPECT_EQ(10u, impl_.quic_server_info_map().max_size()); |
// Check empty map. |
- QuicServerInfoMap init_quic_server_info_map(QuicServerInfoMap::NO_AUTO_EVICT); |
- impl_.SetQuicServerInfoMap(&init_quic_server_info_map); |
+ std::unique_ptr<QuicServerInfoMap> init_quic_server_info_map = |
+ base::MakeUnique<QuicServerInfoMap>(QuicServerInfoMap::NO_AUTO_EVICT); |
+ impl_.SetQuicServerInfoMap(std::move(init_quic_server_info_map)); |
EXPECT_EQ(0u, impl_.quic_server_info_map().size()); |
// Check by initializing with www.google.com:443. |
std::string google_server_info("google_quic_server_info"); |
- init_quic_server_info_map.Put(google_quic_server_id, google_server_info); |
- impl_.SetQuicServerInfoMap(&init_quic_server_info_map); |
+ init_quic_server_info_map = |
+ base::MakeUnique<QuicServerInfoMap>(QuicServerInfoMap::NO_AUTO_EVICT); |
+ init_quic_server_info_map->Put(google_quic_server_id, google_server_info); |
+ impl_.SetQuicServerInfoMap(std::move(init_quic_server_info_map)); |
// Verify data for www.google.com:443. |
EXPECT_EQ(1u, impl_.quic_server_info_map().size()); |
@@ -1274,16 +1265,17 @@ TEST_F(QuicServerInfoServerPropertiesTest, Set) { |
// Prepare |quic_server_info_map| to be loaded by |
// SetQuicServerInfoMap(). |
- QuicServerInfoMap quic_server_info_map(QuicServerInfoMap::NO_AUTO_EVICT); |
+ std::unique_ptr<QuicServerInfoMap> quic_server_info_map = |
+ base::MakeUnique<QuicServerInfoMap>(QuicServerInfoMap::NO_AUTO_EVICT); |
// Change the values for |docs_server|. |
std::string new_docs_server_info("new_docs_quic_server_info"); |
- quic_server_info_map.Put(docs_quic_server_id, new_docs_server_info); |
+ quic_server_info_map->Put(docs_quic_server_id, new_docs_server_info); |
// Add data for mail.google.com:443. |
HostPortPair mail_server("mail.google.com", 443); |
QuicServerId mail_quic_server_id(mail_server, PRIVACY_MODE_ENABLED); |
std::string mail_server_info("mail_quic_server_info"); |
- quic_server_info_map.Put(mail_quic_server_id, mail_server_info); |
- impl_.SetQuicServerInfoMap(&quic_server_info_map); |
+ quic_server_info_map->Put(mail_quic_server_id, mail_server_info); |
+ impl_.SetQuicServerInfoMap(std::move(quic_server_info_map)); |
// Recency order will be |docs_server|, |google_server| and |mail_server|. |
const QuicServerInfoMap& memory_map = impl_.quic_server_info_map(); |