OLD | NEW |
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.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 Clear(base::Closure()); | 126 Clear(base::Closure()); |
127 } | 127 } |
128 | 128 |
129 void HttpServerPropertiesManager::Clear(const base::Closure& completion) { | 129 void HttpServerPropertiesManager::Clear(const base::Closure& completion) { |
130 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 130 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
131 | 131 |
132 http_server_properties_impl_->Clear(); | 132 http_server_properties_impl_->Clear(); |
133 UpdatePrefsFromCacheOnNetworkThread(completion); | 133 UpdatePrefsFromCacheOnNetworkThread(completion); |
134 } | 134 } |
135 | 135 |
136 bool HttpServerPropertiesManager::SupportsSpdy(const HostPortPair& server) { | 136 bool HttpServerPropertiesManager::SupportsRequestPriority( |
| 137 const HostPortPair& server) { |
137 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 138 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
138 return http_server_properties_impl_->SupportsSpdy(server); | 139 return http_server_properties_impl_->SupportsRequestPriority(server); |
139 } | 140 } |
140 | 141 |
141 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, | 142 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, |
142 bool support_spdy) { | 143 bool support_spdy) { |
143 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 144 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
144 | 145 |
145 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); | 146 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); |
146 ScheduleUpdatePrefsOnNetworkThread(); | 147 ScheduleUpdatePrefsOnNetworkThread(); |
147 } | 148 } |
148 | 149 |
149 bool HttpServerPropertiesManager::RequiresHTTP11( | 150 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) { |
150 const net::HostPortPair& server) { | |
151 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 151 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
152 return http_server_properties_impl_->RequiresHTTP11(server); | 152 return http_server_properties_impl_->RequiresHTTP11(server); |
153 } | 153 } |
154 | 154 |
155 void HttpServerPropertiesManager::SetHTTP11Required( | 155 void HttpServerPropertiesManager::SetHTTP11Required( |
156 const net::HostPortPair& server) { | 156 const HostPortPair& server) { |
157 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 157 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
158 | 158 |
159 http_server_properties_impl_->SetHTTP11Required(server); | 159 http_server_properties_impl_->SetHTTP11Required(server); |
160 ScheduleUpdatePrefsOnNetworkThread(); | 160 ScheduleUpdatePrefsOnNetworkThread(); |
161 } | 161 } |
162 | 162 |
163 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server, | 163 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server, |
164 SSLConfig* ssl_config) { | 164 SSLConfig* ssl_config) { |
165 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 165 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
166 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config); | 166 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 new AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist); | 606 new AlternateProtocolMap(kMaxAlternateProtocolHostsToPersist); |
607 const AlternateProtocolMap& map = | 607 const AlternateProtocolMap& map = |
608 http_server_properties_impl_->alternate_protocol_map(); | 608 http_server_properties_impl_->alternate_protocol_map(); |
609 count = 0; | 609 count = 0; |
610 typedef std::map<std::string, bool> CanonicalHostPersistedMap; | 610 typedef std::map<std::string, bool> CanonicalHostPersistedMap; |
611 CanonicalHostPersistedMap persisted_map; | 611 CanonicalHostPersistedMap persisted_map; |
612 for (AlternateProtocolMap::const_iterator it = map.begin(); | 612 for (AlternateProtocolMap::const_iterator it = map.begin(); |
613 it != map.end() && count < kMaxAlternateProtocolHostsToPersist; ++it) { | 613 it != map.end() && count < kMaxAlternateProtocolHostsToPersist; ++it) { |
614 const HostPortPair& server = it->first; | 614 const HostPortPair& server = it->first; |
615 std::string canonical_suffix = | 615 std::string canonical_suffix = |
616 http_server_properties_impl_->GetCanonicalSuffix(server); | 616 http_server_properties_impl_->GetCanonicalSuffix(server.host()); |
617 if (!canonical_suffix.empty()) { | 617 if (!canonical_suffix.empty()) { |
618 if (persisted_map.find(canonical_suffix) != persisted_map.end()) | 618 if (persisted_map.find(canonical_suffix) != persisted_map.end()) |
619 continue; | 619 continue; |
620 persisted_map[canonical_suffix] = true; | 620 persisted_map[canonical_suffix] = true; |
621 } | 621 } |
622 alternate_protocol_map->Put(server, it->second); | 622 alternate_protocol_map->Put(server, it->second); |
623 ++count; | 623 ++count; |
624 } | 624 } |
625 | 625 |
626 SupportsQuicMap* supports_quic_map = new SupportsQuicMap(); | 626 SupportsQuicMap* supports_quic_map = new SupportsQuicMap(); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 completion.Run(); | 858 completion.Run(); |
859 } | 859 } |
860 | 860 |
861 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 861 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
862 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 862 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
863 if (!setting_prefs_) | 863 if (!setting_prefs_) |
864 ScheduleUpdateCacheOnPrefThread(); | 864 ScheduleUpdateCacheOnPrefThread(); |
865 } | 865 } |
866 | 866 |
867 } // namespace net | 867 } // namespace net |
OLD | NEW |