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

Unified Diff: net/quic/core/quic_session.cc

Issue 2862563003: Landing Recent QUIC changes until Sat Apr 29 00:22:04 2017 +0000 (Closed)
Patch Set: rebase and fix test bugs detected by swarm bot. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_session.h ('k') | net/quic/core/quic_session_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « net/quic/core/quic_session.h ('k') | net/quic/core/quic_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698