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

Unified Diff: net/quic/quic_session.cc

Issue 1422533006: Merge GetIncomingDynamicStream and GetDynamicStream into a single GetOrCreateDynamicStream method i… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@106419223
Patch Set: Created 5 years, 1 month 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/quic_session.h ('k') | net/quic/quic_session_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_session.cc
diff --git a/net/quic/quic_session.cc b/net/quic/quic_session.cc
index 39259240ac54823e75acd2088d91a114415067f1..2a325d680a087dc95e36401f2292ee96cbbfb93f 100644
--- a/net/quic/quic_session.cc
+++ b/net/quic/quic_session.cc
@@ -157,7 +157,7 @@ void QuicSession::OnRstStream(const QuicRstStreamFrame& frame) {
return;
}
- ReliableQuicStream* stream = GetDynamicStream(frame.stream_id);
+ ReliableQuicStream* stream = GetOrCreateDynamicStream(frame.stream_id);
if (!stream) {
// The RST frame contains the final byte offset for the stream: we can now
// update the connection level flow controller if needed.
@@ -570,7 +570,7 @@ ReliableQuicStream* QuicSession::GetStream(const QuicStreamId stream_id) {
if (it != static_stream_map_.end()) {
return it->second;
}
- return GetDynamicStream(stream_id);
+ return GetOrCreateDynamicStream(stream_id);
}
void QuicSession::StreamDraining(QuicStreamId stream_id) {
@@ -586,10 +586,11 @@ void QuicSession::CloseConnection(QuicErrorCode error) {
}
}
-ReliableQuicStream* QuicSession::GetDynamicStream(
+ReliableQuicStream* QuicSession::GetOrCreateDynamicStream(
const QuicStreamId stream_id) {
- if (static_stream_map_.find(stream_id) != static_stream_map_.end()) {
- DLOG(FATAL) << "Attempt to call GetDynamicStream for a static stream";
+ if (ContainsKey(static_stream_map_, stream_id)) {
+ DLOG(FATAL)
+ << "Attempt to call GetOrCreateDynamicStream for a static stream";
return nullptr;
}
@@ -603,31 +604,14 @@ ReliableQuicStream* QuicSession::GetDynamicStream(
}
if (stream_id % 2 == next_outgoing_stream_id_ % 2) {
- // We've received a frame for a locally-created stream that is not
- // currently active. This is an error.
- CloseConnection(QUIC_PACKET_FOR_NONEXISTENT_STREAM);
+ // Received a frame for a locally-created stream that is not currently
+ // active. This is an error.
+ CloseConnection(QUIC_INVALID_STREAM_ID);
return nullptr;
}
- return GetIncomingDynamicStream(stream_id);
-}
-
-ReliableQuicStream* QuicSession::GetIncomingDynamicStream(
- QuicStreamId stream_id) {
- if (IsClosedStream(stream_id)) {
- return nullptr;
- }
available_streams_.erase(stream_id);
- // Legitimate streams created by the peer are alternately-numbered.
- if (FLAGS_allow_many_available_streams &&
- stream_id % 2 != largest_peer_created_stream_id_ % 2) {
- // Close the connection.
- DVLOG(1) << "Invalid incoming stream_id " << stream_id;
- connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID);
- return nullptr;
- }
-
if (stream_id > largest_peer_created_stream_id_) {
if (FLAGS_allow_many_available_streams) {
// Check if the new number of available streams would cause the number of
« no previous file with comments | « net/quic/quic_session.h ('k') | net/quic/quic_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698