src/net/http/http_server_properties_manager.cc
// Utility method to return only those AlternativeServiceInfos that should be
// persisted to disk. In particular, removes expired and invalid alternative
// services. Also checks if an alternative service for the same canonical suffix
// has already been saved, and if so, returns an empty list.
Utility method to return only those AlternativeServiceInfos that should be
persisted to disk. In particular, removes expired and invalid alternative
services. Also checks if an alternative service for the same canonical suffix
has already been saved, and if so, returns an empty list.
Utility method to return only those AlternativeServiceInfos that should be persisted to disk . In particular removes expired and invalid alternative services . Also checks if an alternative service for the same canonical suffix has already been saved and if so returns an empty list .
AlternativeServiceInfoVector GetAlternativeServiceToPersist(
    const base::Optional<AlternativeServiceInfoVector>& alternative_services,
    const HttpServerProperties::ServerInfoMapKey& server_info_key,
    base::Time now,
    const HttpServerPropertiesManager::GetCannonicalSuffix&
        get_canonical_suffix,
    std::set<std::pair<std::string, NetworkIsolationKey>>*
        persisted_canonical_suffix_set) {
  if (!alternative_services)
    return AlternativeServiceInfoVector();
  AlternativeServiceInfoVector notbroken_alternative_service_info_vector;
  for (const auto& alternative_service_info : alternative_services.value()) {
    if (alternative_service_info.expiration() < now ||
        !IsAlternateProtocolValid(
            alternative_service_info.alternative_service().protocol)) {
      continue;
    }
    notbroken_alternative_service_info_vector.push_back(
        alternative_service_info);
  }
  if (notbroken_alternative_service_info_vector.empty())
    return notbroken_alternative_service_info_vector;
  const std::string* canonical_suffix =
      get_canonical_suffix.Run(server_info_key.server.host());
  if (canonical_suffix) {
    std::pair<std::string, NetworkIsolationKey> index(
        *canonical_suffix, server_info_key.network_isolation_key);
    if (persisted_canonical_suffix_set->find(index) !=
        persisted_canonical_suffix_set->end()) {
      return AlternativeServiceInfoVector();
    }
    persisted_canonical_suffix_set->emplace(std::move(index));
  }
  return notbroken_alternative_service_info_vector;
}
AlternativeServiceInfoVector GetAlternativeServiceToPersist ( const base :: Optional < AlternativeServiceInfoVector > & alternative_services , const HttpServerProperties :: ServerInfoMapKey & server_info_key , base :: Time now , const HttpServerPropertiesManager :: GetCannonicalSuffix & get_canonical_suffix , std :: set < std :: pair < std :: string , NetworkIsolationKey > > * persisted_canonical_suffix_set ) { if ( ! alternative_services ) return AlternativeServiceInfoVector ( ) ; AlternativeServiceInfoVector notbroken_alternative_service_info_vector ; for ( const auto & alternative_service_info : alternative_services . value ( ) ) { if ( alternative_service_info . expiration ( ) < now || ! IsAlternateProtocolValid ( alternative_service_info . alternative_service ( ) . protocol ) ) { continue ; } notbroken_alternative_service_info_vector . push_back ( alternative_service_info ) ; } if ( notbroken_alternative_service_info_vector . empty ( ) ) return notbroken_alternative_service_info_vector ; const std :: string * canonical_suffix = get_canonical_suffix . Run ( server_info_key . server . host ( ) ) ; if ( canonical_suffix ) { std :: pair < std :: string , NetworkIsolationKey > index ( * canonical_suffix , server_info_key . network_isolation_key ) ; if ( persisted_canonical_suffix_set -> find ( index ) != persisted_canonical_suffix_set -> end ( ) ) { return AlternativeServiceInfoVector ( ) ; } persisted_canonical_suffix_set -> emplace ( std :: move ( index ) ) ; } return notbroken_alternative_service_info_vector ; }
Utility method to return only those AlternativeServiceInfos that should be
persisted to disk.
Utility method to return only those AlternativeServiceInfos that should be persisted to disk .
// Separate out valid, non-expired AlternativeServiceInfo entries. // Don't save if have already saved information associated with the same // canonical suffix.