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_impl.cc

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: rebase on r476634 Created 3 years, 6 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_impl.h ('k') | net/http/transport_security_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "net/http/http_server_properties_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 20 matching lines...) Expand all
31 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), 31 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT),
32 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), 32 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT),
33 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist) { 33 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist) {
34 canonical_suffixes_.push_back(".ggpht.com"); 34 canonical_suffixes_.push_back(".ggpht.com");
35 canonical_suffixes_.push_back(".c.youtube.com"); 35 canonical_suffixes_.push_back(".c.youtube.com");
36 canonical_suffixes_.push_back(".googlevideo.com"); 36 canonical_suffixes_.push_back(".googlevideo.com");
37 canonical_suffixes_.push_back(".googleusercontent.com"); 37 canonical_suffixes_.push_back(".googleusercontent.com");
38 } 38 }
39 39
40 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { 40 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
41 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
41 } 42 }
42 43
43 void HttpServerPropertiesImpl::SetSpdyServers( 44 void HttpServerPropertiesImpl::SetSpdyServers(
44 std::vector<std::string>* spdy_servers, 45 std::vector<std::string>* spdy_servers,
45 bool support_spdy) { 46 bool support_spdy) {
46 DCHECK(CalledOnValidThread()); 47 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
47 if (!spdy_servers) 48 if (!spdy_servers)
48 return; 49 return;
49 50
50 // Add the entries from persisted data. 51 // Add the entries from persisted data.
51 SpdyServersMap spdy_servers_map(SpdyServersMap::NO_AUTO_EVICT); 52 SpdyServersMap spdy_servers_map(SpdyServersMap::NO_AUTO_EVICT);
52 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); 53 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin();
53 it != spdy_servers->rend(); ++it) { 54 it != spdy_servers->rend(); ++it) {
54 spdy_servers_map.Put(*it, support_spdy); 55 spdy_servers_map.Put(*it, support_spdy);
55 } 56 }
56 57
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 it != temp_map.rend(); ++it) { 175 it != temp_map.rend(); ++it) {
175 if (quic_server_info_map_.Get(it->first) == quic_server_info_map_.end()) { 176 if (quic_server_info_map_.Get(it->first) == quic_server_info_map_.end()) {
176 quic_server_info_map_.Put(it->first, it->second); 177 quic_server_info_map_.Put(it->first, it->second);
177 } 178 }
178 } 179 }
179 } 180 }
180 181
181 void HttpServerPropertiesImpl::GetSpdyServerList( 182 void HttpServerPropertiesImpl::GetSpdyServerList(
182 base::ListValue* spdy_server_list, 183 base::ListValue* spdy_server_list,
183 size_t max_size) const { 184 size_t max_size) const {
184 DCHECK(CalledOnValidThread()); 185 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
185 DCHECK(spdy_server_list); 186 DCHECK(spdy_server_list);
186 spdy_server_list->Clear(); 187 spdy_server_list->Clear();
187 size_t count = 0; 188 size_t count = 0;
188 // Get the list of servers (scheme/host/port) that support SPDY. 189 // Get the list of servers (scheme/host/port) that support SPDY.
189 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); 190 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin();
190 it != spdy_servers_map_.end() && count < max_size; ++it) { 191 it != spdy_servers_map_.end() && count < max_size; ++it) {
191 const std::string spdy_server = it->first; 192 const std::string spdy_server = it->first;
192 if (it->second) { 193 if (it->second) {
193 spdy_server_list->AppendString(spdy_server); 194 spdy_server_list->AppendString(spdy_server);
194 ++count; 195 ++count;
195 } 196 }
196 } 197 }
197 } 198 }
198 199
199 void HttpServerPropertiesImpl::Clear() { 200 void HttpServerPropertiesImpl::Clear() {
200 DCHECK(CalledOnValidThread()); 201 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
201 spdy_servers_map_.Clear(); 202 spdy_servers_map_.Clear();
202 alternative_service_map_.Clear(); 203 alternative_service_map_.Clear();
203 canonical_host_to_origin_map_.clear(); 204 canonical_host_to_origin_map_.clear();
204 last_quic_address_ = IPAddress(); 205 last_quic_address_ = IPAddress();
205 server_network_stats_map_.Clear(); 206 server_network_stats_map_.Clear();
206 quic_server_info_map_.Clear(); 207 quic_server_info_map_.Clear();
207 } 208 }
208 209
209 bool HttpServerPropertiesImpl::SupportsRequestPriority( 210 bool HttpServerPropertiesImpl::SupportsRequestPriority(
210 const url::SchemeHostPort& server) { 211 const url::SchemeHostPort& server) {
211 DCHECK(CalledOnValidThread()); 212 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
212 if (server.host().empty()) 213 if (server.host().empty())
213 return false; 214 return false;
214 215
215 if (GetSupportsSpdy(server)) 216 if (GetSupportsSpdy(server))
216 return true; 217 return true;
217 const AlternativeServiceInfoVector alternative_service_info_vector = 218 const AlternativeServiceInfoVector alternative_service_info_vector =
218 GetAlternativeServiceInfos(server); 219 GetAlternativeServiceInfos(server);
219 for (const AlternativeServiceInfo& alternative_service_info : 220 for (const AlternativeServiceInfo& alternative_service_info :
220 alternative_service_info_vector) { 221 alternative_service_info_vector) {
221 if (alternative_service_info.alternative_service.protocol == kProtoQUIC) { 222 if (alternative_service_info.alternative_service.protocol == kProtoQUIC) {
222 return true; 223 return true;
223 } 224 }
224 } 225 }
225 return false; 226 return false;
226 } 227 }
227 228
228 bool HttpServerPropertiesImpl::GetSupportsSpdy( 229 bool HttpServerPropertiesImpl::GetSupportsSpdy(
229 const url::SchemeHostPort& server) { 230 const url::SchemeHostPort& server) {
230 DCHECK(CalledOnValidThread()); 231 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
231 if (server.host().empty()) 232 if (server.host().empty())
232 return false; 233 return false;
233 234
234 SpdyServersMap::iterator spdy_server = 235 SpdyServersMap::iterator spdy_server =
235 spdy_servers_map_.Get(server.Serialize()); 236 spdy_servers_map_.Get(server.Serialize());
236 return spdy_server != spdy_servers_map_.end() && spdy_server->second; 237 return spdy_server != spdy_servers_map_.end() && spdy_server->second;
237 } 238 }
238 239
239 void HttpServerPropertiesImpl::SetSupportsSpdy( 240 void HttpServerPropertiesImpl::SetSupportsSpdy(
240 const url::SchemeHostPort& server, 241 const url::SchemeHostPort& server,
241 bool support_spdy) { 242 bool support_spdy) {
242 DCHECK(CalledOnValidThread()); 243 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
243 if (server.host().empty()) 244 if (server.host().empty())
244 return; 245 return;
245 246
246 SpdyServersMap::iterator spdy_server = 247 SpdyServersMap::iterator spdy_server =
247 spdy_servers_map_.Get(server.Serialize()); 248 spdy_servers_map_.Get(server.Serialize());
248 if ((spdy_server != spdy_servers_map_.end()) && 249 if ((spdy_server != spdy_servers_map_.end()) &&
249 (spdy_server->second == support_spdy)) { 250 (spdy_server->second == support_spdy)) {
250 return; 251 return;
251 } 252 }
252 // Cache the data. 253 // Cache the data.
253 spdy_servers_map_.Put(server.Serialize(), support_spdy); 254 spdy_servers_map_.Put(server.Serialize(), support_spdy);
254 } 255 }
255 256
256 bool HttpServerPropertiesImpl::RequiresHTTP11( 257 bool HttpServerPropertiesImpl::RequiresHTTP11(
257 const HostPortPair& host_port_pair) { 258 const HostPortPair& host_port_pair) {
258 DCHECK(CalledOnValidThread()); 259 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
259 if (host_port_pair.host().empty()) 260 if (host_port_pair.host().empty())
260 return false; 261 return false;
261 262
262 return (http11_servers_.find(host_port_pair) != http11_servers_.end()); 263 return (http11_servers_.find(host_port_pair) != http11_servers_.end());
263 } 264 }
264 265
265 void HttpServerPropertiesImpl::SetHTTP11Required( 266 void HttpServerPropertiesImpl::SetHTTP11Required(
266 const HostPortPair& host_port_pair) { 267 const HostPortPair& host_port_pair) {
267 DCHECK(CalledOnValidThread()); 268 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
268 if (host_port_pair.host().empty()) 269 if (host_port_pair.host().empty())
269 return; 270 return;
270 271
271 http11_servers_.insert(host_port_pair); 272 http11_servers_.insert(host_port_pair);
272 } 273 }
273 274
274 void HttpServerPropertiesImpl::MaybeForceHTTP11(const HostPortPair& server, 275 void HttpServerPropertiesImpl::MaybeForceHTTP11(const HostPortPair& server,
275 SSLConfig* ssl_config) { 276 SSLConfig* ssl_config) {
276 if (RequiresHTTP11(server)) { 277 if (RequiresHTTP11(server)) {
277 ForceHTTP11(ssl_config); 278 ForceHTTP11(ssl_config);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 if (map_it->second.empty()) { 692 if (map_it->second.empty()) {
692 RemoveCanonicalHost(map_it->first); 693 RemoveCanonicalHost(map_it->first);
693 map_it = alternative_service_map_.Erase(map_it); 694 map_it = alternative_service_map_.Erase(map_it);
694 continue; 695 continue;
695 } 696 }
696 ++map_it; 697 ++map_it;
697 } 698 }
698 } 699 }
699 700
700 } // namespace net 701 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.h ('k') | net/http/transport_security_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698