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

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: Use SSL info to extract scheme, fix resource scheduler unittest 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (!http_server_properties_dict.GetListWithoutPathExpansion( 485 if (!http_server_properties_dict.GetListWithoutPathExpansion(
483 kServersKey, &servers_list)) { 486 kServersKey, &servers_list)) {
484 DVLOG(1) << "Malformed http_server_properties for servers list."; 487 DVLOG(1) << "Malformed http_server_properties for servers list.";
485 return; 488 return;
486 } 489 }
487 } 490 }
488 491
489 IPAddress* addr = new IPAddress; 492 IPAddress* addr = new IPAddress;
490 ReadSupportsQuic(http_server_properties_dict, addr); 493 ReadSupportsQuic(http_server_properties_dict, addr);
491 494
492 // String is host/port pair of spdy server. 495 // String is "scheme://host:port" tuple of spdy server.
493 scoped_ptr<ServerList> spdy_servers(new ServerList); 496 scoped_ptr<ServerList> spdy_servers(new ServerList);
494 scoped_ptr<SpdySettingsMap> spdy_settings_map( 497 scoped_ptr<SpdySettingsMap> spdy_settings_map(
495 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); 498 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist));
496 scoped_ptr<AlternativeServiceMap> alternative_service_map( 499 scoped_ptr<AlternativeServiceMap> alternative_service_map(
497 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist)); 500 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist));
498 scoped_ptr<ServerNetworkStatsMap> server_network_stats_map( 501 scoped_ptr<ServerNetworkStatsMap> server_network_stats_map(
499 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist)); 502 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist));
500 scoped_ptr<QuicServerInfoMap> quic_server_info_map( 503 scoped_ptr<QuicServerInfoMap> quic_server_info_map(
501 new QuicServerInfoMap(QuicServerInfoMap::NO_AUTO_EVICT)); 504 new QuicServerInfoMap(QuicServerInfoMap::NO_AUTO_EVICT));
502 505
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 543 }
541 544
542 bool HttpServerPropertiesManager::AddServersData( 545 bool HttpServerPropertiesManager::AddServersData(
543 const base::DictionaryValue& servers_dict, 546 const base::DictionaryValue& servers_dict,
544 ServerList* spdy_servers, 547 ServerList* spdy_servers,
545 SpdySettingsMap* spdy_settings_map, 548 SpdySettingsMap* spdy_settings_map,
546 AlternativeServiceMap* alternative_service_map, 549 AlternativeServiceMap* alternative_service_map,
547 ServerNetworkStatsMap* network_stats_map) { 550 ServerNetworkStatsMap* network_stats_map) {
548 for (base::DictionaryValue::Iterator it(servers_dict); !it.IsAtEnd(); 551 for (base::DictionaryValue::Iterator it(servers_dict); !it.IsAtEnd();
549 it.Advance()) { 552 it.Advance()) {
553 // TODO(zhongyi): get server's scheme/host/port when servers_dict migrates
554 // to SchemeHostPort.
550 // Get server's host/pair. 555 // Get server's host/pair.
551 const std::string& server_str = it.key(); 556 const std::string& server_str = it.key();
552 HostPortPair server = HostPortPair::FromString(server_str); 557 HostPortPair server = HostPortPair::FromString(server_str);
553 if (server.host().empty()) { 558 if (server.host().empty()) {
554 DVLOG(1) << "Malformed http_server_properties for server: " << server_str; 559 DVLOG(1) << "Malformed http_server_properties for server: " << server_str;
555 return false; 560 return false;
556 } 561 }
557 562
558 const base::DictionaryValue* server_pref_dict = nullptr; 563 const base::DictionaryValue* server_pref_dict = nullptr;
559 if (!it.value().GetAsDictionary(&server_pref_dict)) { 564 if (!it.value().GetAsDictionary(&server_pref_dict)) {
560 DVLOG(1) << "Malformed http_server_properties server: " << server_str; 565 DVLOG(1) << "Malformed http_server_properties server: " << server_str;
561 return false; 566 return false;
562 } 567 }
563 568
564 // Get if server supports Spdy. 569 // Get if server supports Spdy.
565 bool supports_spdy = false; 570 bool supports_spdy = false;
566 if ((server_pref_dict->GetBoolean(kSupportsSpdyKey, &supports_spdy)) && 571 if ((server_pref_dict->GetBoolean(kSupportsSpdyKey, &supports_spdy)) &&
567 supports_spdy) { 572 supports_spdy) {
568 spdy_servers->push_back(server_str); 573 // TODO(zhongyi): fill in the scheme field when servers_dict has scheme.
574 std::string spdy_server_url = "http://" + server_str;
Ryan Hamilton 2016/04/08 18:32:51 I know this is temporary, but might as well make t
575 url::SchemeHostPort spdy_server((GURL(spdy_server_url)));
576 spdy_servers->push_back(spdy_server.Serialize());
569 } 577 }
570 578
571 AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map); 579 AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map);
572 if (!AddToAlternativeServiceMap(server, *server_pref_dict, 580 if (!AddToAlternativeServiceMap(server, *server_pref_dict,
573 alternative_service_map) || 581 alternative_service_map) ||
574 !AddToNetworkStatsMap(server, *server_pref_dict, network_stats_map)) { 582 !AddToNetworkStatsMap(server, *server_pref_dict, network_stats_map)) {
575 return false; 583 return false;
576 } 584 }
577 } 585 }
578 return true; 586 return true;
(...skipping 660 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