• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "quiche/quic/core/uber_quic_stream_id_manager.h"
6 
7 #include "quiche/quic/core/quic_session.h"
8 #include "quiche/quic/core/quic_utils.h"
9 
10 namespace quic {
11 
UberQuicStreamIdManager(Perspective perspective,ParsedQuicVersion version,QuicStreamIdManager::DelegateInterface * delegate,QuicStreamCount max_open_outgoing_bidirectional_streams,QuicStreamCount max_open_outgoing_unidirectional_streams,QuicStreamCount max_open_incoming_bidirectional_streams,QuicStreamCount max_open_incoming_unidirectional_streams)12 UberQuicStreamIdManager::UberQuicStreamIdManager(
13     Perspective perspective, ParsedQuicVersion version,
14     QuicStreamIdManager::DelegateInterface* delegate,
15     QuicStreamCount max_open_outgoing_bidirectional_streams,
16     QuicStreamCount max_open_outgoing_unidirectional_streams,
17     QuicStreamCount max_open_incoming_bidirectional_streams,
18     QuicStreamCount max_open_incoming_unidirectional_streams)
19     : version_(version),
20       bidirectional_stream_id_manager_(delegate,
21                                        /*unidirectional=*/false, perspective,
22                                        version,
23                                        max_open_outgoing_bidirectional_streams,
24                                        max_open_incoming_bidirectional_streams),
25       unidirectional_stream_id_manager_(
26           delegate,
27           /*unidirectional=*/true, perspective, version,
28           max_open_outgoing_unidirectional_streams,
29           max_open_incoming_unidirectional_streams) {}
30 
MaybeAllowNewOutgoingBidirectionalStreams(QuicStreamCount max_open_streams)31 bool UberQuicStreamIdManager::MaybeAllowNewOutgoingBidirectionalStreams(
32     QuicStreamCount max_open_streams) {
33   return bidirectional_stream_id_manager_.MaybeAllowNewOutgoingStreams(
34       max_open_streams);
35 }
MaybeAllowNewOutgoingUnidirectionalStreams(QuicStreamCount max_open_streams)36 bool UberQuicStreamIdManager::MaybeAllowNewOutgoingUnidirectionalStreams(
37     QuicStreamCount max_open_streams) {
38   return unidirectional_stream_id_manager_.MaybeAllowNewOutgoingStreams(
39       max_open_streams);
40 }
SetMaxOpenIncomingBidirectionalStreams(QuicStreamCount max_open_streams)41 void UberQuicStreamIdManager::SetMaxOpenIncomingBidirectionalStreams(
42     QuicStreamCount max_open_streams) {
43   bidirectional_stream_id_manager_.SetMaxOpenIncomingStreams(max_open_streams);
44 }
SetMaxOpenIncomingUnidirectionalStreams(QuicStreamCount max_open_streams)45 void UberQuicStreamIdManager::SetMaxOpenIncomingUnidirectionalStreams(
46     QuicStreamCount max_open_streams) {
47   unidirectional_stream_id_manager_.SetMaxOpenIncomingStreams(max_open_streams);
48 }
49 
CanOpenNextOutgoingBidirectionalStream() const50 bool UberQuicStreamIdManager::CanOpenNextOutgoingBidirectionalStream() const {
51   return bidirectional_stream_id_manager_.CanOpenNextOutgoingStream();
52 }
53 
CanOpenNextOutgoingUnidirectionalStream() const54 bool UberQuicStreamIdManager::CanOpenNextOutgoingUnidirectionalStream() const {
55   return unidirectional_stream_id_manager_.CanOpenNextOutgoingStream();
56 }
57 
GetNextOutgoingBidirectionalStreamId()58 QuicStreamId UberQuicStreamIdManager::GetNextOutgoingBidirectionalStreamId() {
59   return bidirectional_stream_id_manager_.GetNextOutgoingStreamId();
60 }
61 
GetNextOutgoingUnidirectionalStreamId()62 QuicStreamId UberQuicStreamIdManager::GetNextOutgoingUnidirectionalStreamId() {
63   return unidirectional_stream_id_manager_.GetNextOutgoingStreamId();
64 }
65 
MaybeIncreaseLargestPeerStreamId(QuicStreamId id,std::string * error_details)66 bool UberQuicStreamIdManager::MaybeIncreaseLargestPeerStreamId(
67     QuicStreamId id, std::string* error_details) {
68   if (QuicUtils::IsBidirectionalStreamId(id, version_)) {
69     return bidirectional_stream_id_manager_.MaybeIncreaseLargestPeerStreamId(
70         id, error_details);
71   }
72   return unidirectional_stream_id_manager_.MaybeIncreaseLargestPeerStreamId(
73       id, error_details);
74 }
75 
OnStreamClosed(QuicStreamId id)76 void UberQuicStreamIdManager::OnStreamClosed(QuicStreamId id) {
77   if (QuicUtils::IsBidirectionalStreamId(id, version_)) {
78     bidirectional_stream_id_manager_.OnStreamClosed(id);
79     return;
80   }
81   unidirectional_stream_id_manager_.OnStreamClosed(id);
82 }
83 
OnStreamsBlockedFrame(const QuicStreamsBlockedFrame & frame,std::string * error_details)84 bool UberQuicStreamIdManager::OnStreamsBlockedFrame(
85     const QuicStreamsBlockedFrame& frame, std::string* error_details) {
86   if (frame.unidirectional) {
87     return unidirectional_stream_id_manager_.OnStreamsBlockedFrame(
88         frame, error_details);
89   }
90   return bidirectional_stream_id_manager_.OnStreamsBlockedFrame(frame,
91                                                                 error_details);
92 }
93 
IsAvailableStream(QuicStreamId id) const94 bool UberQuicStreamIdManager::IsAvailableStream(QuicStreamId id) const {
95   if (QuicUtils::IsBidirectionalStreamId(id, version_)) {
96     return bidirectional_stream_id_manager_.IsAvailableStream(id);
97   }
98   return unidirectional_stream_id_manager_.IsAvailableStream(id);
99 }
100 
101 QuicStreamCount
GetMaxAllowdIncomingBidirectionalStreams() const102 UberQuicStreamIdManager::GetMaxAllowdIncomingBidirectionalStreams() const {
103   return bidirectional_stream_id_manager_.incoming_initial_max_open_streams();
104 }
105 
106 QuicStreamCount
GetMaxAllowdIncomingUnidirectionalStreams() const107 UberQuicStreamIdManager::GetMaxAllowdIncomingUnidirectionalStreams() const {
108   return unidirectional_stream_id_manager_.incoming_initial_max_open_streams();
109 }
110 
GetLargestPeerCreatedStreamId(bool unidirectional) const111 QuicStreamId UberQuicStreamIdManager::GetLargestPeerCreatedStreamId(
112     bool unidirectional) const {
113   if (unidirectional) {
114     return unidirectional_stream_id_manager_.largest_peer_created_stream_id();
115   }
116   return bidirectional_stream_id_manager_.largest_peer_created_stream_id();
117 }
118 
next_outgoing_bidirectional_stream_id() const119 QuicStreamId UberQuicStreamIdManager::next_outgoing_bidirectional_stream_id()
120     const {
121   return bidirectional_stream_id_manager_.next_outgoing_stream_id();
122 }
123 
next_outgoing_unidirectional_stream_id() const124 QuicStreamId UberQuicStreamIdManager::next_outgoing_unidirectional_stream_id()
125     const {
126   return unidirectional_stream_id_manager_.next_outgoing_stream_id();
127 }
128 
max_outgoing_bidirectional_streams() const129 QuicStreamCount UberQuicStreamIdManager::max_outgoing_bidirectional_streams()
130     const {
131   return bidirectional_stream_id_manager_.outgoing_max_streams();
132 }
133 
max_outgoing_unidirectional_streams() const134 QuicStreamCount UberQuicStreamIdManager::max_outgoing_unidirectional_streams()
135     const {
136   return unidirectional_stream_id_manager_.outgoing_max_streams();
137 }
138 
max_incoming_bidirectional_streams() const139 QuicStreamCount UberQuicStreamIdManager::max_incoming_bidirectional_streams()
140     const {
141   return bidirectional_stream_id_manager_.incoming_actual_max_streams();
142 }
143 
max_incoming_unidirectional_streams() const144 QuicStreamCount UberQuicStreamIdManager::max_incoming_unidirectional_streams()
145     const {
146   return unidirectional_stream_id_manager_.incoming_actual_max_streams();
147 }
148 
149 QuicStreamCount
advertised_max_incoming_bidirectional_streams() const150 UberQuicStreamIdManager::advertised_max_incoming_bidirectional_streams() const {
151   return bidirectional_stream_id_manager_.incoming_advertised_max_streams();
152 }
153 
154 QuicStreamCount
advertised_max_incoming_unidirectional_streams() const155 UberQuicStreamIdManager::advertised_max_incoming_unidirectional_streams()
156     const {
157   return unidirectional_stream_id_manager_.incoming_advertised_max_streams();
158 }
159 
outgoing_bidirectional_stream_count() const160 QuicStreamCount UberQuicStreamIdManager::outgoing_bidirectional_stream_count()
161     const {
162   return bidirectional_stream_id_manager_.outgoing_stream_count();
163 }
164 
outgoing_unidirectional_stream_count() const165 QuicStreamCount UberQuicStreamIdManager::outgoing_unidirectional_stream_count()
166     const {
167   return unidirectional_stream_id_manager_.outgoing_stream_count();
168 }
169 
170 }  // namespace quic
171