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

Side by Side Diff: net/spdy/chromium/spdy_session.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
« no previous file with comments | « net/quic/chromium/quic_stream_factory_test.cc ('k') | no next file » | 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/spdy/chromium/spdy_session.h" 5 #include "net/spdy/chromium/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 DCHECK(!quic_supported_versions_.empty()); 3017 DCHECK(!quic_supported_versions_.empty());
3018 for (const SpdyAltSvcWireFormat::AlternativeService& altsvc : altsvc_vector) { 3018 for (const SpdyAltSvcWireFormat::AlternativeService& altsvc : altsvc_vector) {
3019 const NextProto protocol = NextProtoFromString(altsvc.protocol_id); 3019 const NextProto protocol = NextProtoFromString(altsvc.protocol_id);
3020 if (protocol == kProtoUnknown) 3020 if (protocol == kProtoUnknown)
3021 continue; 3021 continue;
3022 3022
3023 // TODO(zhongyi): refactor the QUIC version filtering to a single function 3023 // TODO(zhongyi): refactor the QUIC version filtering to a single function
3024 // so that SpdySession::OnAltSvc and 3024 // so that SpdySession::OnAltSvc and
3025 // HttpStreamFactory::ProcessAlternativeServices 3025 // HttpStreamFactory::ProcessAlternativeServices
3026 // could use the the same function. 3026 // could use the the same function.
3027 // Check if QUIC version is supported. 3027 // Check if QUIC version is supported. Filter supported QUIC versions.
3028 QuicVersionVector advertised_versions;
3028 if (protocol == kProtoQUIC && !altsvc.version.empty()) { 3029 if (protocol == kProtoQUIC && !altsvc.version.empty()) {
3029 bool match_found = false; 3030 bool match_found = false;
3030 for (const QuicVersion& supported : quic_supported_versions_) { 3031 for (const QuicVersion& supported : quic_supported_versions_) {
3031 for (const uint16_t& advertised : altsvc.version) { 3032 for (const uint16_t& advertised : altsvc.version) {
3032 if (supported == advertised) { 3033 if (supported == advertised) {
3033 match_found = true; 3034 match_found = true;
3034 break; 3035 advertised_versions.push_back(supported);
3035 } 3036 }
3036 } 3037 }
3037 if (match_found) {
3038 break;
3039 }
3040 } 3038 }
3041 if (!match_found) { 3039 if (!match_found) {
3042 continue; 3040 continue;
3043 } 3041 }
3044 } 3042 }
3045 3043
3046 const AlternativeService alternative_service(protocol, altsvc.host, 3044 const AlternativeService alternative_service(protocol, altsvc.host,
3047 altsvc.port); 3045 altsvc.port);
3048 const base::Time expiration = 3046 const base::Time expiration =
3049 now + base::TimeDelta::FromSeconds(altsvc.max_age); 3047 now + base::TimeDelta::FromSeconds(altsvc.max_age);
3050 alternative_service_info_vector.push_back( 3048 AlternativeServiceInfo alternative_service_info;
3051 AlternativeServiceInfo(alternative_service, expiration)); 3049 if (protocol == kProtoQUIC) {
3050 alternative_service_info =
3051 AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
3052 alternative_service, expiration, advertised_versions);
3053 } else {
3054 alternative_service_info =
3055 AlternativeServiceInfo::CreateHttp2AlternativeServiceInfo(
3056 alternative_service, expiration);
3057 }
3058 alternative_service_info_vector.push_back(alternative_service_info);
3052 } 3059 }
3060
3053 http_server_properties_->SetAlternativeServices( 3061 http_server_properties_->SetAlternativeServices(
3054 scheme_host_port, alternative_service_info_vector); 3062 scheme_host_port, alternative_service_info_vector);
3055 } 3063 }
3056 3064
3057 bool SpdySession::OnUnknownFrame(SpdyStreamId stream_id, uint8_t frame_type) { 3065 bool SpdySession::OnUnknownFrame(SpdyStreamId stream_id, uint8_t frame_type) {
3058 // Validate stream id. 3066 // Validate stream id.
3059 // Was the frame sent on a stream id that has not been used in this session? 3067 // Was the frame sent on a stream id that has not been used in this session?
3060 if (stream_id % 2 == 1 && stream_id > stream_hi_water_mark_) 3068 if (stream_id % 2 == 1 && stream_id > stream_hi_water_mark_)
3061 return false; 3069 return false;
3062 3070
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 if (!queue->empty()) { 3265 if (!queue->empty()) {
3258 SpdyStreamId stream_id = queue->front(); 3266 SpdyStreamId stream_id = queue->front();
3259 queue->pop_front(); 3267 queue->pop_front();
3260 return stream_id; 3268 return stream_id;
3261 } 3269 }
3262 } 3270 }
3263 return 0; 3271 return 0;
3264 } 3272 }
3265 3273
3266 } // namespace net 3274 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_stream_factory_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698