From ed26f172b96ea37a5db344fbf0be31a00eb6e757 Mon Sep 17 00:00:00 2001 From: "wtc@chromium.org" Date: Sat, 22 Dec 2012 01:23:57 +0000 Subject: In the comment for WritePacketToWire, change "errno" to "the error code" because Chromium does not use errno directly. Have WritePacketToWire set *error to 0 on success, and set *error to the Chromium error code and return -1 on failure. Merge internal CL: 40315480 R=rch@chromium.org BUG=none TEST=net_unittests Review URL: https://codereview.chromium.org/11668012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174485 0039d316-1c4b-4281-b951-d872f2087c98 --- net/quic/quic_connection.h | 5 +++-- net/quic/quic_connection_helper.cc | 13 ++++++++++--- net/quic/quic_connection_helper_test.cc | 5 ++--- net/quic/quic_connection_test.cc | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'net') diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h index d13fc5e..442e200 100644 --- a/net/quic/quic_connection.h +++ b/net/quic/quic_connection.h @@ -83,8 +83,9 @@ class NET_EXPORT_PRIVATE QuicConnectionHelperInterface { virtual QuicRandom* GetRandomGenerator() = 0; // Sends the packet out to the peer, possibly simulating packet - // loss if FLAGS_fake_packet_loss_percentage is set. If the write failed - // errno will be copied to |*error|. + // loss if FLAGS_fake_packet_loss_percentage is set. If the write + // succeeded, returns the number of bytes written. If the write + // failed, returns -1 and the error code will be copied to |*error|. virtual int WritePacketToWire(const QuicEncryptedPacket& packet, int* error) = 0; diff --git a/net/quic/quic_connection_helper.cc b/net/quic/quic_connection_helper.cc index e150017..16d2782 100644 --- a/net/quic/quic_connection_helper.cc +++ b/net/quic/quic_connection_helper.cc @@ -55,9 +55,16 @@ int QuicConnectionHelper::WritePacketToWire( scoped_refptr buf( new StringIOBuffer(std::string(packet.data(), packet.length()))); - return socket_->Write(buf, packet.length(), - base::Bind(&QuicConnectionHelper::OnWriteComplete, - weak_factory_.GetWeakPtr())); + int rv = socket_->Write(buf, packet.length(), + base::Bind(&QuicConnectionHelper::OnWriteComplete, + weak_factory_.GetWeakPtr())); + if (rv >= 0) { + *error = 0; + } else { + *error = rv; + rv = -1; + } + return rv; } void QuicConnectionHelper::SetResendAlarm( diff --git a/net/quic/quic_connection_helper_test.cc b/net/quic/quic_connection_helper_test.cc index 9e7404f1..5557e8a 100644 --- a/net/quic/quic_connection_helper_test.cc +++ b/net/quic/quic_connection_helper_test.cc @@ -279,9 +279,8 @@ TEST_F(QuicConnectionHelperTest, WritePacketToWireAsync) { EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); int error = 0; - EXPECT_EQ(ERR_IO_PENDING, - helper_->WritePacketToWire(*GetWrite(0), &error)); - EXPECT_EQ(0, error); + EXPECT_EQ(-1, helper_->WritePacketToWire(*GetWrite(0), &error)); + EXPECT_EQ(ERR_IO_PENDING, error); MessageLoop::current()->RunUntilIdle(); EXPECT_TRUE(AtEof()); } diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc index 8c22ecc..c8e54ad 100644 --- a/net/quic/quic_connection_test.cc +++ b/net/quic/quic_connection_test.cc @@ -118,6 +118,7 @@ class TestConnectionHelper : public QuicConnectionHelperInterface { *error = ERR_IO_PENDING; return -1; } + *error = 0; return packet.length(); } -- cgit v1.1