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

Side by Side Diff: net/http/http_server_properties_manager_unittest.cc

Issue 2133393002: Serialize NPN_HTTP_2 as "h2" instead of "npn-h2". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
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 unified diff | Download patch
« no previous file with comments | « net/http/http_server_properties.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_server_properties_manager.h" 5 #include "net/http/http_server_properties_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 url::SchemeHostPort google_server("https", "www.google.com", 443); 239 url::SchemeHostPort google_server("https", "www.google.com", 443);
240 url::SchemeHostPort mail_server("https", "mail.google.com", 443); 240 url::SchemeHostPort mail_server("https", "mail.google.com", 443);
241 241
242 // Set supports_spdy for https://www.google.com:443. 242 // Set supports_spdy for https://www.google.com:443.
243 server_pref_dict->SetBoolean("supports_spdy", true); 243 server_pref_dict->SetBoolean("supports_spdy", true);
244 244
245 // Set up alternative_services for https://www.google.com. 245 // Set up alternative_services for https://www.google.com.
246 std::unique_ptr<base::DictionaryValue> alternative_service_dict0( 246 std::unique_ptr<base::DictionaryValue> alternative_service_dict0(
247 new base::DictionaryValue); 247 new base::DictionaryValue);
248 alternative_service_dict0->SetInteger("port", 443); 248 alternative_service_dict0->SetInteger("port", 443);
249 alternative_service_dict0->SetString("protocol_str", "npn-h2"); 249 alternative_service_dict0->SetString("protocol_str", "h2");
250 std::unique_ptr<base::DictionaryValue> alternative_service_dict1( 250 std::unique_ptr<base::DictionaryValue> alternative_service_dict1(
251 new base::DictionaryValue); 251 new base::DictionaryValue);
252 alternative_service_dict1->SetInteger("port", 1234); 252 alternative_service_dict1->SetInteger("port", 1234);
253 alternative_service_dict1->SetString("protocol_str", "quic"); 253 alternative_service_dict1->SetString("protocol_str", "quic");
254 base::ListValue* alternative_service_list0 = new base::ListValue; 254 base::ListValue* alternative_service_list0 = new base::ListValue;
255 alternative_service_list0->Append(std::move(alternative_service_dict0)); 255 alternative_service_list0->Append(std::move(alternative_service_dict0));
256 alternative_service_list0->Append(std::move(alternative_service_dict1)); 256 alternative_service_list0->Append(std::move(alternative_service_dict1));
257 server_pref_dict->SetWithoutPathExpansion("alternative_service", 257 server_pref_dict->SetWithoutPathExpansion("alternative_service",
258 alternative_service_list0); 258 alternative_service_list0);
259 259
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread(); 1114 http_server_props_manager_->ScheduleUpdateCacheOnPrefThread();
1115 base::RunLoop().RunUntilIdle(); 1115 base::RunLoop().RunUntilIdle();
1116 1116
1117 // Verify preferences. 1117 // Verify preferences.
1118 const char expected_json[] = 1118 const char expected_json[] =
1119 "{\"quic_servers\":{\"https://" 1119 "{\"quic_servers\":{\"https://"
1120 "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}}," 1120 "mail.google.com:80\":{\"server_info\":\"quic_server_info1\"}},"
1121 "\"servers\":[" 1121 "\"servers\":["
1122 "{\"http://www.google.com\":{" 1122 "{\"http://www.google.com\":{"
1123 "\"alternative_service\":[{\"expiration\":\"13756212000000000\"," 1123 "\"alternative_service\":[{\"expiration\":\"13756212000000000\","
1124 "\"port\":443,\"protocol_str\":\"npn-h2\"}," 1124 "\"port\":443,\"protocol_str\":\"h2\"},"
1125 "{\"expiration\":\"13758804000000000\",\"host\":\"www.google.com\"," 1125 "{\"expiration\":\"13758804000000000\",\"host\":\"www.google.com\","
1126 "\"port\":1234,\"protocol_str\":\"npn-h2\"}]}}," 1126 "\"port\":1234,\"protocol_str\":\"h2\"}]}},"
1127 "{\"http://mail.google.com\":{\"alternative_service\":[{" 1127 "{\"http://mail.google.com\":{\"alternative_service\":[{"
1128 "\"expiration\":\"9223372036854775807\",\"host\":\"foo.google.com\"," 1128 "\"expiration\":\"9223372036854775807\",\"host\":\"foo.google.com\","
1129 "\"port\":444,\"protocol_str\":\"npn-spdy/3.1\"}]," 1129 "\"port\":444,\"protocol_str\":\"npn-spdy/3.1\"}],"
1130 "\"network_stats\":{\"srtt\":42}}}" 1130 "\"network_stats\":{\"srtt\":42}}}"
1131 "]," 1131 "],"
1132 "\"supports_quic\":{\"address\":\"127.0.0.1\",\"used_quic\":true}," 1132 "\"supports_quic\":{\"address\":\"127.0.0.1\",\"used_quic\":true},"
1133 "\"version\":5}"; 1133 "\"version\":5}";
1134 1134
1135 const base::Value* http_server_properties = 1135 const base::Value* http_server_properties =
1136 &pref_delegate_->GetServerProperties(); 1136 &pref_delegate_->GetServerProperties();
1137 std::string preferences_json; 1137 std::string preferences_json;
1138 EXPECT_TRUE( 1138 EXPECT_TRUE(
1139 base::JSONWriter::Write(*http_server_properties, &preferences_json)); 1139 base::JSONWriter::Write(*http_server_properties, &preferences_json));
1140 EXPECT_EQ(expected_json, preferences_json); 1140 EXPECT_EQ(expected_json, preferences_json);
1141 } 1141 }
1142 1142
1143 TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) { 1143 TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
1144 std::unique_ptr<base::Value> server_value = base::JSONReader::Read( 1144 std::unique_ptr<base::Value> server_value = base::JSONReader::Read(
1145 "{\"alternative_service\":[{\"port\":443,\"protocol_str\":\"npn-h2\"}," 1145 "{\"alternative_service\":[{\"port\":443,\"protocol_str\":\"h2\"},"
1146 "{\"port\":123,\"protocol_str\":\"quic\"," 1146 "{\"port\":123,\"protocol_str\":\"quic\","
1147 "\"expiration\":\"9223372036854775807\"},{\"host\":\"example.org\"," 1147 "\"expiration\":\"9223372036854775807\"},{\"host\":\"example.org\","
1148 "\"port\":1234,\"protocol_str\":\"npn-h2\"," 1148 "\"port\":1234,\"protocol_str\":\"npn-h2\","
1149 "\"expiration\":\"13758804000000000\"}]}"); 1149 "\"expiration\":\"13758804000000000\"}]}");
1150 ASSERT_TRUE(server_value); 1150 ASSERT_TRUE(server_value);
1151 base::DictionaryValue* server_dict; 1151 base::DictionaryValue* server_dict;
1152 ASSERT_TRUE(server_value->GetAsDictionary(&server_dict)); 1152 ASSERT_TRUE(server_value->GetAsDictionary(&server_dict));
1153 1153
1154 const url::SchemeHostPort server("https", "example.com", 443); 1154 const url::SchemeHostPort server("https", "example.com", 443);
1155 AlternativeServiceMap alternative_service_map(/*max_size=*/5); 1155 AlternativeServiceMap alternative_service_map(/*max_size=*/5);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 // Shutdown comes before the task is executed. 1383 // Shutdown comes before the task is executed.
1384 http_server_props_manager_->ShutdownOnPrefThread(); 1384 http_server_props_manager_->ShutdownOnPrefThread();
1385 // Run the task after shutdown, but before deletion. 1385 // Run the task after shutdown, but before deletion.
1386 base::RunLoop().RunUntilIdle(); 1386 base::RunLoop().RunUntilIdle();
1387 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); 1387 Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
1388 http_server_props_manager_.reset(); 1388 http_server_props_manager_.reset();
1389 base::RunLoop().RunUntilIdle(); 1389 base::RunLoop().RunUntilIdle();
1390 } 1390 }
1391 1391
1392 } // namespace net 1392 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698