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

Unified Diff: net/quic/quic_session_test.cc

Issue 285193006: Don't set QUIC's write alarm if we are connection flow control blocked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: Created 6 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/quic_session.cc ('k') | net/quic/quic_write_blocked_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_session_test.cc
diff --git a/net/quic/quic_session_test.cc b/net/quic/quic_session_test.cc
index a8cbc723811bc69003b78f918156056bfefe4502..17f53f529c9122384954ebf93746cc01aa65860e 100644
--- a/net/quic/quic_session_test.cc
+++ b/net/quic/quic_session_test.cc
@@ -17,6 +17,7 @@
#include "net/quic/reliable_quic_stream.h"
#include "net/quic/test_tools/quic_connection_peer.h"
#include "net/quic/test_tools/quic_data_stream_peer.h"
+#include "net/quic/test_tools/quic_flow_controller_peer.h"
#include "net/quic/test_tools/quic_session_peer.h"
#include "net/quic/test_tools/quic_test_utils.h"
#include "net/quic/test_tools/reliable_quic_stream_peer.h"
@@ -66,6 +67,15 @@ class TestCryptoStream : public QuicCryptoStream {
MOCK_METHOD0(OnCanWrite, void());
};
+class TestHeadersStream : public QuicHeadersStream {
+ public:
+ explicit TestHeadersStream(QuicSession* session)
+ : QuicHeadersStream(session) {
+ }
+
+ MOCK_METHOD0(OnCanWrite, void());
+};
+
class TestStream : public QuicDataStream {
public:
TestStream(QuicStreamId id, QuicSession* session)
@@ -157,7 +167,7 @@ class TestSession : public QuicSession {
}
private:
- TestCryptoStream crypto_stream_;
+ StrictMock<TestCryptoStream> crypto_stream_;
bool writev_consumes_all_data_;
};
@@ -350,7 +360,7 @@ TEST_P(QuicSessionTest, OnCanWrite) {
EXPECT_CALL(*stream6, OnCanWrite());
EXPECT_CALL(*stream4, OnCanWrite());
session_.OnCanWrite();
- EXPECT_TRUE(session_.HasPendingWrites());
+ EXPECT_TRUE(session_.WillingAndAbleToWrite());
}
TEST_P(QuicSessionTest, OnCanWriteBundlesStreams) {
@@ -384,7 +394,7 @@ TEST_P(QuicSessionTest, OnCanWriteBundlesStreams) {
Return(WriteResult(WRITE_STATUS_OK, 0)));
EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _));
session_.OnCanWrite();
- EXPECT_FALSE(session_.HasPendingWrites());
+ EXPECT_FALSE(session_.WillingAndAbleToWrite());
}
TEST_P(QuicSessionTest, OnCanWriteCongestionControlBlocks) {
@@ -414,13 +424,13 @@ TEST_P(QuicSessionTest, OnCanWriteCongestionControlBlocks) {
// stream4->OnCanWrite is not called.
session_.OnCanWrite();
- EXPECT_TRUE(session_.HasPendingWrites());
+ EXPECT_TRUE(session_.WillingAndAbleToWrite());
// Still congestion-control blocked.
EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)).WillOnce(Return(
QuicTime::Delta::Infinite()));
session_.OnCanWrite();
- EXPECT_TRUE(session_.HasPendingWrites());
+ EXPECT_TRUE(session_.WillingAndAbleToWrite());
// stream4->OnCanWrite is called once the connection stops being
// congestion-control blocked.
@@ -428,7 +438,7 @@ TEST_P(QuicSessionTest, OnCanWriteCongestionControlBlocks) {
QuicTime::Delta::Zero()));
EXPECT_CALL(*stream4, OnCanWrite());
session_.OnCanWrite();
- EXPECT_FALSE(session_.HasPendingWrites());
+ EXPECT_FALSE(session_.WillingAndAbleToWrite());
}
TEST_P(QuicSessionTest, BufferedHandshake) {
@@ -475,7 +485,7 @@ TEST_P(QuicSessionTest, BufferedHandshake) {
InvokeWithoutArgs(&stream4_blocker, &StreamBlocker::MarkWriteBlocked));
session_.OnCanWrite();
- EXPECT_TRUE(session_.HasPendingWrites());
+ EXPECT_TRUE(session_.WillingAndAbleToWrite());
EXPECT_FALSE(session_.HasPendingHandshake()); // Crypto stream wrote.
}
@@ -493,7 +503,40 @@ TEST_P(QuicSessionTest, OnCanWriteWithClosedStream) {
EXPECT_CALL(*stream2, OnCanWrite());
EXPECT_CALL(*stream4, OnCanWrite());
session_.OnCanWrite();
- EXPECT_FALSE(session_.HasPendingWrites());
+ EXPECT_FALSE(session_.WillingAndAbleToWrite());
+}
+
+TEST_P(QuicSessionTest, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
+ ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true);
+ if (version() < QUIC_VERSION_19) {
+ return;
+ }
+
+ // Ensure connection level flow control blockage.
+ QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0);
+ EXPECT_TRUE(session_.flow_controller()->IsBlocked());
+
+ // Mark the crypto and headers streams as write blocked, we expect them to be
+ // allowed to write later.
+ session_.MarkWriteBlocked(kCryptoStreamId, kHighestPriority);
+ session_.MarkWriteBlocked(kHeadersStreamId, kHighestPriority);
+
+ // Create a data stream, and although it is write blocked we never expect it
+ // to be allowed to write as we are connection level flow control blocked.
+ TestStream* stream = session_.CreateOutgoingDataStream();
+ session_.MarkWriteBlocked(stream->id(), kSomeMiddlePriority);
+ EXPECT_CALL(*stream, OnCanWrite()).Times(0);
+
+ // The crypto and headers streams should be called even though we are
+ // connection flow control blocked.
+ TestCryptoStream* crypto_stream = session_.GetCryptoStream();
+ EXPECT_CALL(*crypto_stream, OnCanWrite()).Times(1);
+ TestHeadersStream* headers_stream = new TestHeadersStream(&session_);
+ QuicSessionPeer::SetHeadersStream(&session_, headers_stream);
+ EXPECT_CALL(*headers_stream, OnCanWrite()).Times(1);
+
+ session_.OnCanWrite();
+ EXPECT_FALSE(session_.WillingAndAbleToWrite());
}
TEST_P(QuicSessionTest, SendGoAway) {
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_write_blocked_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698