| Index: net/quic/core/quic_session.cc
|
| diff --git a/net/quic/core/quic_session.cc b/net/quic/core/quic_session.cc
|
| index 9cda039a97ec7484052838b7ddbecdbcbf005c48..3afc985adf101ab9bbfab38163fd287a2c6921b8 100644
|
| --- a/net/quic/core/quic_session.cc
|
| +++ b/net/quic/core/quic_session.cc
|
| @@ -44,7 +44,8 @@ QuicSession::QuicSession(QuicConnection* connection,
|
| config_.GetInitialSessionFlowControlWindowToSend(),
|
| perspective() == Perspective::IS_SERVER,
|
| nullptr),
|
| - currently_writing_stream_id_(0) {}
|
| + currently_writing_stream_id_(0),
|
| + respect_goaway_(true) {}
|
|
|
| void QuicSession::Initialize() {
|
| connection_->set_visitor(this);
|
| @@ -720,6 +721,11 @@ QuicStream* QuicSession::GetOrCreateDynamicStream(
|
| if (!MaybeIncreaseLargestPeerStreamId(stream_id)) {
|
| return nullptr;
|
| }
|
| +
|
| + if (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation) {
|
| + return MaybeCreateIncomingDynamicStream(stream_id);
|
| + }
|
| +
|
| // Check if the new number of open streams would cause the number of
|
| // open streams to exceed the limit.
|
| if (GetNumOpenIncomingStreams() >= max_open_incoming_streams()) {
|
| @@ -866,4 +872,76 @@ bool QuicSession::IsIncomingStream(QuicStreamId id) const {
|
| return id % 2 != next_outgoing_stream_id_ % 2;
|
| }
|
|
|
| +bool QuicSession::ShouldCreateIncomingDynamicStream2(QuicStreamId id) {
|
| + DCHECK(FLAGS_quic_reloadable_flag_quic_refactor_stream_creation);
|
| + if (goaway_received() && respect_goaway_) {
|
| + QUIC_DLOG(INFO) << "Failed to create a new outgoing stream. "
|
| + << "Already received goaway.";
|
| + return false;
|
| + }
|
| + if (!IsIncomingStream(id)) {
|
| + QUIC_DLOG(INFO) << "invalid incoming stream id: " << id;
|
| + return false;
|
| + }
|
| + if (!connection()->connected()) {
|
| + QUIC_DLOG(INFO)
|
| + << "ShouldCreateIncomingDynamicStream called when disconnected";
|
| + return false;
|
| + }
|
| + if (GetNumOpenIncomingStreams() >= max_open_incoming_streams()) {
|
| + DVLOG(1) << "Reset stream (refused) " << id;
|
| + SendRstStream(id, QUIC_REFUSED_STREAM, 0);
|
| + return false;
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +bool QuicSession::ShouldCreateOutgoingDynamicStream2() {
|
| + DCHECK(FLAGS_quic_reloadable_flag_quic_refactor_stream_creation);
|
| + if (!connection()->connected()) {
|
| + QUIC_DLOG(INFO)
|
| + << "ShouldCreateOutgoingDynamicStream called when disconnected";
|
| + return false;
|
| + }
|
| + if (!IsEncryptionEstablished()) {
|
| + QUIC_DLOG(INFO) << "Encryption not established so no outgoing stream "
|
| + << "created.";
|
| + return false;
|
| + }
|
| + if (goaway_received() && respect_goaway_) {
|
| + QUIC_DLOG(INFO) << "Failed to create a new outgoing stream. "
|
| + << "Already received goaway.";
|
| + return false;
|
| + }
|
| + if (GetNumOpenOutgoingStreams() >= max_open_outgoing_streams()) {
|
| + QUIC_DLOG(INFO) << "Failed to create a new outgoing stream. "
|
| + << "Already " << GetNumOpenOutgoingStreams() << " open.";
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +QuicStream* QuicSession::MaybeCreateIncomingDynamicStream(QuicStreamId id) {
|
| + if (!ShouldCreateIncomingDynamicStream2(id)) {
|
| + return nullptr;
|
| + }
|
| + return CreateAndActivateStream(id);
|
| +}
|
| +
|
| +QuicStream* QuicSession::MaybeCreateOutgoingDynamicStream(
|
| + SpdyPriority priority) {
|
| + if (!ShouldCreateOutgoingDynamicStream2()) {
|
| + return nullptr;
|
| + }
|
| + return CreateAndActivateStream(GetNextOutgoingStreamId());
|
| +}
|
| +
|
| +QuicStream* QuicSession::CreateAndActivateStream(QuicStreamId id) {
|
| + std::unique_ptr<QuicStream> stream = CreateStream(id);
|
| + QuicStream* stream_ptr = stream.get();
|
| + ActivateStream(std::move(stream));
|
| + return stream_ptr;
|
| +}
|
| +
|
| } // namespace net
|
|
|