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

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

Issue 2496953002: Revert of Unify enum NextProto and enum AlternateProtocol. (Closed)
Patch Set: Created 4 years, 1 month 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.cc ('k') | net/http/http_server_properties_impl_unittest.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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 DCHECK(CalledOnValidThread()); 239 DCHECK(CalledOnValidThread());
240 if (server.host().empty()) 240 if (server.host().empty())
241 return false; 241 return false;
242 242
243 if (GetSupportsSpdy(server)) 243 if (GetSupportsSpdy(server))
244 return true; 244 return true;
245 const AlternativeServiceVector alternative_service_vector = 245 const AlternativeServiceVector alternative_service_vector =
246 GetAlternativeServices(server); 246 GetAlternativeServices(server);
247 for (const AlternativeService& alternative_service : 247 for (const AlternativeService& alternative_service :
248 alternative_service_vector) { 248 alternative_service_vector) {
249 if (alternative_service.protocol == kProtoQUIC) { 249 if (alternative_service.protocol == QUIC) {
250 return true; 250 return true;
251 } 251 }
252 } 252 }
253 return false; 253 return false;
254 } 254 }
255 255
256 bool HttpServerPropertiesImpl::GetSupportsSpdy( 256 bool HttpServerPropertiesImpl::GetSupportsSpdy(
257 const url::SchemeHostPort& server) { 257 const url::SchemeHostPort& server) {
258 DCHECK(CalledOnValidThread()); 258 DCHECK(CalledOnValidThread());
259 if (server.host().empty()) 259 if (server.host().empty())
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 it = map_it->second.erase(it); 333 it = map_it->second.erase(it);
334 continue; 334 continue;
335 } 335 }
336 AlternativeService alternative_service(it->alternative_service); 336 AlternativeService alternative_service(it->alternative_service);
337 if (alternative_service.host.empty()) { 337 if (alternative_service.host.empty()) {
338 alternative_service.host = origin.host(); 338 alternative_service.host = origin.host();
339 } 339 }
340 // If the alternative service is equivalent to the origin (same host, same 340 // If the alternative service is equivalent to the origin (same host, same
341 // port, and both TCP), skip it. 341 // port, and both TCP), skip it.
342 if (host_port_pair.Equals(alternative_service.host_port_pair()) && 342 if (host_port_pair.Equals(alternative_service.host_port_pair()) &&
343 alternative_service.protocol == kProtoHTTP2) { 343 alternative_service.protocol == NPN_HTTP_2) {
344 ++it; 344 ++it;
345 continue; 345 continue;
346 } 346 }
347 valid_alternative_services.push_back(alternative_service); 347 valid_alternative_services.push_back(alternative_service);
348 ++it; 348 ++it;
349 } 349 }
350 if (map_it->second.empty()) { 350 if (map_it->second.empty()) {
351 alternative_service_map_.Erase(map_it); 351 alternative_service_map_.Erase(map_it);
352 } 352 }
353 return valid_alternative_services; 353 return valid_alternative_services;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 canonical_host_to_origin_map_[canonical_server] = origin; 465 canonical_host_to_origin_map_[canonical_server] = origin;
466 } 466 }
467 } 467 }
468 return changed; 468 return changed;
469 } 469 }
470 470
471 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken( 471 void HttpServerPropertiesImpl::MarkAlternativeServiceBroken(
472 const AlternativeService& alternative_service) { 472 const AlternativeService& alternative_service) {
473 // Empty host means use host of origin, callers are supposed to substitute. 473 // Empty host means use host of origin, callers are supposed to substitute.
474 DCHECK(!alternative_service.host.empty()); 474 DCHECK(!alternative_service.host.empty());
475 if (alternative_service.protocol == kProtoUnknown) { 475 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) {
476 LOG(DFATAL) << "Trying to mark unknown alternate protocol broken."; 476 LOG(DFATAL) << "Trying to mark unknown alternate protocol broken.";
477 return; 477 return;
478 } 478 }
479 ++recently_broken_alternative_services_[alternative_service]; 479 ++recently_broken_alternative_services_[alternative_service];
480 int shift = recently_broken_alternative_services_[alternative_service] - 1; 480 int shift = recently_broken_alternative_services_[alternative_service] - 1;
481 if (shift > kBrokenDelayMaxShift) 481 if (shift > kBrokenDelayMaxShift)
482 shift = kBrokenDelayMaxShift; 482 shift = kBrokenDelayMaxShift;
483 base::TimeDelta delay = 483 base::TimeDelta delay =
484 base::TimeDelta::FromSeconds(kBrokenAlternativeProtocolDelaySecs); 484 base::TimeDelta::FromSeconds(kBrokenAlternativeProtocolDelaySecs);
485 base::TimeTicks when = base::TimeTicks::Now() + delay * (1 << shift); 485 base::TimeTicks when = base::TimeTicks::Now() + delay * (1 << shift);
(...skipping 20 matching lines...) Expand all
506 506
507 bool HttpServerPropertiesImpl::IsAlternativeServiceBroken( 507 bool HttpServerPropertiesImpl::IsAlternativeServiceBroken(
508 const AlternativeService& alternative_service) const { 508 const AlternativeService& alternative_service) const {
509 // Empty host means use host of origin, callers are supposed to substitute. 509 // Empty host means use host of origin, callers are supposed to substitute.
510 DCHECK(!alternative_service.host.empty()); 510 DCHECK(!alternative_service.host.empty());
511 return base::ContainsKey(broken_alternative_services_, alternative_service); 511 return base::ContainsKey(broken_alternative_services_, alternative_service);
512 } 512 }
513 513
514 bool HttpServerPropertiesImpl::WasAlternativeServiceRecentlyBroken( 514 bool HttpServerPropertiesImpl::WasAlternativeServiceRecentlyBroken(
515 const AlternativeService& alternative_service) { 515 const AlternativeService& alternative_service) {
516 if (alternative_service.protocol == kProtoUnknown) 516 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
517 return false; 517 return false;
518 return base::ContainsKey(recently_broken_alternative_services_, 518 return base::ContainsKey(recently_broken_alternative_services_,
519 alternative_service); 519 alternative_service);
520 } 520 }
521 521
522 void HttpServerPropertiesImpl::ConfirmAlternativeService( 522 void HttpServerPropertiesImpl::ConfirmAlternativeService(
523 const AlternativeService& alternative_service) { 523 const AlternativeService& alternative_service) {
524 if (alternative_service.protocol == kProtoUnknown) 524 if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
525 return; 525 return;
526 broken_alternative_services_.erase(alternative_service); 526 broken_alternative_services_.erase(alternative_service);
527 recently_broken_alternative_services_.erase(alternative_service); 527 recently_broken_alternative_services_.erase(alternative_service);
528 } 528 }
529 529
530 const AlternativeServiceMap& HttpServerPropertiesImpl::alternative_service_map() 530 const AlternativeServiceMap& HttpServerPropertiesImpl::alternative_service_map()
531 const { 531 const {
532 return alternative_service_map_; 532 return alternative_service_map_;
533 } 533 }
534 534
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 806 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
807 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 807 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
808 FROM_HERE, 808 FROM_HERE,
809 base::Bind( 809 base::Bind(
810 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 810 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
811 weak_ptr_factory_.GetWeakPtr()), 811 weak_ptr_factory_.GetWeakPtr()),
812 delay); 812 delay);
813 } 813 }
814 814
815 } // namespace net 815 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties.cc ('k') | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698