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

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

Issue 2229393003: net: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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_network_session.cc ('k') | net/http/http_stream_factory_impl.cc » ('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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 } 106 }
107 107
108 // Attempt to find canonical servers. Canonical suffix only apply to HTTPS. 108 // Attempt to find canonical servers. Canonical suffix only apply to HTTPS.
109 const uint16_t kCanonicalPort = 443; 109 const uint16_t kCanonicalPort = 443;
110 const char* kCanonicalScheme = "https"; 110 const char* kCanonicalScheme = "https";
111 for (const std::string& canonical_suffix : canonical_suffixes_) { 111 for (const std::string& canonical_suffix : canonical_suffixes_) {
112 url::SchemeHostPort canonical_server(kCanonicalScheme, canonical_suffix, 112 url::SchemeHostPort canonical_server(kCanonicalScheme, canonical_suffix,
113 kCanonicalPort); 113 kCanonicalPort);
114 // If we already have a valid canonical server, we're done. 114 // If we already have a valid canonical server, we're done.
115 if (ContainsKey(canonical_host_to_origin_map_, canonical_server) && 115 if (base::ContainsKey(canonical_host_to_origin_map_, canonical_server) &&
116 (alternative_service_map_.Peek( 116 (alternative_service_map_.Peek(
117 canonical_host_to_origin_map_[canonical_server]) != 117 canonical_host_to_origin_map_[canonical_server]) !=
118 alternative_service_map_.end())) { 118 alternative_service_map_.end())) {
119 continue; 119 continue;
120 } 120 }
121 // Now attempt to find a server which matches this origin and set it as 121 // Now attempt to find a server which matches this origin and set it as
122 // canonical. 122 // canonical.
123 for (AlternativeServiceMap::const_iterator it = 123 for (AlternativeServiceMap::const_iterator it =
124 alternative_service_map_.begin(); 124 alternative_service_map_.begin();
125 it != alternative_service_map_.end(); ++it) { 125 it != alternative_service_map_.end(); ++it) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 // If this is the only entry in the list, schedule an expiration task. 486 // If this is the only entry in the list, schedule an expiration task.
487 // Otherwise it will be rescheduled automatically when the pending task runs. 487 // Otherwise it will be rescheduled automatically when the pending task runs.
488 if (broken_alternative_services_.size() == 1) { 488 if (broken_alternative_services_.size() == 1) {
489 ScheduleBrokenAlternateProtocolMappingsExpiration(); 489 ScheduleBrokenAlternateProtocolMappingsExpiration();
490 } 490 }
491 } 491 }
492 492
493 void HttpServerPropertiesImpl::MarkAlternativeServiceRecentlyBroken( 493 void HttpServerPropertiesImpl::MarkAlternativeServiceRecentlyBroken(
494 const AlternativeService& alternative_service) { 494 const AlternativeService& alternative_service) {
495 if (!ContainsKey(recently_broken_alternative_services_, alternative_service)) 495 if (!base::ContainsKey(recently_broken_alternative_services_,
496 alternative_service))
496 recently_broken_alternative_services_[alternative_service] = 1; 497 recently_broken_alternative_services_[alternative_service] = 1;
497 } 498 }
498 499
499 bool HttpServerPropertiesImpl::IsAlternativeServiceBroken( 500 bool HttpServerPropertiesImpl::IsAlternativeServiceBroken(
500 const AlternativeService& alternative_service) const { 501 const AlternativeService& alternative_service) const {
501 // Empty host means use host of origin, callers are supposed to substitute. 502 // Empty host means use host of origin, callers are supposed to substitute.
502 DCHECK(!alternative_service.host.empty()); 503 DCHECK(!alternative_service.host.empty());
503 return ContainsKey(broken_alternative_services_, alternative_service); 504 return base::ContainsKey(broken_alternative_services_, alternative_service);
504 } 505 }
505 506
506 bool HttpServerPropertiesImpl::WasAlternativeServiceRecentlyBroken( 507 bool HttpServerPropertiesImpl::WasAlternativeServiceRecentlyBroken(
507 const AlternativeService& alternative_service) { 508 const AlternativeService& alternative_service) {
508 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) 509 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
509 return false; 510 return false;
510 return ContainsKey(recently_broken_alternative_services_, 511 return base::ContainsKey(recently_broken_alternative_services_,
511 alternative_service); 512 alternative_service);
512 } 513 }
513 514
514 void HttpServerPropertiesImpl::ConfirmAlternativeService( 515 void HttpServerPropertiesImpl::ConfirmAlternativeService(
515 const AlternativeService& alternative_service) { 516 const AlternativeService& alternative_service) {
516 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) 517 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
517 return; 518 return;
518 broken_alternative_services_.erase(alternative_service); 519 broken_alternative_services_.erase(alternative_service);
519 recently_broken_alternative_services_.erase(alternative_service); 520 recently_broken_alternative_services_.erase(alternative_service);
520 } 521 }
521 522
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 799 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
799 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 800 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
800 FROM_HERE, 801 FROM_HERE,
801 base::Bind( 802 base::Bind(
802 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 803 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
803 weak_ptr_factory_.GetWeakPtr()), 804 weak_ptr_factory_.GetWeakPtr()),
804 delay); 805 delay);
805 } 806 }
806 807
807 } // namespace net 808 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698