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

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

Issue 2901093004: Add and persist a new field in AlternativeServiceInfo to list QUIC verisons advertised (Closed)
Patch Set: fix compile in components 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
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (alternative_service.host.empty()) { 312 if (alternative_service.host.empty()) {
313 alternative_service.host = origin.host(); 313 alternative_service.host = origin.host();
314 } 314 }
315 // If the alternative service is equivalent to the origin (same host, same 315 // If the alternative service is equivalent to the origin (same host, same
316 // port, and both TCP), skip it. 316 // port, and both TCP), skip it.
317 if (host_port_pair.Equals(alternative_service.host_port_pair()) && 317 if (host_port_pair.Equals(alternative_service.host_port_pair()) &&
318 alternative_service.protocol == kProtoHTTP2) { 318 alternative_service.protocol == kProtoHTTP2) {
319 ++it; 319 ++it;
320 continue; 320 continue;
321 } 321 }
322 valid_alternative_service_infos.push_back( 322 valid_alternative_service_infos.push_back(AlternativeServiceInfo(
323 AlternativeServiceInfo(alternative_service, it->expiration)); 323 alternative_service, it->expiration, it->advertised_versions()));
324 ++it; 324 ++it;
325 } 325 }
326 if (map_it->second.empty()) { 326 if (map_it->second.empty()) {
327 alternative_service_map_.Erase(map_it); 327 alternative_service_map_.Erase(map_it);
328 } 328 }
329 return valid_alternative_service_infos; 329 return valid_alternative_service_infos;
330 } 330 }
331 331
332 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin); 332 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin);
333 if (canonical == canonical_host_to_origin_map_.end()) { 333 if (canonical == canonical_host_to_origin_map_.end()) {
(...skipping 14 matching lines...) Expand all
348 alternative_service.host = canonical->second.host(); 348 alternative_service.host = canonical->second.host();
349 if (IsAlternativeServiceBroken(alternative_service)) { 349 if (IsAlternativeServiceBroken(alternative_service)) {
350 ++it; 350 ++it;
351 continue; 351 continue;
352 } 352 }
353 alternative_service.host = origin.host(); 353 alternative_service.host = origin.host();
354 } else if (IsAlternativeServiceBroken(alternative_service)) { 354 } else if (IsAlternativeServiceBroken(alternative_service)) {
355 ++it; 355 ++it;
356 continue; 356 continue;
357 } 357 }
358 valid_alternative_service_infos.push_back( 358 valid_alternative_service_infos.push_back(AlternativeServiceInfo(
359 AlternativeServiceInfo(alternative_service, it->expiration)); 359 alternative_service, it->expiration, it->advertised_versions()));
360 ++it; 360 ++it;
361 } 361 }
362 if (map_it->second.empty()) { 362 if (map_it->second.empty()) {
363 alternative_service_map_.Erase(map_it); 363 alternative_service_map_.Erase(map_it);
364 } 364 }
365 return valid_alternative_service_infos; 365 return valid_alternative_service_infos;
366 } 366 }
367 367
368 bool HttpServerPropertiesImpl::SetAlternativeService( 368 bool HttpServerPropertiesImpl::SetAlternativeService(
369 const url::SchemeHostPort& origin, 369 const url::SchemeHostPort& origin,
370 const AlternativeService& alternative_service, 370 const AlternativeService& alternative_service,
371 base::Time expiration) { 371 base::Time expiration,
372 const QuicVersionVector& advertised_versions) {
372 return SetAlternativeServices( 373 return SetAlternativeServices(
373 origin, 374 origin,
374 AlternativeServiceInfoVector( 375 AlternativeServiceInfoVector(
375 /*size=*/1, AlternativeServiceInfo(alternative_service, expiration))); 376 /*size=*/1, AlternativeServiceInfo(alternative_service, expiration,
377 advertised_versions)));
376 } 378 }
377 379
378 bool HttpServerPropertiesImpl::SetAlternativeServices( 380 bool HttpServerPropertiesImpl::SetAlternativeServices(
379 const url::SchemeHostPort& origin, 381 const url::SchemeHostPort& origin,
380 const AlternativeServiceInfoVector& alternative_service_info_vector) { 382 const AlternativeServiceInfoVector& alternative_service_info_vector) {
381 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); 383 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin);
382 384
383 if (alternative_service_info_vector.empty()) { 385 if (alternative_service_info_vector.empty()) {
384 RemoveCanonicalHost(origin); 386 RemoveCanonicalHost(origin);
385 if (it == alternative_service_map_.end()) 387 if (it == alternative_service_map_.end())
(...skipping 19 matching lines...) Expand all
405 } 407 }
406 // Also persist to disk if new expiration it more that twice as far or 408 // Also persist to disk if new expiration it more that twice as far or
407 // less than half as far in the future. 409 // less than half as far in the future.
408 base::Time old_time = old.expiration; 410 base::Time old_time = old.expiration;
409 base::Time new_time = new_it->expiration; 411 base::Time new_time = new_it->expiration;
410 if (new_time - now > 2 * (old_time - now) || 412 if (new_time - now > 2 * (old_time - now) ||
411 2 * (new_time - now) < (old_time - now)) { 413 2 * (new_time - now) < (old_time - now)) {
412 changed = true; 414 changed = true;
413 break; 415 break;
414 } 416 }
417 // Also persist to disk if advertised versions change significantly for
Ryan Hamilton 2017/06/07 20:52:23 What does "significantly" mean here?
Zhongyi Shi 2017/06/08 23:11:16 Ah, advertised_versions used to be not sorted, and
418 // QUIC.
419 if (!old.EqualAdvertisedVersions(*new_it)) {
Ryan Hamilton 2017/06/07 20:52:23 can you just do old.advertised_services == new_it-
Zhongyi Shi 2017/06/08 23:11:16 Done.
420 changed = true;
421 break;
422 }
415 ++new_it; 423 ++new_it;
416 } 424 }
417 } 425 }
418 } 426 }
419 427
420 const bool previously_no_alternative_services = 428 const bool previously_no_alternative_services =
421 (GetAlternateProtocolIterator(origin) == alternative_service_map_.end()); 429 (GetAlternateProtocolIterator(origin) == alternative_service_map_.end());
422 430
423 alternative_service_map_.Put(origin, alternative_service_info_vector); 431 alternative_service_map_.Put(origin, alternative_service_info_vector);
424 432
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 if (map_it->second.empty()) { 700 if (map_it->second.empty()) {
693 RemoveCanonicalHost(map_it->first); 701 RemoveCanonicalHost(map_it->first);
694 map_it = alternative_service_map_.Erase(map_it); 702 map_it = alternative_service_map_.Erase(map_it);
695 continue; 703 continue;
696 } 704 }
697 ++map_it; 705 ++map_it;
698 } 706 }
699 } 707 }
700 708
701 } // namespace net 709 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698