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

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

Issue 1860343002: SHP 1: Change SupportsSpdy dict to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git sync Created 4 years, 8 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "net/base/ip_address.h" 15 #include "net/base/ip_address.h"
16 #include "net/base/port_util.h" 16 #include "net/base/port_util.h"
17 #include "url/gurl.h"
17 18
18 namespace net { 19 namespace net {
19 20
20 namespace { 21 namespace {
21 22
22 // Time to wait before starting an update the http_server_properties_impl_ cache 23 // Time to wait before starting an update the http_server_properties_impl_ cache
23 // from preferences. Scheduling another update during this period will reset the 24 // from preferences. Scheduling another update during this period will reset the
24 // timer. 25 // timer.
25 const int64_t kUpdateCacheDelayMs = 1000; 26 const int64_t kUpdateCacheDelayMs = 1000;
26 27
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 139 }
139 140
140 void HttpServerPropertiesManager::Clear(const base::Closure& completion) { 141 void HttpServerPropertiesManager::Clear(const base::Closure& completion) {
141 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 142 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
142 143
143 http_server_properties_impl_->Clear(); 144 http_server_properties_impl_->Clear();
144 UpdatePrefsFromCacheOnNetworkThread(completion); 145 UpdatePrefsFromCacheOnNetworkThread(completion);
145 } 146 }
146 147
147 bool HttpServerPropertiesManager::SupportsRequestPriority( 148 bool HttpServerPropertiesManager::SupportsRequestPriority(
148 const HostPortPair& server) { 149 const url::SchemeHostPort& server) {
149 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 150 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
150 return http_server_properties_impl_->SupportsRequestPriority(server); 151 return http_server_properties_impl_->SupportsRequestPriority(server);
151 } 152 }
152 153
153 bool HttpServerPropertiesManager::GetSupportsSpdy(const HostPortPair& server) { 154 bool HttpServerPropertiesManager::GetSupportsSpdy(
155 const url::SchemeHostPort& server) {
154 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 156 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
155 return http_server_properties_impl_->GetSupportsSpdy(server); 157 return http_server_properties_impl_->GetSupportsSpdy(server);
156 } 158 }
157 159
158 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, 160 void HttpServerPropertiesManager::SetSupportsSpdy(
159 bool support_spdy) { 161 const url::SchemeHostPort& server,
162 bool support_spdy) {
160 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 163 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
161 164
162 bool old_support_spdy = http_server_properties_impl_->GetSupportsSpdy(server); 165 bool old_support_spdy = http_server_properties_impl_->GetSupportsSpdy(server);
163 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); 166 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy);
164 bool new_support_spdy = http_server_properties_impl_->GetSupportsSpdy(server); 167 bool new_support_spdy = http_server_properties_impl_->GetSupportsSpdy(server);
165 if (old_support_spdy != new_support_spdy) 168 if (old_support_spdy != new_support_spdy)
166 ScheduleUpdatePrefsOnNetworkThread(SUPPORTS_SPDY); 169 ScheduleUpdatePrefsOnNetworkThread(SUPPORTS_SPDY);
167 } 170 }
168 171
169 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) { 172 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (!http_server_properties_dict.GetListWithoutPathExpansion( 484 if (!http_server_properties_dict.GetListWithoutPathExpansion(
482 kServersKey, &servers_list)) { 485 kServersKey, &servers_list)) {
483 DVLOG(1) << "Malformed http_server_properties for servers list."; 486 DVLOG(1) << "Malformed http_server_properties for servers list.";
484 return; 487 return;
485 } 488 }
486 } 489 }
487 490
488 IPAddress* addr = new IPAddress; 491 IPAddress* addr = new IPAddress;
489 ReadSupportsQuic(http_server_properties_dict, addr); 492 ReadSupportsQuic(http_server_properties_dict, addr);
490 493
491 // String is host/port pair of spdy server. 494 // String is "scheme://host:port" tuple of spdy server.
492 std::unique_ptr<ServerList> spdy_servers(new ServerList); 495 std::unique_ptr<ServerList> spdy_servers(new ServerList);
493 std::unique_ptr<SpdySettingsMap> spdy_settings_map( 496 std::unique_ptr<SpdySettingsMap> spdy_settings_map(
494 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); 497 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist));
495 std::unique_ptr<AlternativeServiceMap> alternative_service_map( 498 std::unique_ptr<AlternativeServiceMap> alternative_service_map(
496 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist)); 499 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist));
497 std::unique_ptr<ServerNetworkStatsMap> server_network_stats_map( 500 std::unique_ptr<ServerNetworkStatsMap> server_network_stats_map(
498 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist)); 501 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist));
499 std::unique_ptr<QuicServerInfoMap> quic_server_info_map( 502 std::unique_ptr<QuicServerInfoMap> quic_server_info_map(
500 new QuicServerInfoMap(QuicServerInfoMap::NO_AUTO_EVICT)); 503 new QuicServerInfoMap(QuicServerInfoMap::NO_AUTO_EVICT));
501 504
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 542 }
540 543
541 bool HttpServerPropertiesManager::AddServersData( 544 bool HttpServerPropertiesManager::AddServersData(
542 const base::DictionaryValue& servers_dict, 545 const base::DictionaryValue& servers_dict,
543 ServerList* spdy_servers, 546 ServerList* spdy_servers,
544 SpdySettingsMap* spdy_settings_map, 547 SpdySettingsMap* spdy_settings_map,
545 AlternativeServiceMap* alternative_service_map, 548 AlternativeServiceMap* alternative_service_map,
546 ServerNetworkStatsMap* network_stats_map) { 549 ServerNetworkStatsMap* network_stats_map) {
547 for (base::DictionaryValue::Iterator it(servers_dict); !it.IsAtEnd(); 550 for (base::DictionaryValue::Iterator it(servers_dict); !it.IsAtEnd();
548 it.Advance()) { 551 it.Advance()) {
552 // TODO(zhongyi): get server's scheme/host/port when servers_dict migrates
553 // to SchemeHostPort.
549 // Get server's host/pair. 554 // Get server's host/pair.
550 const std::string& server_str = it.key(); 555 const std::string& server_str = it.key();
551 HostPortPair server = HostPortPair::FromString(server_str); 556 HostPortPair server = HostPortPair::FromString(server_str);
552 if (server.host().empty()) { 557 if (server.host().empty()) {
553 DVLOG(1) << "Malformed http_server_properties for server: " << server_str; 558 DVLOG(1) << "Malformed http_server_properties for server: " << server_str;
554 return false; 559 return false;
555 } 560 }
556 561
557 const base::DictionaryValue* server_pref_dict = nullptr; 562 const base::DictionaryValue* server_pref_dict = nullptr;
558 if (!it.value().GetAsDictionary(&server_pref_dict)) { 563 if (!it.value().GetAsDictionary(&server_pref_dict)) {
559 DVLOG(1) << "Malformed http_server_properties server: " << server_str; 564 DVLOG(1) << "Malformed http_server_properties server: " << server_str;
560 return false; 565 return false;
561 } 566 }
562 567
563 // Get if server supports Spdy. 568 // Get if server supports Spdy.
564 bool supports_spdy = false; 569 bool supports_spdy = false;
565 if ((server_pref_dict->GetBoolean(kSupportsSpdyKey, &supports_spdy)) && 570 if ((server_pref_dict->GetBoolean(kSupportsSpdyKey, &supports_spdy)) &&
566 supports_spdy) { 571 supports_spdy) {
567 spdy_servers->push_back(server_str); 572 // TODO(zhongyi): fill in the scheme field when servers_dict has scheme.
573 std::string spdy_server_url = "https://" + server_str;
574 url::SchemeHostPort spdy_server((GURL(spdy_server_url)));
575 spdy_servers->push_back(spdy_server.Serialize());
568 } 576 }
569 577
570 AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map); 578 AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map);
571 if (!AddToAlternativeServiceMap(server, *server_pref_dict, 579 if (!AddToAlternativeServiceMap(server, *server_pref_dict,
572 alternative_service_map) || 580 alternative_service_map) ||
573 !AddToNetworkStatsMap(server, *server_pref_dict, network_stats_map)) { 581 !AddToNetworkStatsMap(server, *server_pref_dict, network_stats_map)) {
574 return false; 582 return false;
575 } 583 }
576 } 584 }
577 return true; 585 return true;
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 quic_servers_dict); 1247 quic_servers_dict);
1240 } 1248 }
1241 1249
1242 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 1250 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
1243 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 1251 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
1244 if (!setting_prefs_) 1252 if (!setting_prefs_)
1245 ScheduleUpdateCacheOnPrefThread(); 1253 ScheduleUpdateCacheOnPrefThread();
1246 } 1254 }
1247 1255
1248 } // namespace net 1256 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698