blob: 01315872fb804354971468fc8c72b17df51b8ea2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef QUICHE_QUIC_CORE_LEGACY_QUIC_STREAM_ID_MANAGER_H_
#define QUICHE_QUIC_CORE_LEGACY_QUIC_STREAM_ID_MANAGER_H_
#include "net/third_party/quiche/src/quic/core/quic_stream_id_manager.h"
#include "net/third_party/quiche/src/quic/core/quic_types.h"
#include "net/third_party/quiche/src/quic/core/quic_versions.h"
namespace quic {
namespace test {
class QuicSessionPeer;
} // namespace test
class QuicSession;
// Manages Google QUIC stream IDs. This manager is responsible for two
// questions: 1) can next outgoing stream ID be allocated (if yes, what is the
// next outgoing stream ID) and 2) can a new incoming stream be opened.
class QUIC_EXPORT_PRIVATE LegacyQuicStreamIdManager {
public:
LegacyQuicStreamIdManager(Perspective perspective,
QuicTransportVersion transport_version,
size_t max_open_outgoing_streams,
size_t max_open_incoming_streams);
~LegacyQuicStreamIdManager();
// Returns true if the next outgoing stream ID can be allocated.
bool CanOpenNextOutgoingStream() const;
// Returns true if a new incoming stream can be opened.
bool CanOpenIncomingStream() const;
// Returns false when increasing the largest created stream id to |id| would
// violate the limit, so the connection should be closed.
bool MaybeIncreaseLargestPeerStreamId(const QuicStreamId id);
// Returns true if |id| is still available.
bool IsAvailableStream(QuicStreamId id) const;
// Returns the stream ID for a new outgoing stream, and increments the
// underlying counter.
QuicStreamId GetNextOutgoingStreamId();
// Called when a new stream is open.
void ActivateStream(bool is_incoming);
// Called when a stream ID is closed.
void OnStreamClosed(bool is_incoming);
// Return true if |id| is peer initiated.
bool IsIncomingStream(QuicStreamId id) const;
size_t MaxAvailableStreams() const;
void set_max_open_incoming_streams(size_t max_open_incoming_streams) {
max_open_incoming_streams_ = max_open_incoming_streams;
}
void set_max_open_outgoing_streams(size_t max_open_outgoing_streams) {
max_open_outgoing_streams_ = max_open_outgoing_streams;
}
void set_largest_peer_created_stream_id(
QuicStreamId largest_peer_created_stream_id) {
largest_peer_created_stream_id_ = largest_peer_created_stream_id;
}
size_t max_open_incoming_streams() const {
return max_open_incoming_streams_;
}
size_t max_open_outgoing_streams() const {
return max_open_outgoing_streams_;
}
QuicStreamId next_outgoing_stream_id() const {
return next_outgoing_stream_id_;
}
QuicStreamId largest_peer_created_stream_id() const {
return largest_peer_created_stream_id_;
}
size_t GetNumAvailableStreams() const;
size_t num_open_incoming_streams() const {
return num_open_incoming_streams_;
}
size_t num_open_outgoing_streams() const {
return num_open_outgoing_streams_;
}
private:
friend class test::QuicSessionPeer;
const Perspective perspective_;
const QuicTransportVersion transport_version_;
// The maximum number of outgoing streams this connection can open.
size_t max_open_outgoing_streams_;
// The maximum number of incoming streams this connection will allow.
size_t max_open_incoming_streams_;
// The ID to use for the next outgoing stream.
QuicStreamId next_outgoing_stream_id_;
// Set of stream ids that are less than the largest stream id that has been
// received, but are nonetheless available to be created.
QuicHashSet<QuicStreamId> available_streams_;
QuicStreamId largest_peer_created_stream_id_;
// A counter for peer initiated open streams.
size_t num_open_incoming_streams_;
// A counter for self initiated open streams.
size_t num_open_outgoing_streams_;
};
} // namespace quic
#endif // QUICHE_QUIC_CORE_LEGACY_QUIC_STREAM_ID_MANAGER_H_
|