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

Side by Side Diff: net/quic/quic_data_stream_test.cc

Issue 288313003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: implemented rch's comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_data_stream.h" 5 #include "net/quic/quic_data_stream.h"
6 6
7 #include "net/quic/quic_ack_notifier.h" 7 #include "net/quic/quic_ack_notifier.h"
8 #include "net/quic/quic_connection.h" 8 #include "net/quic/quic_connection.h"
9 #include "net/quic/quic_flags.h" 9 #include "net/quic/quic_flags.h"
10 #include "net/quic/quic_utils.h" 10 #include "net/quic/quic_utils.h"
(...skipping 12 matching lines...) Expand all
23 using testing::AnyNumber; 23 using testing::AnyNumber;
24 using testing::InSequence; 24 using testing::InSequence;
25 using testing::Return; 25 using testing::Return;
26 using testing::SaveArg; 26 using testing::SaveArg;
27 using testing::StrictMock; 27 using testing::StrictMock;
28 28
29 namespace net { 29 namespace net {
30 namespace test { 30 namespace test {
31 namespace { 31 namespace {
32 32
33 const QuicConnectionId kStreamId = 3; 33 // First non-reserved client stream ID.
34 const QuicStreamId kStreamId = 5;
35
34 const bool kIsServer = true; 36 const bool kIsServer = true;
35 const bool kShouldProcessData = true; 37 const bool kShouldProcessData = true;
36 38
37 class TestStream : public QuicDataStream { 39 class TestStream : public QuicDataStream {
38 public: 40 public:
39 TestStream(QuicStreamId id, 41 TestStream(QuicStreamId id,
40 QuicSession* session, 42 QuicSession* session,
41 bool should_process_data) 43 bool should_process_data)
42 : QuicDataStream(id, session), 44 : QuicDataStream(id, session),
43 should_process_data_(should_process_data) {} 45 should_process_data_(should_process_data) {}
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // Set a small flow control limit for streams and connection. 430 // Set a small flow control limit for streams and connection.
429 const uint64 kWindow = 36; 431 const uint64 kWindow = 36;
430 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 432 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(),
431 kWindow); 433 kWindow);
432 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), 434 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(),
433 kWindow); 435 kWindow);
434 QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_->flow_controller(), 436 QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_->flow_controller(),
435 kWindow); 437 kWindow);
436 QuicFlowControllerPeer::SetMaxReceiveWindow(stream2_->flow_controller(), 438 QuicFlowControllerPeer::SetMaxReceiveWindow(stream2_->flow_controller(),
437 kWindow); 439 kWindow);
438 QuicFlowControllerPeer::SetReceiveWindowOffset(connection_->flow_controller(), 440 QuicFlowControllerPeer::SetReceiveWindowOffset(session_->flow_controller(),
439 kWindow); 441 kWindow);
440 QuicFlowControllerPeer::SetMaxReceiveWindow(connection_->flow_controller(), 442 QuicFlowControllerPeer::SetMaxReceiveWindow(session_->flow_controller(),
441 kWindow); 443 kWindow);
442 444
443 // Supply headers to both streams so that they are happy to receive data. 445 // Supply headers to both streams so that they are happy to receive data.
444 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); 446 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_);
445 stream_->OnStreamHeaders(headers); 447 stream_->OnStreamHeaders(headers);
446 stream_->OnStreamHeadersComplete(false, headers.size()); 448 stream_->OnStreamHeadersComplete(false, headers.size());
447 stream2_->OnStreamHeaders(headers); 449 stream2_->OnStreamHeaders(headers);
448 stream2_->OnStreamHeadersComplete(false, headers.size()); 450 stream2_->OnStreamHeadersComplete(false, headers.size());
449 451
450 // Each stream gets a quarter window of data. This should not trigger a 452 // Each stream gets a quarter window of data. This should not trigger a
451 // WINDOW_UPDATE for either stream, nor for the connection. 453 // WINDOW_UPDATE for either stream, nor for the connection.
452 string body; 454 string body;
453 GenerateBody(&body, kWindow / 4); 455 GenerateBody(&body, kWindow / 4);
454 QuicStreamFrame frame1(kStreamId, false, 0, MakeIOVector(body)); 456 QuicStreamFrame frame1(kStreamId, false, 0, MakeIOVector(body));
455 stream_->OnStreamFrame(frame1); 457 stream_->OnStreamFrame(frame1);
456 QuicStreamFrame frame2(kStreamId + 2, false, 0, MakeIOVector(body)); 458 QuicStreamFrame frame2(kStreamId + 2, false, 0, MakeIOVector(body));
457 stream2_->OnStreamFrame(frame2); 459 stream2_->OnStreamFrame(frame2);
458 460
459 // Now receive a further single byte on one stream - again this does not 461 // Now receive a further single byte on one stream - again this does not
460 // trigger a stream WINDOW_UPDATE, but now the connection flow control window 462 // trigger a stream WINDOW_UPDATE, but now the connection flow control window
461 // is over half full and thus a connection WINDOW_UPDATE is sent. 463 // is over half full and thus a connection WINDOW_UPDATE is sent.
462 EXPECT_CALL(*connection_, SendWindowUpdate(kStreamId, _)).Times(0); 464 EXPECT_CALL(*connection_, SendWindowUpdate(kStreamId, _)).Times(0);
463 EXPECT_CALL(*connection_, SendWindowUpdate(kStreamId + 2, _)).Times(0); 465 EXPECT_CALL(*connection_, SendWindowUpdate(kStreamId + 2, _)).Times(0);
464 EXPECT_CALL(*connection_, 466 EXPECT_CALL(*connection_,
465 SendWindowUpdate(0, QuicFlowControllerPeer::ReceiveWindowOffset( 467 SendWindowUpdate(0, QuicFlowControllerPeer::ReceiveWindowOffset(
466 connection_->flow_controller()) + 468 session_->flow_controller()) +
467 1 + kWindow / 2)); 469 1 + kWindow / 2));
468 QuicStreamFrame frame3(kStreamId, false, (kWindow / 4), MakeIOVector("a")); 470 QuicStreamFrame frame3(kStreamId, false, (kWindow / 4), MakeIOVector("a"));
469 stream_->OnStreamFrame(frame3); 471 stream_->OnStreamFrame(frame3);
470 } 472 }
471 473
472 TEST_P(QuicDataStreamTest, StreamFlowControlViolation) { 474 TEST_P(QuicDataStreamTest, StreamFlowControlViolation) {
473 // Tests that on if the peer sends too much data (i.e. violates the flow 475 // Tests that on if the peer sends too much data (i.e. violates the flow
474 // control protocol), then we terminate the connection. 476 // control protocol), then we terminate the connection.
475 if (GetParam() < QUIC_VERSION_17) { 477 if (GetParam() < QUIC_VERSION_17) {
476 return; 478 return;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 513
512 // Stream should not process data, so that data gets buffered in the 514 // Stream should not process data, so that data gets buffered in the
513 // sequencer, triggering flow control limits. 515 // sequencer, triggering flow control limits.
514 Initialize(!kShouldProcessData); 516 Initialize(!kShouldProcessData);
515 517
516 // Set a small flow control window on streams, and connection. 518 // Set a small flow control window on streams, and connection.
517 const uint64 kStreamWindow = 50; 519 const uint64 kStreamWindow = 50;
518 const uint64 kConnectionWindow = 10; 520 const uint64 kConnectionWindow = 10;
519 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 521 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(),
520 kStreamWindow); 522 kStreamWindow);
521 QuicFlowControllerPeer::SetReceiveWindowOffset(connection_->flow_controller(), 523 QuicFlowControllerPeer::SetReceiveWindowOffset(session_->flow_controller(),
522 kConnectionWindow); 524 kConnectionWindow);
523 525
524 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); 526 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_);
525 stream_->OnStreamHeaders(headers); 527 stream_->OnStreamHeaders(headers);
526 EXPECT_EQ(headers, stream_->data()); 528 EXPECT_EQ(headers, stream_->data());
527 stream_->OnStreamHeadersComplete(false, headers.size()); 529 stream_->OnStreamHeadersComplete(false, headers.size());
528 530
529 // Send enough data to overflow the connection level flow control window. 531 // Send enough data to overflow the connection level flow control window.
530 string body; 532 string body;
531 GenerateBody(&body, kConnectionWindow + 1); 533 GenerateBody(&body, kConnectionWindow + 1);
(...skipping 26 matching lines...) Expand all
558 EXPECT_CALL(*connection_, SendBlocked(kStreamId)).Times(0); 560 EXPECT_CALL(*connection_, SendBlocked(kStreamId)).Times(0);
559 EXPECT_CALL(*session_, WritevData(kStreamId, _, _, _, _)).WillOnce( 561 EXPECT_CALL(*session_, WritevData(kStreamId, _, _, _, _)).WillOnce(
560 Return(QuicConsumedData(0, fin))); 562 Return(QuicConsumedData(0, fin)));
561 563
562 stream_->WriteOrBufferData(body, fin, NULL); 564 stream_->WriteOrBufferData(body, fin, NULL);
563 } 565 }
564 566
565 } // namespace 567 } // namespace
566 } // namespace test 568 } // namespace test
567 } // namespace net 569 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698