diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 14:30:16 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 14:30:16 +0000 |
commit | 97cf302c2ab7903de946a7bcc2a26f7c02b2e073 (patch) | |
tree | 60ae842094d86b9383f884d3d2e47b201636c0c5 /net/quic/quic_ack_notifier_test.cc | |
parent | 58f2878ce0784383088ba71a83a4c3c681a760a2 (diff) | |
download | chromium_src-97cf302c2ab7903de946a7bcc2a26f7c02b2e073.zip chromium_src-97cf302c2ab7903de946a7bcc2a26f7c02b2e073.tar.gz chromium_src-97cf302c2ab7903de946a7bcc2a26f7c02b2e073.tar.bz2 |
Land Recent QUIC changes.
This is the first part of the code to allow faster stats/future
compression stuff to register for a notification when a block of data
has been fully ACKed by the peer.
The idea is as follows:
Someone who wants to be notified when their data is ACKed calls
SendStreamDataAndNotifyWhenAcked instead of SendStreamData, and provides
a Closure.
The QuicConnection stores the Closure in a QuicAckNotifier, and
maintains a vector of these.
On every ACK frame received, the OnAck(acked_seqnums) method of each
QuicAckNotifier is called. The QuicAckNotifier keeps track of the
sequence numbers it is waiting to see, and after being notified of all
of them it calls the Closure's Run() method.
Merge internal change: 51476134
Changed SourceAddressToken's code not to include port number while
performing crypto handshake (found in EndToEnd unit tests).
Use IPAddressToPackedString for source address token comparison.
Add CryptoServerConfig::set_strike_register_no_startup_period() to allow
a QuicServer to start accepting 0-RTT handshakes without waiting
a startup period.
Add an end-to-end test for a successful 0-RTT handshake.
Merge internal change: 51419595
Copying the overly-lenient SPDY workarounds to handling priority blocked
streams for idle timeout logic.
Merge internal change: 51406984
For this CL, the only chromium side change is to add
QuicConnectionPeer::SetPeerAddress.
Log packet retransmissions to DLOG(INFO). Use the standard format for
the log messages for crypto handshake messages on the client side.
Merge internal change: 51336227
New frame ID scheme to eliminate conflict between STREAM and PADDING
frames. PADDING frames are now stream type 0. Description of the new
scheme is in quic_framer.cc.
Merge internal change: 51271708
Fixing a bug in implicitly created streams which results in early packet
loss causing all streams to hang.
Merge internal change: 51248632
R=rch@chromium.org
Review URL: https://chromiumcodereview.appspot.com/23464033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221419 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic/quic_ack_notifier_test.cc')
-rw-r--r-- | net/quic/quic_ack_notifier_test.cc | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/net/quic/quic_ack_notifier_test.cc b/net/quic/quic_ack_notifier_test.cc new file mode 100644 index 0000000..aa1ebfa --- /dev/null +++ b/net/quic/quic_ack_notifier_test.cc @@ -0,0 +1,106 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/quic/quic_ack_notifier.h" + +#include "net/quic/test_tools/quic_test_utils.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace net { +namespace test { +namespace { + +class QuicAckNotifierTest : public ::testing::Test { + protected: + virtual void SetUp() { + notifier_.reset(new QuicAckNotifier(&delegate_)); + + sequence_numbers_.insert(26); + sequence_numbers_.insert(99); + sequence_numbers_.insert(1234); + notifier_->AddSequenceNumbers(sequence_numbers_); + } + + SequenceNumberSet sequence_numbers_; + MockAckNotifierDelegate delegate_; + scoped_ptr<QuicAckNotifier> notifier_; +}; + +// Should trigger callback when we receive acks for all the registered seqnums. +TEST_F(QuicAckNotifierTest, TriggerCallback) { + EXPECT_CALL(delegate_, OnAckNotification()).Times(1); + EXPECT_TRUE(notifier_->OnAck(sequence_numbers_)); +} + +// Should trigger callback when we receive acks for all the registered seqnums, +// even though they are interspersed with other seqnums. +TEST_F(QuicAckNotifierTest, TriggerCallbackInterspersed) { + sequence_numbers_.insert(3); + sequence_numbers_.insert(55); + sequence_numbers_.insert(805); + + EXPECT_CALL(delegate_, OnAckNotification()).Times(1); + EXPECT_TRUE(notifier_->OnAck(sequence_numbers_)); +} + +// Should trigger callback when we receive acks for all the registered seqnums, +// even though they are split over multiple calls to OnAck. +TEST_F(QuicAckNotifierTest, TriggerCallbackMultipleCalls) { + SequenceNumberSet seqnums; + seqnums.insert(26); + EXPECT_CALL(delegate_, OnAckNotification()).Times(0); + EXPECT_FALSE(notifier_->OnAck(seqnums)); + + seqnums.clear(); + seqnums.insert(55); + seqnums.insert(9001); + seqnums.insert(99); + EXPECT_CALL(delegate_, OnAckNotification()).Times(0); + EXPECT_FALSE(notifier_->OnAck(seqnums)); + + seqnums.clear(); + seqnums.insert(1234); + EXPECT_CALL(delegate_, OnAckNotification()).Times(1); + EXPECT_TRUE(notifier_->OnAck(seqnums)); +} + +// Should not trigger callback if we never provide all the seqnums. +TEST_F(QuicAckNotifierTest, DoesNotTrigger) { + SequenceNumberSet different_seqnums; + different_seqnums.insert(14); + different_seqnums.insert(15); + different_seqnums.insert(16); + + // Should not trigger callback as not all packets have been seen. + EXPECT_CALL(delegate_, OnAckNotification()).Times(0); + EXPECT_FALSE(notifier_->OnAck(different_seqnums)); +} + +// Should trigger even after updating sequence numbers and receiving ACKs for +// new sequeunce numbers. +TEST_F(QuicAckNotifierTest, UpdateSeqNums) { + // Uninteresting sequeunce numbers shouldn't trigger callback. + SequenceNumberSet seqnums; + seqnums.insert(6); + seqnums.insert(7); + seqnums.insert(2000); + EXPECT_CALL(delegate_, OnAckNotification()).Times(0); + EXPECT_FALSE(notifier_->OnAck(seqnums)); + + // Update a couple of the sequence numbers (i.e. retransmitted packets) + notifier_->UpdateSequenceNumber(99, 3000); + notifier_->UpdateSequenceNumber(1234, 3001); + + seqnums.clear(); + seqnums.insert(26); // original, unchanged + seqnums.insert(3000); // updated + seqnums.insert(3001); // updated + EXPECT_CALL(delegate_, OnAckNotification()).Times(1); + EXPECT_TRUE(notifier_->OnAck(seqnums)); +} + +} // namespace +} // namespace test +} // namespace net |