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

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 Canonical test Created 3 years, 5 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if (alternative_service.host.empty()) { 280 if (alternative_service.host.empty()) {
281 alternative_service.host = origin.host(); 281 alternative_service.host = origin.host();
282 } 282 }
283 // If the alternative service is equivalent to the origin (same host, same 283 // If the alternative service is equivalent to the origin (same host, same
284 // port, and both TCP), skip it. 284 // port, and both TCP), skip it.
285 if (host_port_pair.Equals(alternative_service.host_port_pair()) && 285 if (host_port_pair.Equals(alternative_service.host_port_pair()) &&
286 alternative_service.protocol == kProtoHTTP2) { 286 alternative_service.protocol == kProtoHTTP2) {
287 ++it; 287 ++it;
288 continue; 288 continue;
289 } 289 }
290 valid_alternative_service_infos.push_back( 290 if (alternative_service.protocol == kProtoQUIC) {
291 AlternativeServiceInfo(alternative_service, it->expiration())); 291 valid_alternative_service_infos.push_back(
292 AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
293 alternative_service, it->expiration(),
294 it->advertised_versions()));
295 } else {
296 valid_alternative_service_infos.push_back(
297 AlternativeServiceInfo::CreateHttp2AlternativeServiceInfo(
298 alternative_service, it->expiration()));
299 }
292 ++it; 300 ++it;
293 } 301 }
294 if (map_it->second.empty()) { 302 if (map_it->second.empty()) {
295 alternative_service_map_.Erase(map_it); 303 alternative_service_map_.Erase(map_it);
296 } 304 }
297 return valid_alternative_service_infos; 305 return valid_alternative_service_infos;
298 } 306 }
299 307
300 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin); 308 CanonicalHostMap::const_iterator canonical = GetCanonicalHost(origin);
301 if (canonical == canonical_host_to_origin_map_.end()) { 309 if (canonical == canonical_host_to_origin_map_.end()) {
(...skipping 14 matching lines...) Expand all
316 alternative_service.host = canonical->second.host(); 324 alternative_service.host = canonical->second.host();
317 if (IsAlternativeServiceBroken(alternative_service)) { 325 if (IsAlternativeServiceBroken(alternative_service)) {
318 ++it; 326 ++it;
319 continue; 327 continue;
320 } 328 }
321 alternative_service.host = origin.host(); 329 alternative_service.host = origin.host();
322 } else if (IsAlternativeServiceBroken(alternative_service)) { 330 } else if (IsAlternativeServiceBroken(alternative_service)) {
323 ++it; 331 ++it;
324 continue; 332 continue;
325 } 333 }
326 valid_alternative_service_infos.push_back( 334 if (alternative_service.protocol == kProtoQUIC) {
327 AlternativeServiceInfo(alternative_service, it->expiration())); 335 valid_alternative_service_infos.push_back(
336 AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
337 alternative_service, it->expiration(),
338 it->advertised_versions()));
339 } else {
340 valid_alternative_service_infos.push_back(
341 AlternativeServiceInfo::CreateHttp2AlternativeServiceInfo(
342 alternative_service, it->expiration()));
343 }
328 ++it; 344 ++it;
329 } 345 }
330 if (map_it->second.empty()) { 346 if (map_it->second.empty()) {
331 alternative_service_map_.Erase(map_it); 347 alternative_service_map_.Erase(map_it);
332 } 348 }
333 return valid_alternative_service_infos; 349 return valid_alternative_service_infos;
334 } 350 }
335 351
336 bool HttpServerPropertiesImpl::SetAlternativeService( 352 bool HttpServerPropertiesImpl::SetHttp2AlternativeService(
337 const url::SchemeHostPort& origin, 353 const url::SchemeHostPort& origin,
338 const AlternativeService& alternative_service, 354 const AlternativeService& alternative_service,
339 base::Time expiration) { 355 base::Time expiration) {
356 DCHECK_EQ(alternative_service.protocol, kProtoHTTP2);
357
340 return SetAlternativeServices( 358 return SetAlternativeServices(
341 origin, 359 origin,
342 AlternativeServiceInfoVector( 360 AlternativeServiceInfoVector(
343 /*size=*/1, AlternativeServiceInfo(alternative_service, expiration))); 361 /*size=*/1, AlternativeServiceInfo::CreateHttp2AlternativeServiceInfo(
362 alternative_service, expiration)));
363 }
364
365 bool HttpServerPropertiesImpl::SetQuicAlternativeService(
366 const url::SchemeHostPort& origin,
367 const AlternativeService& alternative_service,
368 base::Time expiration,
369 const QuicVersionVector& advertised_versions) {
370 DCHECK(alternative_service.protocol == kProtoQUIC);
371
372 return SetAlternativeServices(
373 origin, AlternativeServiceInfoVector(
374 /*size=*/1,
375 AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
376 alternative_service, expiration, advertised_versions)));
344 } 377 }
345 378
346 bool HttpServerPropertiesImpl::SetAlternativeServices( 379 bool HttpServerPropertiesImpl::SetAlternativeServices(
347 const url::SchemeHostPort& origin, 380 const url::SchemeHostPort& origin,
348 const AlternativeServiceInfoVector& alternative_service_info_vector) { 381 const AlternativeServiceInfoVector& alternative_service_info_vector) {
349 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin); 382 AlternativeServiceMap::iterator it = alternative_service_map_.Peek(origin);
350 383
351 if (alternative_service_info_vector.empty()) { 384 if (alternative_service_info_vector.empty()) {
352 RemoveCanonicalHost(origin); 385 RemoveCanonicalHost(origin);
353 if (it == alternative_service_map_.end()) 386 if (it == alternative_service_map_.end())
(...skipping 19 matching lines...) Expand all
373 } 406 }
374 // Also persist to disk if new expiration it more that twice as far or 407 // Also persist to disk if new expiration it more that twice as far or
375 // less than half as far in the future. 408 // less than half as far in the future.
376 base::Time old_time = old.expiration(); 409 base::Time old_time = old.expiration();
377 base::Time new_time = new_it->expiration(); 410 base::Time new_time = new_it->expiration();
378 if (new_time - now > 2 * (old_time - now) || 411 if (new_time - now > 2 * (old_time - now) ||
379 2 * (new_time - now) < (old_time - now)) { 412 2 * (new_time - now) < (old_time - now)) {
380 changed = true; 413 changed = true;
381 break; 414 break;
382 } 415 }
416 // Also persist to disk if new entry has a different list of advertised
417 // versions.
418 if (old.advertised_versions() != new_it->advertised_versions()) {
419 changed = true;
420 break;
421 }
383 ++new_it; 422 ++new_it;
384 } 423 }
385 } 424 }
386 } 425 }
387 426
388 const bool previously_no_alternative_services = 427 const bool previously_no_alternative_services =
389 (GetAlternateProtocolIterator(origin) == alternative_service_map_.end()); 428 (GetAlternateProtocolIterator(origin) == alternative_service_map_.end());
390 429
391 alternative_service_map_.Put(origin, alternative_service_info_vector); 430 alternative_service_map_.Put(origin, alternative_service_info_vector);
392 431
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 if (map_it->second.empty()) { 699 if (map_it->second.empty()) {
661 RemoveCanonicalHost(map_it->first); 700 RemoveCanonicalHost(map_it->first);
662 map_it = alternative_service_map_.Erase(map_it); 701 map_it = alternative_service_map_.Erase(map_it);
663 continue; 702 continue;
664 } 703 }
665 ++map_it; 704 ++map_it;
666 } 705 }
667 } 706 }
668 707
669 } // namespace net 708 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.h ('k') | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698