summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-27 03:40:44 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-27 03:40:44 +0000
commit2cfc6bb8891f4eaac2146c97fe562ca698a9883c (patch)
tree064ab3652329edc1a33845aa58c0aef2f8322a7b /net
parenta9f5730af67a9838ea3e68efa5beb54f861f02cb (diff)
downloadchromium_src-2cfc6bb8891f4eaac2146c97fe562ca698a9883c.zip
chromium_src-2cfc6bb8891f4eaac2146c97fe562ca698a9883c.tar.gz
chromium_src-2cfc6bb8891f4eaac2146c97fe562ca698a9883c.tar.bz2
Land Recent QUIC changes.
Rename ambiquious ConnectionClose method to OnConnectionClosed. Merge internal change: 54774694 Change TCP cubic's max packet size used to calculate the initial and subsequent congestion window in bytes to the default of 1460 from QUIC's artificially low 1200. Merge internal change: 54772582 QUIC: make the SCID a hash of the rest of the server config. We need to ensure that the SCID changes whenever the rest of the server config does. For example, cl/54004815 changed the server config, but not the SCID. This could lead to bad 0-RTT handshakes where the server believes the handshake is good, but will derive different keys than the client. The easiest change to ensure that the SCID is changed is to make it a hash of the rest of the message. Merge internal change: 54659325 EndToEndTest to fix TSAN. Merge internal change: 54090381 Don't add a zero-length public key to kPUBS if P-256 support is disabled. kKEXS and kPUBS should have the same number of elements. Merge internal change: 54004815 Make the QuicConnectionHelper no longer owned by the QuicConnection. Instead a single helper is owned by the Dispatcher or Client, and shared among each Connection. Merge internal change: 53974968 R=rch@chromium.org Review URL: https://codereview.chromium.org/45733002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender.cc2
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender.h3
-rw-r--r--net/quic/congestion_control/tcp_cubic_sender_test.cc30
-rw-r--r--net/quic/crypto/crypto_server_config.cc53
-rw-r--r--net/quic/crypto/crypto_server_test.cc53
-rw-r--r--net/quic/quic_client_session.cc7
-rw-r--r--net/quic/quic_client_session.h2
-rw-r--r--net/quic/quic_connection.cc2
-rw-r--r--net/quic/quic_connection.h12
-rw-r--r--net/quic/quic_connection_helper.h3
-rw-r--r--net/quic/quic_connection_helper_test.cc25
-rw-r--r--net/quic/quic_connection_logger.cc8
-rw-r--r--net/quic/quic_connection_logger.h2
-rw-r--r--net/quic/quic_connection_test.cc39
-rw-r--r--net/quic/quic_crypto_stream.cc12
-rw-r--r--net/quic/quic_crypto_stream.h4
-rw-r--r--net/quic/quic_crypto_stream_test.cc6
-rw-r--r--net/quic/quic_http_stream_test.cc8
-rw-r--r--net/quic/quic_session.cc14
-rw-r--r--net/quic/quic_session.h2
-rw-r--r--net/quic/quic_stream_factory.cc13
-rw-r--r--net/quic/quic_stream_factory.h6
-rw-r--r--net/quic/quic_stream_sequencer.cc3
-rw-r--r--net/quic/quic_stream_sequencer_test.cc6
-rw-r--r--net/quic/reliable_quic_stream.cc12
-rw-r--r--net/quic/reliable_quic_stream.h7
-rw-r--r--net/quic/reliable_quic_stream_test.cc2
-rw-r--r--net/quic/test_tools/quic_connection_peer.cc2
-rw-r--r--net/quic/test_tools/quic_test_utils.cc3
-rw-r--r--net/quic/test_tools/quic_test_utils.h5
-rw-r--r--net/tools/quic/end_to_end_test.cc22
-rw-r--r--net/tools/quic/quic_client.cc5
-rw-r--r--net/tools/quic/quic_client.h3
-rw-r--r--net/tools/quic/quic_dispatcher.cc7
-rw-r--r--net/tools/quic/quic_dispatcher.h9
-rw-r--r--net/tools/quic/quic_dispatcher_test.cc10
-rw-r--r--net/tools/quic/quic_epoll_connection_helper_test.cc12
-rw-r--r--net/tools/quic/quic_server_session.cc7
-rw-r--r--net/tools/quic/quic_server_session.h4
-rw-r--r--net/tools/quic/test_tools/quic_dispatcher_peer.cc6
-rw-r--r--net/tools/quic/test_tools/quic_dispatcher_peer.h2
-rw-r--r--net/tools/quic/test_tools/quic_test_utils.cc6
-rw-r--r--net/tools/quic/test_tools/quic_test_utils.h3
43 files changed, 271 insertions, 171 deletions
diff --git a/net/quic/congestion_control/tcp_cubic_sender.cc b/net/quic/congestion_control/tcp_cubic_sender.cc
index 36164b1..14804a9 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender.cc
@@ -13,7 +13,7 @@ namespace net {
namespace {
// Constants based on TCP defaults.
const int64 kHybridStartLowWindow = 16;
-const QuicByteCount kMaxSegmentSize = kMaxPacketSize;
+const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS;
const QuicByteCount kDefaultReceiveWindow = 64000;
const int64 kInitialCongestionWindow = 10;
const int kMaxBurstLength = 3;
diff --git a/net/quic/congestion_control/tcp_cubic_sender.h b/net/quic/congestion_control/tcp_cubic_sender.h
index 603c73f..f83de11 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.h
+++ b/net/quic/congestion_control/tcp_cubic_sender.h
@@ -20,6 +20,9 @@
namespace net {
+// Default maximum packet size used in Linux TCP implementations.
+const QuicByteCount kDefaultTCPMSS = 1460;
+
namespace test {
class TcpCubicSenderPeer;
} // namespace test
diff --git a/net/quic/congestion_control/tcp_cubic_sender_test.cc b/net/quic/congestion_control/tcp_cubic_sender_test.cc
index f8013bc0..5c2db40 100644
--- a/net/quic/congestion_control/tcp_cubic_sender_test.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender_test.cc
@@ -12,7 +12,7 @@
namespace net {
namespace test {
-const uint32 kDefaultWindowTCP = 10 * kMaxPacketSize;
+const uint32 kDefaultWindowTCP = 10 * kDefaultTCPMSS;
// TODO(ianswett): Remove 10000 once b/10075719 is fixed.
const QuicTcpCongestionWindow kDefaultMaxCongestionWindowTCP = 10000;
@@ -43,7 +43,7 @@ class TcpCubicSenderTest : public ::testing::Test {
void SendAvailableSendWindow() {
QuicByteCount bytes_to_send = sender_->AvailableSendWindow();
while (bytes_to_send > 0) {
- QuicByteCount bytes_in_packet = std::min(kMaxPacketSize, bytes_to_send);
+ QuicByteCount bytes_in_packet = std::min(kDefaultTCPMSS, bytes_to_send);
sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet,
NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
bytes_to_send -= bytes_in_packet;
@@ -57,7 +57,7 @@ class TcpCubicSenderTest : public ::testing::Test {
void AckNPackets(int n) {
for (int i = 0; i < n; ++i) {
acked_sequence_number_++;
- sender_->OnIncomingAck(acked_sequence_number_, kMaxPacketSize, rtt_);
+ sender_->OnIncomingAck(acked_sequence_number_, kDefaultTCPMSS, rtt_);
}
clock_.AdvanceTime(one_ms_); // 1 millisecond.
}
@@ -115,7 +115,7 @@ TEST_F(TcpCubicSenderTest, ExponentialSlowStart) {
AckNPackets(2);
}
QuicByteCount bytes_to_send = sender_->SendWindow();
- EXPECT_EQ(kDefaultWindowTCP + kMaxPacketSize * 2 * kNumberOfAck,
+ EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAck,
bytes_to_send);
}
@@ -144,12 +144,12 @@ TEST_F(TcpCubicSenderTest, SlowStartAckTrain) {
AckNPackets(2);
}
QuicByteCount expected_send_window =
- kDefaultWindowTCP + (kMaxPacketSize * 2 * kNumberOfAck);
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAck);
EXPECT_EQ(expected_send_window, sender_->SendWindow());
// We should now have fallen out of slow start.
SendAvailableSendWindow();
AckNPackets(2);
- expected_send_window += kMaxPacketSize;
+ expected_send_window += kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->SendWindow());
// Testing Reno phase.
@@ -162,7 +162,7 @@ TEST_F(TcpCubicSenderTest, SlowStartAckTrain) {
}
SendAvailableSendWindow();
AckNPackets(2);
- expected_send_window += kMaxPacketSize;
+ expected_send_window += kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->SendWindow());
}
@@ -188,7 +188,7 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) {
}
SendAvailableSendWindow();
QuicByteCount expected_send_window = kDefaultWindowTCP +
- (kMaxPacketSize * 2 * kNumberOfAck);
+ (kDefaultTCPMSS * 2 * kNumberOfAck);
EXPECT_EQ(expected_send_window, sender_->SendWindow());
sender_->OnIncomingLoss(clock_.Now());
@@ -204,13 +204,13 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) {
// Testing Reno phase.
// We need to ack half of the pending packet before we can send again.
- int number_of_packets_in_window = expected_send_window / kMaxPacketSize;
+ int number_of_packets_in_window = expected_send_window / kDefaultTCPMSS;
AckNPackets(number_of_packets_in_window);
EXPECT_EQ(expected_send_window, sender_->SendWindow());
EXPECT_EQ(0u, sender_->AvailableSendWindow());
AckNPackets(1);
- expected_send_window += kMaxPacketSize;
+ expected_send_window += kDefaultTCPMSS;
number_of_packets_in_window++;
EXPECT_EQ(expected_send_window, sender_->SendWindow());
@@ -223,7 +223,7 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) {
}
SendAvailableSendWindow();
AckNPackets(1);
- expected_send_window += kMaxPacketSize;
+ expected_send_window += kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->SendWindow());
}
@@ -280,7 +280,7 @@ TEST_F(TcpCubicSenderTest, SlowStartMaxSendWindow) {
AckNPackets(2);
}
QuicByteCount expected_send_window =
- kMaxCongestionWindowTCP * kMaxPacketSize;
+ kMaxCongestionWindowTCP * kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->SendWindow());
}
@@ -314,7 +314,7 @@ TEST_F(TcpCubicSenderTest, TcpRenoMaxCongestionWindow) {
}
QuicByteCount expected_send_window =
- kMaxCongestionWindowTCP * kMaxPacketSize;
+ kMaxCongestionWindowTCP * kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->SendWindow());
}
@@ -348,7 +348,7 @@ TEST_F(TcpCubicSenderTest, TcpCubicMaxCongestionWindow) {
}
QuicByteCount expected_send_window =
- kMaxCongestionWindowTCP * kMaxPacketSize;
+ kMaxCongestionWindowTCP * kDefaultTCPMSS;
EXPECT_EQ(expected_send_window, sender_->SendWindow());
}
@@ -357,7 +357,7 @@ TEST_F(TcpCubicSenderTest, SendWindowNotAffectedByAcks) {
// Send a packet with no retransmittable data, and ensure that the congestion
// window doesn't change.
- QuicByteCount bytes_in_packet = std::min(kMaxPacketSize, send_window);
+ QuicByteCount bytes_in_packet = std::min(kDefaultTCPMSS, send_window);
sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet,
NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA);
EXPECT_EQ(send_window, sender_->AvailableSendWindow());
diff --git a/net/quic/crypto/crypto_server_config.cc b/net/quic/crypto/crypto_server_config.cc
index 4ff51c4..7fb4fa9 100644
--- a/net/quic/crypto/crypto_server_config.cc
+++ b/net/quic/crypto/crypto_server_config.cc
@@ -98,15 +98,6 @@ QuicServerConfigProtobuf* QuicCryptoServerConfig::DefaultConfig(
Curve25519KeyExchange::New(curve25519_private_key));
StringPiece curve25519_public_value = curve25519->public_value();
- string p256_private_key;
- StringPiece p256_public_value;
- scoped_ptr<P256KeyExchange> p256;
- if (options.p256) {
- p256_private_key = P256KeyExchange::NewPrivateKey();
- p256.reset(P256KeyExchange::New(p256_private_key));
- p256_public_value = p256->public_value();
- }
-
string encoded_public_values;
// First three bytes encode the length of the public value.
encoded_public_values.push_back(curve25519_public_value.size());
@@ -114,11 +105,19 @@ QuicServerConfigProtobuf* QuicCryptoServerConfig::DefaultConfig(
encoded_public_values.push_back(curve25519_public_value.size() >> 16);
encoded_public_values.append(curve25519_public_value.data(),
curve25519_public_value.size());
- encoded_public_values.push_back(p256_public_value.size());
- encoded_public_values.push_back(p256_public_value.size() >> 8);
- encoded_public_values.push_back(p256_public_value.size() >> 16);
- encoded_public_values.append(p256_public_value.data(),
- p256_public_value.size());
+
+ string p256_private_key;
+ if (options.p256) {
+ p256_private_key = P256KeyExchange::NewPrivateKey();
+ scoped_ptr<P256KeyExchange> p256(P256KeyExchange::New(p256_private_key));
+ StringPiece p256_public_value = p256->public_value();
+
+ encoded_public_values.push_back(p256_public_value.size());
+ encoded_public_values.push_back(p256_public_value.size() >> 8);
+ encoded_public_values.push_back(p256_public_value.size() >> 16);
+ encoded_public_values.append(p256_public_value.data(),
+ p256_public_value.size());
+ }
msg.set_tag(kSCFG);
if (options.p256) {
@@ -140,14 +139,6 @@ QuicServerConfigProtobuf* QuicCryptoServerConfig::DefaultConfig(
msg.SetValue(kEXPY, options.expiry_time.ToUNIXSeconds());
}
- if (options.id.empty()) {
- char scid_bytes[16];
- rand->RandBytes(scid_bytes, sizeof(scid_bytes));
- msg.SetStringPiece(kSCID, StringPiece(scid_bytes, sizeof(scid_bytes)));
- } else {
- msg.SetStringPiece(kSCID, options.id);
- }
-
char orbit_bytes[kOrbitSize];
if (options.orbit.size() == sizeof(orbit_bytes)) {
memcpy(orbit_bytes, options.orbit.data(), sizeof(orbit_bytes));
@@ -161,6 +152,24 @@ QuicServerConfigProtobuf* QuicCryptoServerConfig::DefaultConfig(
msg.SetTaglist(kPDMD, kCHID, 0);
}
+ if (options.id.empty()) {
+ // We need to ensure that the SCID changes whenever the server config does
+ // thus we make it a hash of the rest of the server config.
+ scoped_ptr<QuicData> serialized(
+ CryptoFramer::ConstructHandshakeMessage(msg));
+ scoped_ptr<SecureHash> hash(SecureHash::Create(SecureHash::SHA256));
+ hash->Update(serialized->data(), serialized->length());
+
+ char scid_bytes[16];
+ hash->Finish(scid_bytes, sizeof(scid_bytes));
+ msg.SetStringPiece(kSCID, StringPiece(scid_bytes, sizeof(scid_bytes)));
+ } else {
+ msg.SetStringPiece(kSCID, options.id);
+ }
+ // Don't put new tags below this point. The SCID generation should hash over
+ // everything but itself and so extra tags should be added prior to the
+ // preceeding if block.
+
scoped_ptr<QuicData> serialized(CryptoFramer::ConstructHandshakeMessage(msg));
scoped_ptr<QuicServerConfigProtobuf> config(new QuicServerConfigProtobuf);
diff --git a/net/quic/crypto/crypto_server_test.cc b/net/quic/crypto/crypto_server_test.cc
index 348b31a..258afd5 100644
--- a/net/quic/crypto/crypto_server_test.cc
+++ b/net/quic/crypto/crypto_server_test.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/strings/string_number_conversions.h"
+#include "crypto/secure_hash.h"
#include "net/quic/crypto/crypto_server_config.h"
#include "net/quic/crypto/crypto_utils.h"
#include "net/quic/crypto/quic_random.h"
@@ -258,6 +259,58 @@ TEST(CryptoServerConfigGenerationTest, Determinism) {
ASSERT_EQ(scfg_a->DebugString(), scfg_b->DebugString());
}
+TEST(CryptoServerConfigGenerationTest, SCIDVaries) {
+ // This test ensures that the server config ID varies for different server
+ // configs.
+
+ MockRandom rand_a, rand_b;
+ const QuicCryptoServerConfig::ConfigOptions options;
+ MockClock clock;
+
+ QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a);
+ rand_b.ChangeValue();
+ QuicCryptoServerConfig b(QuicCryptoServerConfig::TESTING, &rand_b);
+ scoped_ptr<CryptoHandshakeMessage> scfg_a(
+ a.AddDefaultConfig(&rand_a, &clock, options));
+ scoped_ptr<CryptoHandshakeMessage> scfg_b(
+ b.AddDefaultConfig(&rand_b, &clock, options));
+
+ StringPiece scid_a, scid_b;
+ EXPECT_TRUE(scfg_a->GetStringPiece(kSCID, &scid_a));
+ EXPECT_TRUE(scfg_b->GetStringPiece(kSCID, &scid_b));
+
+ EXPECT_NE(scid_a, scid_b);
+}
+
+
+TEST(CryptoServerConfigGenerationTest, SCIDIsHashOfServerConfig) {
+ MockRandom rand_a;
+ const QuicCryptoServerConfig::ConfigOptions options;
+ MockClock clock;
+
+ QuicCryptoServerConfig a(QuicCryptoServerConfig::TESTING, &rand_a);
+ scoped_ptr<CryptoHandshakeMessage> scfg(
+ a.AddDefaultConfig(&rand_a, &clock, options));
+
+ StringPiece scid;
+ EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid));
+ // Need to take a copy of |scid| has we're about to call |Erase|.
+ const string scid_str(scid.as_string());
+
+ scfg->Erase(kSCID);
+ scfg->MarkDirty();
+ const QuicData& serialized(scfg->GetSerialized());
+
+ scoped_ptr<crypto::SecureHash> hash(
+ crypto::SecureHash::Create(crypto::SecureHash::SHA256));
+ hash->Update(serialized.data(), serialized.length());
+ uint8 digest[16];
+ hash->Finish(digest, sizeof(digest));
+
+ ASSERT_EQ(scid.size(), sizeof(digest));
+ EXPECT_TRUE(0 == memcmp(digest, scid_str.data(), sizeof(digest)));
+}
+
class CryptoServerTestNoConfig : public CryptoServerTest {
public:
virtual void SetUp() {
diff --git a/net/quic/quic_client_session.cc b/net/quic/quic_client_session.cc
index 36f7dc0..8677a8d 100644
--- a/net/quic/quic_client_session.cc
+++ b/net/quic/quic_client_session.cc
@@ -340,9 +340,10 @@ void QuicClientSession::OnCryptoHandshakeMessageReceived(
logger_.OnCryptoHandshakeMessageReceived(message);
}
-void QuicClientSession::ConnectionClose(QuicErrorCode error, bool from_peer) {
+void QuicClientSession::OnConnectionClosed(QuicErrorCode error,
+ bool from_peer) {
DCHECK(!connection()->connected());
- logger_.OnConnectionClose(error, from_peer);
+ logger_.OnConnectionClosed(error, from_peer);
if (from_peer) {
UMA_HISTOGRAM_SPARSE_SLOWLY(
"Net.QuicSession.ConnectionCloseErrorCodeServer", error);
@@ -371,7 +372,7 @@ void QuicClientSession::ConnectionClose(QuicErrorCode error, bool from_peer) {
base::ResetAndReturn(&callback_).Run(ERR_QUIC_PROTOCOL_ERROR);
}
socket_->Close();
- QuicSession::ConnectionClose(error, from_peer);
+ QuicSession::OnConnectionClosed(error, from_peer);
NotifyFactoryOfSessionClosedLater();
}
diff --git a/net/quic/quic_client_session.h b/net/quic/quic_client_session.h
index 583ba96..6e8ea47 100644
--- a/net/quic/quic_client_session.h
+++ b/net/quic/quic_client_session.h
@@ -127,7 +127,7 @@ class NET_EXPORT_PRIVATE QuicClientSession : public QuicSession {
virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
// QuicConnectionVisitorInterface methods:
- virtual void ConnectionClose(QuicErrorCode error, bool from_peer) OVERRIDE;
+ virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
virtual void OnSuccessfulVersionNegotiation(
const QuicVersion& version) OVERRIDE;
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index 28a7b0d..7448b51 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -1742,7 +1742,7 @@ void QuicConnection::SendConnectionClosePacket(QuicErrorCode error,
void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) {
DCHECK(connected_);
connected_ = false;
- visitor_->ConnectionClose(error, from_peer);
+ visitor_->OnConnectionClosed(error, from_peer);
}
void QuicConnection::SendGoAway(QuicErrorCode error,
diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h
index 583962c..7f3875b 100644
--- a/net/quic/quic_connection.h
+++ b/net/quic/quic_connection.h
@@ -78,8 +78,8 @@ class NET_EXPORT_PRIVATE QuicConnectionVisitorInterface {
// Called when the connection is closed either locally by the framer, or
// remotely by the peer.
- virtual void ConnectionClose(QuicErrorCode error,
- bool from_peer) = 0;
+ virtual void OnConnectionClosed(QuicErrorCode error,
+ bool from_peer) = 0;
// Called once a specific QUIC version is agreed by both endpoints.
virtual void OnSuccessfulVersionNegotiation(const QuicVersion& version) = 0;
@@ -189,7 +189,7 @@ class NET_EXPORT_PRIVATE QuicConnection
};
// Constructs a new QuicConnection for the specified |guid| and |address|.
- // |helper| will be owned by this connection.
+ // |helper| and |writer| must outlive this connection.
QuicConnection(QuicGuid guid,
IPEndPoint address,
QuicConnectionHelperInterface* helper,
@@ -441,7 +441,7 @@ class NET_EXPORT_PRIVATE QuicConnection
// Make sure an ack we got from our peer is sane.
bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
- QuicConnectionHelperInterface* helper() { return helper_.get(); }
+ QuicConnectionHelperInterface* helper() { return helper_; }
// Selects and updates the version of the protocol being used by selecting a
// version from |available_versions| which is also supported. Returns true if
@@ -648,8 +648,8 @@ class NET_EXPORT_PRIVATE QuicConnection
// Closes any FEC groups protecting packets before |sequence_number|.
void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number);
- scoped_ptr<QuicConnectionHelperInterface> helper_;
- QuicPacketWriter* writer_;
+ QuicConnectionHelperInterface* helper_; // Not owned.
+ QuicPacketWriter* writer_; // Not owned.
EncryptionLevel encryption_level_;
const QuicClock* clock_;
QuicRandom* random_generator_;
diff --git a/net/quic/quic_connection_helper.h b/net/quic/quic_connection_helper.h
index 3aaab29..7098039 100644
--- a/net/quic/quic_connection_helper.h
+++ b/net/quic/quic_connection_helper.h
@@ -42,9 +42,6 @@ class NET_EXPORT_PRIVATE QuicConnectionHelper
virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) OVERRIDE;
private:
- // A completion callback invoked when a write completes.
- void OnWriteComplete(int rv);
-
base::WeakPtrFactory<QuicConnectionHelper> weak_factory_;
base::TaskRunner* task_runner_;
const QuicClock* clock_;
diff --git a/net/quic/quic_connection_helper_test.cc b/net/quic/quic_connection_helper_test.cc
index fd50a8e..d88bcb6 100644
--- a/net/quic/quic_connection_helper_test.cc
+++ b/net/quic/quic_connection_helper_test.cc
@@ -121,20 +121,20 @@ class QuicConnectionHelperTest : public ::testing::Test {
net_log_.net_log()));
socket_->Connect(IPEndPoint());
runner_ = new TestTaskRunner(&clock_);
- helper_ = new QuicConnectionHelper(runner_.get(), &clock_,
- &random_generator_);
+ helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_,
+ &random_generator_));
send_algorithm_ = new testing::StrictMock<MockSendAlgorithm>();
EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _, _)).
WillRepeatedly(Return(QuicTime::Delta::Zero()));
- EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(
- Return(QuicBandwidth::FromKBitsPerSecond(100)));
- EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(
- Return(QuicTime::Delta::FromMilliseconds(100)));
+ EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return(
+ QuicBandwidth::FromKBitsPerSecond(100)));
+ EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return(
+ QuicTime::Delta::FromMilliseconds(100)));
ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
.WillByDefault(Return(true));
EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber());
writer_.reset(new QuicDefaultPacketWriter(socket_.get()));
- connection_.reset(new TestConnection(guid_, IPEndPoint(), helper_,
+ connection_.reset(new TestConnection(guid_, IPEndPoint(), helper_.get(),
writer_.get()));
connection_->set_visitor(&visitor_);
connection_->SetSendAlgorithm(send_algorithm_);
@@ -200,14 +200,14 @@ class QuicConnectionHelperTest : public ::testing::Test {
testing::StrictMock<MockSendAlgorithm>* send_algorithm_;
scoped_refptr<TestTaskRunner> runner_;
- QuicConnectionHelper* helper_;
+ scoped_ptr<QuicConnectionHelper> helper_;
+ scoped_ptr<TestConnection> connection_;
+ testing::StrictMock<MockConnectionVisitor> visitor_;
scoped_ptr<QuicDefaultPacketWriter> writer_;
scoped_ptr<MockUDPClientSocket> socket_;
scoped_ptr<MockWrite[]> mock_writes_;
MockClock clock_;
MockRandom random_generator_;
- scoped_ptr<TestConnection> connection_;
- testing::StrictMock<MockConnectionVisitor> visitor_;
private:
void InitializeHeader(QuicPacketSequenceNumber sequence_number) {
@@ -430,7 +430,7 @@ TEST_F(QuicConnectionHelperTest, InitialTimeout) {
EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillOnce(
Return(QuicTime::Delta::FromMicroseconds(1)));
// After we run the next task, we should close the connection.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false));
runner_->RunNextTask();
EXPECT_EQ(QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(
@@ -468,7 +468,8 @@ TEST_F(QuicConnectionHelperTest, TimeoutAfterSend) {
EXPECT_TRUE(connection_->connected());
// This time, we should time out.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, !kFromPeer));
+ EXPECT_CALL(visitor_,
+ OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, !kFromPeer));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2, _, NOT_RETRANSMISSION,
HAS_RETRANSMITTABLE_DATA));
EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillOnce(
diff --git a/net/quic/quic_connection_logger.cc b/net/quic/quic_connection_logger.cc
index 6152293..9443c03 100644
--- a/net/quic/quic_connection_logger.cc
+++ b/net/quic/quic_connection_logger.cc
@@ -183,7 +183,7 @@ base::Value* NetLogQuicCryptoHandshakeMessageCallback(
return dict;
}
-base::Value* NetLogQuicConnectionClosedCallback(
+base::Value* NetLogQuicOnConnectionClosedCallback(
QuicErrorCode error,
bool from_peer,
NetLog::LogLevel /* log_level */) {
@@ -416,11 +416,11 @@ void QuicConnectionLogger::OnCryptoHandshakeMessageSent(
base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message));
}
-void QuicConnectionLogger::OnConnectionClose(QuicErrorCode error,
- bool from_peer) {
+void QuicConnectionLogger::OnConnectionClosed(QuicErrorCode error,
+ bool from_peer) {
net_log_.AddEvent(
NetLog::TYPE_QUIC_SESSION_CLOSED,
- base::Bind(&NetLogQuicConnectionClosedCallback, error, from_peer));
+ base::Bind(&NetLogQuicOnConnectionClosedCallback, error, from_peer));
}
void QuicConnectionLogger::OnSuccessfulVersionNegotiation(
diff --git a/net/quic/quic_connection_logger.h b/net/quic/quic_connection_logger.h
index a7a8747..d162282 100644
--- a/net/quic/quic_connection_logger.h
+++ b/net/quic/quic_connection_logger.h
@@ -56,7 +56,7 @@ class NET_EXPORT_PRIVATE QuicConnectionLogger
const CryptoHandshakeMessage& message);
void OnCryptoHandshakeMessageSent(
const CryptoHandshakeMessage& message);
- void OnConnectionClose(QuicErrorCode error, bool from_peer);
+ void OnConnectionClosed(QuicErrorCode error, bool from_peer);
void OnSuccessfulVersionNegotiation(const QuicVersion& version);
private:
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index c5e33e2..8f76cb6 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -521,7 +521,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<bool> {
send_algorithm_(new StrictMock<MockSendAlgorithm>),
helper_(new TestConnectionHelper(&clock_, &random_generator_)),
writer_(new TestPacketWriter()),
- connection_(guid_, IPEndPoint(), helper_, writer_.get(), false),
+ connection_(guid_, IPEndPoint(), helper_.get(), writer_.get(), false),
frame1_(1, false, 0, data1),
frame2_(1, false, 3, data2),
accept_packet_(true) {
@@ -798,7 +798,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<bool> {
TestReceiveAlgorithm* receive_algorithm_;
MockClock clock_;
MockRandom random_generator_;
- TestConnectionHelper* helper_;
+ scoped_ptr<TestConnectionHelper> helper_;
scoped_ptr<TestPacketWriter> writer_;
TestConnection connection_;
StrictMock<MockConnectionVisitor> visitor_;
@@ -915,7 +915,7 @@ TEST_P(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) {
TEST_P(QuicConnectionTest, RejectPacketTooFarOut) {
// Call ProcessDataPacket rather than ProcessPacket, as we should not get a
// packet call to the visitor.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_PACKET_HEADER, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
ProcessDataPacket(6000, 0, !kEntropyFlag);
}
@@ -1055,7 +1055,7 @@ TEST_P(QuicConnectionTest, LeastUnackedLower) {
// Now claim it's one, but set the ordering so it was sent "after" the first
// one. This should cause a connection error.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_ACK_DATA, false));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
creator_.set_sequence_number(7);
ProcessAckPacket(&frame2);
@@ -1077,14 +1077,14 @@ TEST_P(QuicConnectionTest, LargestObservedLower) {
// Now change it to 1, and it should cause a connection error.
QuicAckFrame frame2(1, QuicTime::Zero(), 0);
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_ACK_DATA, false));
EXPECT_CALL(visitor_, OnCanWrite()).Times(0);
ProcessAckPacket(&frame2);
}
TEST_P(QuicConnectionTest, LeastUnackedGreaterThanPacketSequenceNumber) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_ACK_DATA, false));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
// Create an ack with least_unacked is 2 in packet number 1.
creator_.set_sequence_number(0);
@@ -1101,7 +1101,7 @@ TEST_P(QuicConnectionTest,
SendStreamDataToPeer(1, "bar", 3, !kFin, NULL);
SendStreamDataToPeer(1, "eep", 6, !kFin, NULL);
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_ACK_DATA, false));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
QuicAckFrame frame(0, QuicTime::Zero(), 1);
frame.received_info.missing_packets.insert(3);
@@ -1111,7 +1111,7 @@ TEST_P(QuicConnectionTest,
TEST_P(QuicConnectionTest, AckUnsentData) {
// Ack a packet which has not been sent.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_ACK_DATA, false));
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
QuicAckFrame frame(1, QuicTime::Zero(), 0);
@@ -2296,7 +2296,7 @@ TEST_P(QuicConnectionTest, DontUpdateQuicCongestionFeedbackFrameForRevived) {
TEST_P(QuicConnectionTest, InitialTimeout) {
EXPECT_TRUE(connection_.connected());
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
QuicTime default_timeout = clock_.ApproximateNow().Add(
@@ -2337,7 +2337,7 @@ TEST_P(QuicConnectionTest, TimeoutAfterSend) {
connection_.GetTimeoutAlarm()->deadline());
// This time, we should time out.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)),
@@ -2605,14 +2605,14 @@ TEST_P(QuicConnectionTest, NoAckForClose) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
ProcessPacket(1);
EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(0);
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
ProcessClosePacket(2, 0);
}
TEST_P(QuicConnectionTest, SendWhenDisconnected) {
EXPECT_TRUE(connection_.connected());
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, false));
connection_.CloseConnection(QUIC_PEER_GOING_AWAY, false);
EXPECT_FALSE(connection_.connected());
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
@@ -2629,7 +2629,7 @@ TEST_P(QuicConnectionTest, PublicReset) {
header.rejected_sequence_number = 10101;
scoped_ptr<QuicEncryptedPacket> packet(
framer_.BuildPublicResetPacket(header));
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_PUBLIC_RESET, true));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PUBLIC_RESET, true));
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *packet);
}
@@ -2898,8 +2898,9 @@ TEST_P(QuicConnectionTest, BadVersionNegotiation) {
// Send a version negotiation packet with the version the client started with.
// It should be rejected.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_VERSION_NEGOTIATION_PACKET,
- false));
+ EXPECT_CALL(visitor_,
+ OnConnectionClosed(QUIC_INVALID_VERSION_NEGOTIATION_PACKET,
+ false));
scoped_ptr<QuicEncryptedPacket> encrypted(
framer_.BuildVersionNegotiationPacket(
header.public_header, supported_versions));
@@ -3033,7 +3034,7 @@ TEST_P(QuicConnectionTest, DontProcessFramesIfPacketClosedConnection) {
scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
ENCRYPTION_NONE, 1, *packet));
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true));
EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(0);
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
@@ -3078,7 +3079,7 @@ TEST_P(QuicConnectionTest, ConnectionCloseWhenNotWriteBlocked) {
EXPECT_EQ(1u, writer_->packets_write_attempts());
// Send an erroneous packet to close the connection.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_PACKET_HEADER, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
ProcessDataPacket(6000, 0, !kEntropyFlag);
EXPECT_EQ(2u, writer_->packets_write_attempts());
}
@@ -3093,7 +3094,7 @@ TEST_P(QuicConnectionTest, ConnectionCloseWhenWriteBlocked) {
EXPECT_EQ(1u, writer_->packets_write_attempts());
// Send an erroneous packet to close the connection.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_PACKET_HEADER, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
ProcessDataPacket(6000, 0, !kEntropyFlag);
EXPECT_EQ(1u, writer_->packets_write_attempts());
}
@@ -3102,7 +3103,7 @@ TEST_P(QuicConnectionTest, ConnectionCloseWhenNothingPending) {
writer_->set_blocked(true);
// Send an erroneous packet to close the connection.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_PACKET_HEADER, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
ProcessDataPacket(6000, 0, !kEntropyFlag);
EXPECT_EQ(1u, writer_->packets_write_attempts());
}
diff --git a/net/quic/quic_crypto_stream.cc b/net/quic/quic_crypto_stream.cc
index 3c10c5b..e73e61d 100644
--- a/net/quic/quic_crypto_stream.cc
+++ b/net/quic/quic_crypto_stream.cc
@@ -24,7 +24,8 @@ QuicCryptoStream::QuicCryptoStream(QuicSession* session)
}
void QuicCryptoStream::OnError(CryptoFramer* framer) {
- session()->ConnectionClose(framer->error(), false);
+ DLOG(WARNING) << "Error processing crypto data: "
+ << QuicUtils::ErrorToString(framer->error());
}
void QuicCryptoStream::OnHandshakeMessage(
@@ -46,15 +47,6 @@ uint32 QuicCryptoStream::ProcessData(const char* data,
return data_len;
}
-void QuicCryptoStream::CloseConnection(QuicErrorCode error) {
- session()->connection()->SendConnectionClose(error);
-}
-
-void QuicCryptoStream::CloseConnectionWithDetails(QuicErrorCode error,
- const string& details) {
- session()->connection()->SendConnectionCloseWithDetails(error, details);
-}
-
void QuicCryptoStream::SendHandshakeMessage(
const CryptoHandshakeMessage& message) {
session()->OnCryptoHandshakeMessageSent(message);
diff --git a/net/quic/quic_crypto_stream.h b/net/quic/quic_crypto_stream.h
index c402b0d9..d5b3417 100644
--- a/net/quic/quic_crypto_stream.h
+++ b/net/quic/quic_crypto_stream.h
@@ -50,10 +50,6 @@ class NET_EXPORT_PRIVATE QuicCryptoStream
const QuicCryptoNegotiatedParameters& crypto_negotiated_params() const;
protected:
- // Closes the connection
- void CloseConnection(QuicErrorCode error);
- void CloseConnectionWithDetails(QuicErrorCode error, const string& details);
-
bool encryption_established_;
bool handshake_confirmed_;
diff --git a/net/quic/quic_crypto_stream_test.cc b/net/quic/quic_crypto_stream_test.cc
index cc69304..0403eb3 100644
--- a/net/quic/quic_crypto_stream_test.cc
+++ b/net/quic/quic_crypto_stream_test.cc
@@ -78,12 +78,6 @@ TEST_F(QuicCryptoStreamTest, NotInitiallyConected) {
EXPECT_FALSE(stream_.handshake_confirmed());
}
-TEST_F(QuicCryptoStreamTest, OnErrorClosesConnection) {
- CryptoFramer framer;
- EXPECT_CALL(session_, ConnectionClose(QUIC_NO_ERROR, false));
- stream_.OnError(&framer);
-}
-
TEST_F(QuicCryptoStreamTest, ProcessData) {
EXPECT_EQ(message_data_->length(),
stream_.ProcessData(message_data_->data(),
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index 5995c44..450afcb 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -197,10 +197,10 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<bool> {
Return(QuicTime::Delta::Zero()));
EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(
Return(QuicBandwidth::Zero()));
- helper_ = new QuicConnectionHelper(runner_.get(), &clock_,
- &random_generator_);
+ helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_,
+ &random_generator_));
writer_.reset(new QuicDefaultPacketWriter(socket));
- connection_ = new TestQuicConnection(guid_, peer_addr_, helper_,
+ connection_ = new TestQuicConnection(guid_, peer_addr_, helper_.get(),
writer_.get());
connection_->set_visitor(&visitor_);
connection_->SetSendAlgorithm(send_algorithm_);
@@ -305,7 +305,7 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<bool> {
MockClock clock_;
MockRandom random_generator_;
TestQuicConnection* connection_;
- QuicConnectionHelper* helper_;
+ scoped_ptr<QuicConnectionHelper> helper_;
testing::StrictMock<MockConnectionVisitor> visitor_;
scoped_ptr<QuicHttpStream> stream_;
scoped_ptr<QuicDefaultPacketWriter> writer_;
diff --git a/net/quic/quic_session.cc b/net/quic/quic_session.cc
index 9389af4..4a487d2 100644
--- a/net/quic/quic_session.cc
+++ b/net/quic/quic_session.cc
@@ -59,8 +59,9 @@ class VisitorShim : public QuicConnectionVisitorInterface {
session_->OnSuccessfulVersionNegotiation(version);
}
- virtual void ConnectionClose(QuicErrorCode error, bool from_peer) OVERRIDE {
- session_->ConnectionClose(error, from_peer);
+ virtual void OnConnectionClosed(QuicErrorCode error,
+ bool from_peer) OVERRIDE {
+ session_->OnConnectionClosed(error, from_peer);
// The session will go away, so don't bother with cleanup.
}
@@ -183,7 +184,7 @@ void QuicSession::OnGoAway(const QuicGoAwayFrame& frame) {
goaway_received_ = true;
}
-void QuicSession::ConnectionClose(QuicErrorCode error, bool from_peer) {
+void QuicSession::OnConnectionClosed(QuicErrorCode error, bool from_peer) {
DCHECK(!connection_->connected());
if (error_ == QUIC_NO_ERROR) {
error_ = error;
@@ -192,10 +193,11 @@ void QuicSession::ConnectionClose(QuicErrorCode error, bool from_peer) {
while (stream_map_.size() != 0) {
ReliableStreamMap::iterator it = stream_map_.begin();
QuicStreamId id = it->first;
- it->second->ConnectionClose(error, from_peer);
- // The stream should call CloseStream as part of ConnectionClose.
+ it->second->OnConnectionClosed(error, from_peer);
+ // The stream should call CloseStream as part of OnConnectionClosed.
if (stream_map_.find(id) != stream_map_.end()) {
- LOG(DFATAL) << ENDPOINT << "Stream failed to close under ConnectionClose";
+ LOG(DFATAL) << ENDPOINT
+ << "Stream failed to close under OnConnectionClosed";
CloseStream(id);
}
}
diff --git a/net/quic/quic_session.h b/net/quic/quic_session.h
index b58feb2..b2b6a06 100644
--- a/net/quic/quic_session.h
+++ b/net/quic/quic_session.h
@@ -63,7 +63,7 @@ class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface {
const std::vector<QuicStreamFrame>& frames) OVERRIDE;
virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE;
virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE;
- virtual void ConnectionClose(QuicErrorCode error, bool from_peer) OVERRIDE;
+ virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
virtual void OnSuccessfulVersionNegotiation(
const QuicVersion& version) OVERRIDE{}
// Not needed for HTTP.
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index 2fa1e77..a7bca03 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -440,15 +440,16 @@ QuicClientSession* QuicStreamFactory::CreateSession(
// wrong encryption level, when the send buffer is full.
socket->SetSendBufferSize(kMaxPacketSize * 20); // Support 20 packets.
- QuicConnectionHelper* helper = new QuicConnectionHelper(
- base::MessageLoop::current()->message_loop_proxy().get(),
- clock_.get(),
- random_generator_);
-
scoped_ptr<QuicDefaultPacketWriter> writer(
new QuicDefaultPacketWriter(socket.get()));
- QuicConnection* connection = new QuicConnection(guid, addr, helper,
+ if (!helper_.get()) {
+ helper_.reset(new QuicConnectionHelper(
+ base::MessageLoop::current()->message_loop_proxy().get(),
+ clock_.get(), random_generator_));
+ }
+
+ QuicConnection* connection = new QuicConnection(guid, addr, helper_.get(),
writer.get(), false,
QuicVersionMax());
writer->SetConnection(connection);
diff --git a/net/quic/quic_stream_factory.h b/net/quic/quic_stream_factory.h
index 6316d62..f688dcb 100644
--- a/net/quic/quic_stream_factory.h
+++ b/net/quic/quic_stream_factory.h
@@ -28,6 +28,7 @@ class HostResolver;
class HttpServerProperties;
class QuicClock;
class QuicClientSession;
+class QuicConnectionHelper;
class QuicCryptoClientStreamFactory;
class QuicRandom;
class QuicStreamFactory;
@@ -136,6 +137,8 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
require_confirmation_ = require_confirmation;
}
+ QuicConnectionHelper* helper() { return helper_.get(); }
+
private:
class Job;
friend class test::QuicStreamFactoryPeer;
@@ -182,6 +185,9 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
QuicRandom* random_generator_;
scoped_ptr<QuicClock> clock_;
+ // The helper used for all connections.
+ scoped_ptr<QuicConnectionHelper> helper_;
+
// Contains owning pointers to all sessions that currently exist.
SessionSet all_sessions_;
// Contains non-owning pointers to currently active session
diff --git a/net/quic/quic_stream_sequencer.cc b/net/quic/quic_stream_sequencer.cc
index a57c05f..e6050bc 100644
--- a/net/quic/quic_stream_sequencer.cc
+++ b/net/quic/quic_stream_sequencer.cc
@@ -80,7 +80,8 @@ bool QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) {
if (data_len == 0 && !frame.fin) {
// Stream frames must have data or a fin flag.
- stream_->ConnectionClose(QUIC_INVALID_STREAM_FRAME, false);
+ stream_->CloseConnectionWithDetails(QUIC_INVALID_STREAM_FRAME,
+ "Empty stream frame without FIN set.");
return false;
}
diff --git a/net/quic/quic_stream_sequencer_test.cc b/net/quic/quic_stream_sequencer_test.cc
index 21568d6..af094a2 100644
--- a/net/quic/quic_stream_sequencer_test.cc
+++ b/net/quic/quic_stream_sequencer_test.cc
@@ -71,7 +71,8 @@ class MockStream : public ReliableQuicStream {
MOCK_METHOD1(TerminateFromPeer, void(bool half_close));
MOCK_METHOD2(ProcessData, uint32(const char* data, uint32 data_len));
- MOCK_METHOD2(ConnectionClose, void(QuicErrorCode error, bool from_peer));
+ MOCK_METHOD2(CloseConnectionWithDetails, void(QuicErrorCode error,
+ const string& details));
MOCK_METHOD1(Close, void(QuicRstStreamErrorCode error));
MOCK_METHOD0(OnCanWrite, void());
};
@@ -183,7 +184,8 @@ TEST_F(QuicStreamSequencerTest, FullFrameConsumed) {
}
TEST_F(QuicStreamSequencerTest, EmptyFrame) {
- EXPECT_CALL(stream_, ConnectionClose(QUIC_INVALID_STREAM_FRAME, false));
+ EXPECT_CALL(stream_,
+ CloseConnectionWithDetails(QUIC_INVALID_STREAM_FRAME, _));
EXPECT_FALSE(sequencer_->OnFrame(0, ""));
EXPECT_EQ(0u, sequencer_->frames()->size());
EXPECT_EQ(0u, sequencer_->num_bytes_consumed());
diff --git a/net/quic/reliable_quic_stream.cc b/net/quic/reliable_quic_stream.cc
index dea1e81..0ac6ecd 100644
--- a/net/quic/reliable_quic_stream.cc
+++ b/net/quic/reliable_quic_stream.cc
@@ -99,7 +99,8 @@ void ReliableQuicStream::OnStreamReset(QuicRstStreamErrorCode error) {
TerminateFromPeer(false); // Full close.
}
-void ReliableQuicStream::ConnectionClose(QuicErrorCode error, bool from_peer) {
+void ReliableQuicStream::OnConnectionClosed(QuicErrorCode error,
+ bool from_peer) {
if (read_side_closed_ && write_side_closed_) {
return;
}
@@ -133,6 +134,15 @@ void ReliableQuicStream::Close(QuicRstStreamErrorCode error) {
}
}
+void ReliableQuicStream::CloseConnection(QuicErrorCode error) {
+ session()->connection()->SendConnectionClose(error);
+}
+
+void ReliableQuicStream::CloseConnectionWithDetails(QuicErrorCode error,
+ const string& details) {
+ session()->connection()->SendConnectionCloseWithDetails(error, details);
+}
+
size_t ReliableQuicStream::Readv(const struct iovec* iov, size_t iov_len) {
if (headers_decompressed_ && decompressed_headers_.empty()) {
return sequencer_.Readv(iov, iov_len);
diff --git a/net/quic/reliable_quic_stream.h b/net/quic/reliable_quic_stream.h
index 807882ca..52eb8aa 100644
--- a/net/quic/reliable_quic_stream.h
+++ b/net/quic/reliable_quic_stream.h
@@ -66,7 +66,7 @@ class NET_EXPORT_PRIVATE ReliableQuicStream : public
// Called when we get or send a connection close, and should immediately
// close the stream. This is not passed through the sequencer,
// but is handled immediately.
- virtual void ConnectionClose(QuicErrorCode error, bool from_peer);
+ virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer);
// Called when we should process a stream termination or
// stream close from the peer.
@@ -83,6 +83,11 @@ class NET_EXPORT_PRIVATE ReliableQuicStream : public
// Called to close the stream from this end.
virtual void Close(QuicRstStreamErrorCode error);
+ // Called to close the entire connection from this end.
+ virtual void CloseConnection(QuicErrorCode error);
+ virtual void CloseConnectionWithDetails(QuicErrorCode error,
+ const string& details);
+
// This block of functions wraps the sequencer's functions of the same
// name. These methods return uncompressed data until that has
// been fully processed. Then they simply delegate to the sequencer.
diff --git a/net/quic/reliable_quic_stream_test.cc b/net/quic/reliable_quic_stream_test.cc
index 063554d..7d1a1f1 100644
--- a/net/quic/reliable_quic_stream_test.cc
+++ b/net/quic/reliable_quic_stream_test.cc
@@ -222,7 +222,7 @@ TEST_F(ReliableQuicStreamTest, ConnectionCloseAfterStreamClose) {
stream_->CloseWriteSide();
EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error());
EXPECT_EQ(QUIC_NO_ERROR, stream_->connection_error());
- stream_->ConnectionClose(QUIC_INTERNAL_ERROR, false);
+ stream_->OnConnectionClosed(QUIC_INTERNAL_ERROR, false);
EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error());
EXPECT_EQ(QUIC_NO_ERROR, stream_->connection_error());
}
diff --git a/net/quic/test_tools/quic_connection_peer.cc b/net/quic/test_tools/quic_connection_peer.cc
index 7a233dd..7bdaec0 100644
--- a/net/quic/test_tools/quic_connection_peer.cc
+++ b/net/quic/test_tools/quic_connection_peer.cc
@@ -154,7 +154,7 @@ void QuicConnectionPeer::SwapCrypters(QuicConnection* connection,
// static
QuicConnectionHelperInterface* QuicConnectionPeer::GetHelper(
QuicConnection* connection) {
- return connection->helper_.get();
+ return connection->helper_;
}
// static
diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc
index 71a62a5..8b594c2 100644
--- a/net/quic/test_tools/quic_test_utils.cc
+++ b/net/quic/test_tools/quic_test_utils.cc
@@ -211,7 +211,8 @@ MockConnection::MockConnection(QuicGuid guid,
new testing::NiceMock<MockPacketWriter>(),
is_server, QuicVersionMax()),
has_mock_helper_(true),
- writer_(QuicConnectionPeer::GetWriter(this)) {
+ writer_(QuicConnectionPeer::GetWriter(this)),
+ helper_(helper()) {
}
MockConnection::MockConnection(QuicGuid guid,
diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h
index 0e39209..31b6c03 100644
--- a/net/quic/test_tools/quic_test_utils.h
+++ b/net/quic/test_tools/quic_test_utils.h
@@ -178,7 +178,7 @@ class MockConnectionVisitor : public QuicConnectionVisitorInterface {
MOCK_METHOD1(OnStreamFrames, bool(const std::vector<QuicStreamFrame>& frame));
MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame));
MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame));
- MOCK_METHOD2(ConnectionClose, void(QuicErrorCode error, bool from_peer));
+ MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer));
MOCK_METHOD0(OnCanWrite, bool());
MOCK_CONST_METHOD0(HasPendingHandshake, bool());
MOCK_METHOD1(OnSuccessfulVersionNegotiation,
@@ -246,6 +246,7 @@ class MockConnection : public QuicConnection {
private:
const bool has_mock_helper_;
scoped_ptr<QuicPacketWriter> writer_;
+ scoped_ptr<QuicConnectionHelperInterface> helper_;
DISALLOW_COPY_AND_ASSIGN(MockConnection);
};
@@ -280,7 +281,7 @@ class MockSession : public QuicSession {
const IPEndPoint& peer_address,
const QuicPacketHeader& header,
const std::vector<QuicStreamFrame>& frame));
- MOCK_METHOD2(ConnectionClose, void(QuicErrorCode error, bool from_peer));
+ MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer));
MOCK_METHOD1(CreateIncomingReliableStream,
ReliableQuicStream*(QuicStreamId id));
MOCK_METHOD0(GetCryptoStream, QuicCryptoStream*());
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
index 96ea50b..8b798b4 100644
--- a/net/tools/quic/end_to_end_test.cc
+++ b/net/tools/quic/end_to_end_test.cc
@@ -133,8 +133,10 @@ class EndToEndTest : public ::testing::TestWithParam<QuicVersion> {
server_thread_->listening()->Wait();
server_address_ = IPEndPoint(server_address_.address(),
server_thread_->GetPort());
- QuicDispatcher* dispatcher = QuicServerPeer::GetDispatcher(
- server_thread_->server());
+ QuicDispatcher* dispatcher =
+ QuicServerPeer::GetDispatcher(server_thread_->server());
+ server_writer_->SetConnectionHelper(
+ QuicDispatcherPeer::GetHelper(dispatcher));
QuicDispatcherPeer::UseWriter(dispatcher, server_writer_);
server_started_ = true;
}
@@ -165,21 +167,18 @@ class EndToEndTest : public ::testing::TestWithParam<QuicVersion> {
// server_writer_->set_fake_packet_loss_percentage(loss);
}
- void SetRTT(QuicTime::Delta rtt) {
- // TODO(ianswett): For now, the RTT is entirely simulated on the client
- // side, because the server's writer does not have a ConnectionHelper.
+ void SetPacketSendDelay(QuicTime::Delta delay) {
// TODO(rtenneti): enable when we can do random packet loss tests in
// chrome's tree.
- // client_writer_->set_fake_packet_delay(rtt);
+ // client_writer_->set_fake_packet_delay(delay);
+ // server_writer_->set_fake_packet_delay(delay);
}
void SetReorderPercentage(int32 reorder) {
- // TODO(ianswett): For now, the reordering is entirely simulated on the
- // client side, because the server's writer does not have a
- // ConnectionHelper.
// TODO(rtenneti): enable when we can do random packet loss tests in
// chrome's tree.
// client_writer_->set_fake_reorder_percentage(reorder);
+ // server_writer_->set_fake_reorder_percentage(reorder);
}
IPEndPoint server_address_;
@@ -391,10 +390,11 @@ TEST_P(EndToEndTest, LargePostWithPacketLoss) {
TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) {
ASSERT_TRUE(Initialize());
- SetRTT(QuicTime::Delta::FromMilliseconds(2));
- SetReorderPercentage(30);
client_->client()->WaitForCryptoHandshakeConfirmed();
+ // Both of these must be called when the writer is not actively used.
+ SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
+ SetReorderPercentage(30);
// 1 Mb body.
string body;
diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc
index a01e3c7..b8cf6e9 100644
--- a/net/tools/quic/quic_client.cc
+++ b/net/tools/quic/quic_client.cc
@@ -38,6 +38,7 @@ QuicClient::QuicClient(IPEndPoint server_address,
server_hostname_(server_hostname),
local_port_(0),
fd_(-1),
+ helper_(CreateQuicConnectionHelper()),
initialized_(false),
packets_dropped_(0),
overflow_supported_(false),
@@ -55,6 +56,7 @@ QuicClient::QuicClient(IPEndPoint server_address,
config_(config),
local_port_(0),
fd_(-1),
+ helper_(CreateQuicConnectionHelper()),
initialized_(false),
packets_dropped_(0),
overflow_supported_(false),
@@ -159,8 +161,7 @@ bool QuicClient::StartConnect() {
session_.reset(new QuicClientSession(
server_hostname_,
config_,
- new QuicConnection(GenerateGuid(), server_address_,
- CreateQuicConnectionHelper(),
+ new QuicConnection(GenerateGuid(), server_address_, helper_.get(),
writer_.get(), false, version_),
&crypto_config_));
return session_->CryptoConnect();
diff --git a/net/tools/quic/quic_client.h b/net/tools/quic/quic_client.h
index 5637736..c8e65a1 100644
--- a/net/tools/quic/quic_client.h
+++ b/net/tools/quic/quic_client.h
@@ -183,6 +183,9 @@ class QuicClient : public EpollCallbackInterface,
// UDP socket.
int fd_;
+ // Helper to be used by created connections.
+ scoped_ptr<QuicEpollConnectionHelper> helper_;
+
// Writer used to actually send packets to the wire.
scoped_ptr<QuicPacketWriter> writer_;
diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc
index 72b14de..0ec5470 100644
--- a/net/tools/quic/quic_dispatcher.cc
+++ b/net/tools/quic/quic_dispatcher.cc
@@ -47,6 +47,7 @@ QuicDispatcher::QuicDispatcher(const QuicConfig& config,
epoll_server_(epoll_server),
fd_(fd),
write_blocked_(false),
+ helper_(new QuicEpollConnectionHelper(epoll_server_)),
writer_(new QuicDefaultPacketWriter(fd)) {
}
@@ -176,7 +177,7 @@ void QuicDispatcher::Shutdown() {
DeleteSessions();
}
-void QuicDispatcher::OnConnectionClose(QuicGuid guid, QuicErrorCode error) {
+void QuicDispatcher::OnConnectionClosed(QuicGuid guid, QuicErrorCode error) {
SessionMap::iterator it = session_map_.find(guid);
if (it == session_map_.end()) {
LOG(DFATAL) << "GUID " << guid << " does not exist in the session map. "
@@ -199,10 +200,8 @@ void QuicDispatcher::OnConnectionClose(QuicGuid guid, QuicErrorCode error) {
QuicSession* QuicDispatcher::CreateQuicSession(
QuicGuid guid,
const IPEndPoint& client_address) {
- QuicConnectionHelperInterface* helper =
- new QuicEpollConnectionHelper(epoll_server_);
QuicServerSession* session = new QuicServerSession(
- config_, new QuicConnection(guid, client_address, helper, this,
+ config_, new QuicConnection(guid, client_address, helper_.get(), this,
true, QuicVersionMax()), this);
session->InitializeSession(crypto_config_);
return session;
diff --git a/net/tools/quic/quic_dispatcher.h b/net/tools/quic/quic_dispatcher.h
index ddc98df..c20c356 100644
--- a/net/tools/quic/quic_dispatcher.h
+++ b/net/tools/quic/quic_dispatcher.h
@@ -11,6 +11,7 @@
#include <list>
#include "base/containers/hash_tables.h"
+#include "base/memory/scoped_ptr.h"
#include "net/base/ip_endpoint.h"
#include "net/base/linked_hash_map.h"
#include "net/quic/quic_blocked_writer_interface.h"
@@ -46,6 +47,8 @@ class QuicDispatcherPeer;
} // namespace test
class DeleteSessionsAlarm;
+class QuicEpollConnectionHelper;
+
class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner {
public:
// Ideally we'd have a linked_hash_set: the boolean is unused.
@@ -82,7 +85,7 @@ class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner {
void Shutdown();
// Ensure that the closed connection is cleaned up asynchronously.
- virtual void OnConnectionClose(QuicGuid guid, QuicErrorCode error) OVERRIDE;
+ virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) OVERRIDE;
// Sets the fd and creates a default packet writer with that fd.
void set_fd(int fd);
@@ -112,6 +115,7 @@ class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner {
return time_wait_list_manager_.get();
}
+ QuicEpollConnectionHelper* helper() { return helper_.get(); }
EpollServer* epoll_server() { return epoll_server_; }
private:
@@ -144,6 +148,9 @@ class QuicDispatcher : public QuicPacketWriter, public QuicSessionOwner {
// False if we have gotten a call to OnCanWrite after the last failed write.
bool write_blocked_;
+ // The helper used for all connections.
+ scoped_ptr<QuicEpollConnectionHelper> helper_;
+
// The writer to write to the socket with.
scoped_ptr<QuicPacketWriter> writer_;
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc
index 651f224..a3e6885 100644
--- a/net/tools/quic/quic_dispatcher_test.cc
+++ b/net/tools/quic/quic_dispatcher_test.cc
@@ -63,9 +63,9 @@ class MockServerConnection : public MockConnection {
: MockConnection(guid, address, fd, eps, true),
dispatcher_(dispatcher) {
}
- void UnregisterOnConnectionClose() {
+ void UnregisterOnConnectionClosed() {
LOG(ERROR) << "Unregistering " << guid();
- dispatcher_->OnConnectionClose(guid(), QUIC_NO_ERROR);
+ dispatcher_->OnConnectionClosed(guid(), QUIC_NO_ERROR);
}
private:
QuicDispatcher* dispatcher_;
@@ -81,7 +81,7 @@ QuicSession* CreateSession(QuicDispatcher* dispatcher,
*session = new MockSession(connection, true);
ON_CALL(*connection, SendConnectionClose(_)).WillByDefault(
WithoutArgs(Invoke(
- connection, &MockServerConnection::UnregisterOnConnectionClose)));
+ connection, &MockServerConnection::UnregisterOnConnectionClosed)));
EXPECT_CALL(*reinterpret_cast<MockConnection*>((*session)->connection()),
ProcessUdpPacket(_, addr, _));
@@ -207,10 +207,10 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
packet.nonce_proof = 132232;
scoped_ptr<QuicEncryptedPacket> encrypted(
QuicFramer::BuildPublicResetPacket(packet));
- EXPECT_CALL(*session1_, ConnectionClose(QUIC_PUBLIC_RESET, true)).Times(1)
+ EXPECT_CALL(*session1_, OnConnectionClosed(QUIC_PUBLIC_RESET, true)).Times(1)
.WillOnce(WithoutArgs(Invoke(
reinterpret_cast<MockServerConnection*>(session1_->connection()),
- &MockServerConnection::UnregisterOnConnectionClose)));
+ &MockServerConnection::UnregisterOnConnectionClosed)));
EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()),
ProcessUdpPacket(_, _, _))
.WillOnce(Invoke(
diff --git a/net/tools/quic/quic_epoll_connection_helper_test.cc b/net/tools/quic/quic_epoll_connection_helper_test.cc
index e572259..df34743 100644
--- a/net/tools/quic/quic_epoll_connection_helper_test.cc
+++ b/net/tools/quic/quic_epoll_connection_helper_test.cc
@@ -85,8 +85,8 @@ class QuicEpollConnectionHelperTest : public ::testing::Test {
: guid_(42),
framer_(QuicVersionMax(), QuicTime::Zero(), false),
send_algorithm_(new testing::StrictMock<MockSendAlgorithm>),
- helper_(new QuicEpollConnectionHelper(&epoll_server_)),
- connection_(guid_, IPEndPoint(), helper_, &writer_),
+ helper_(&epoll_server_),
+ connection_(guid_, IPEndPoint(), &helper_, &writer_),
frame_(3, false, 0, kData) {
connection_.set_visitor(&visitor_);
connection_.SetSendAlgorithm(send_algorithm_);
@@ -122,7 +122,7 @@ class QuicEpollConnectionHelperTest : public ::testing::Test {
MockEpollServer epoll_server_;
testing::StrictMock<MockSendAlgorithm>* send_algorithm_;
- QuicEpollConnectionHelper* helper_;
+ QuicEpollConnectionHelper helper_;
TestWriter writer_;
TestConnection connection_;
testing::StrictMock<MockConnectionVisitor> visitor_;
@@ -165,7 +165,8 @@ TEST_F(QuicEpollConnectionHelperTest, InitialTimeout) {
HAS_RETRANSMITTABLE_DATA));
EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillOnce(
Return(QuicTime::Delta::FromMicroseconds(1)));
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, !kFromPeer));
+ EXPECT_CALL(visitor_,
+ OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, !kFromPeer));
epoll_server_.WaitForEventsAndExecuteCallbacks();
EXPECT_FALSE(connection_.connected());
EXPECT_EQ(kDefaultInitialTimeoutSecs * 1000000, epoll_server_.NowInUsec());
@@ -191,7 +192,8 @@ TEST_F(QuicEpollConnectionHelperTest, TimeoutAfterSend) {
EXPECT_EQ(kDefaultInitialTimeoutSecs * 1000000, epoll_server_.NowInUsec());
// This time, we should time out.
- EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, !kFromPeer));
+ EXPECT_CALL(visitor_,
+ OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, !kFromPeer));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2, _, NOT_RETRANSMISSION,
HAS_RETRANSMITTABLE_DATA));
EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillOnce(
diff --git a/net/tools/quic/quic_server_session.cc b/net/tools/quic/quic_server_session.cc
index 7ec991c..bea957c 100644
--- a/net/tools/quic/quic_server_session.cc
+++ b/net/tools/quic/quic_server_session.cc
@@ -32,9 +32,10 @@ QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream(
return new QuicCryptoServerStream(crypto_config, this);
}
-void QuicServerSession::ConnectionClose(QuicErrorCode error, bool from_peer) {
- QuicSession::ConnectionClose(error, from_peer);
- owner_->OnConnectionClose(connection()->guid(), error);
+void QuicServerSession::OnConnectionClosed(QuicErrorCode error,
+ bool from_peer) {
+ QuicSession::OnConnectionClosed(error, from_peer);
+ owner_->OnConnectionClosed(connection()->guid(), error);
}
bool QuicServerSession::ShouldCreateIncomingReliableStream(QuicStreamId id) {
diff --git a/net/tools/quic/quic_server_session.h b/net/tools/quic/quic_server_session.h
index 2f03137..1a5bfa3 100644
--- a/net/tools/quic/quic_server_session.h
+++ b/net/tools/quic/quic_server_session.h
@@ -36,7 +36,7 @@ class QuicSessionOwner {
public:
virtual ~QuicSessionOwner() {}
- virtual void OnConnectionClose(QuicGuid guid, QuicErrorCode error) = 0;
+ virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) = 0;
};
class QuicServerSession : public QuicSession {
@@ -46,7 +46,7 @@ class QuicServerSession : public QuicSession {
QuicSessionOwner* owner);
// Override the base class to notify the owner of the connection close.
- virtual void ConnectionClose(QuicErrorCode error, bool from_peer) OVERRIDE;
+ virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
virtual ~QuicServerSession();
diff --git a/net/tools/quic/test_tools/quic_dispatcher_peer.cc b/net/tools/quic/test_tools/quic_dispatcher_peer.cc
index 344784b..c96eafd 100644
--- a/net/tools/quic/test_tools/quic_dispatcher_peer.cc
+++ b/net/tools/quic/test_tools/quic_dispatcher_peer.cc
@@ -36,6 +36,12 @@ QuicPacketWriter* QuicDispatcherPeer::GetWriter(QuicDispatcher* dispatcher) {
return dispatcher->writer_.get();
}
+// static
+QuicEpollConnectionHelper* QuicDispatcherPeer::GetHelper(
+ QuicDispatcher* dispatcher) {
+ return dispatcher->helper_.get();
+}
+
} // namespace test
} // namespace tools
} // namespace net
diff --git a/net/tools/quic/test_tools/quic_dispatcher_peer.h b/net/tools/quic/test_tools/quic_dispatcher_peer.h
index 1e38bbe..f463453 100644
--- a/net/tools/quic/test_tools/quic_dispatcher_peer.h
+++ b/net/tools/quic/test_tools/quic_dispatcher_peer.h
@@ -24,6 +24,8 @@ class QuicDispatcherPeer {
net::test::QuicTestWriter* writer);
static QuicPacketWriter* GetWriter(QuicDispatcher* dispatcher);
+
+ static QuicEpollConnectionHelper* GetHelper(QuicDispatcher* dispatcher);
};
} // namespace test
diff --git a/net/tools/quic/test_tools/quic_test_utils.cc b/net/tools/quic/test_tools/quic_test_utils.cc
index 01e5bb7..7222e1e 100644
--- a/net/tools/quic/test_tools/quic_test_utils.cc
+++ b/net/tools/quic/test_tools/quic_test_utils.cc
@@ -27,7 +27,8 @@ MockConnection::MockConnection(QuicGuid guid,
new QuicDefaultPacketWriter(fd), is_server,
QuicVersionMax()),
has_mock_helper_(false),
- writer_(net::test::QuicConnectionPeer::GetWriter(this)) {
+ writer_(net::test::QuicConnectionPeer::GetWriter(this)),
+ helper_(helper()) {
}
MockConnection::MockConnection(QuicGuid guid,
@@ -37,7 +38,8 @@ MockConnection::MockConnection(QuicGuid guid,
new testing::NiceMock<MockPacketWriter>(),
is_server, QuicVersionMax()),
has_mock_helper_(true),
- writer_(net::test::QuicConnectionPeer::GetWriter(this)) {
+ writer_(net::test::QuicConnectionPeer::GetWriter(this)),
+ helper_(helper()) {
}
MockConnection::MockConnection(QuicGuid guid,
diff --git a/net/tools/quic/test_tools/quic_test_utils.h b/net/tools/quic/test_tools/quic_test_utils.h
index c3f5e4e..3ea1283 100644
--- a/net/tools/quic/test_tools/quic_test_utils.h
+++ b/net/tools/quic/test_tools/quic_test_utils.h
@@ -87,6 +87,7 @@ class MockConnection : public QuicConnection {
private:
const bool has_mock_helper_;
scoped_ptr<QuicPacketWriter> writer_;
+ scoped_ptr<QuicConnectionHelperInterface> helper_;
DISALLOW_COPY_AND_ASSIGN(MockConnection);
};
@@ -129,7 +130,7 @@ class MockQuicSessionOwner : public QuicSessionOwner {
public:
MockQuicSessionOwner();
~MockQuicSessionOwner();
- MOCK_METHOD2(OnConnectionClose, void(QuicGuid guid, QuicErrorCode error));
+ MOCK_METHOD2(OnConnectionClosed, void(QuicGuid guid, QuicErrorCode error));
};
class TestDecompressorVisitor : public QuicSpdyDecompressor::Visitor {