summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-22 01:23:57 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-22 01:23:57 +0000
commited26f172b96ea37a5db344fbf0be31a00eb6e757 (patch)
tree68cc43162d2d8094a0fee4f26eb1e141883ac6f5 /net
parentd336b36a67ec5b68c4100b0d211d61068b5440c6 (diff)
downloadchromium_src-ed26f172b96ea37a5db344fbf0be31a00eb6e757.zip
chromium_src-ed26f172b96ea37a5db344fbf0be31a00eb6e757.tar.gz
chromium_src-ed26f172b96ea37a5db344fbf0be31a00eb6e757.tar.bz2
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
Diffstat (limited to 'net')
-rw-r--r--net/quic/quic_connection.h5
-rw-r--r--net/quic/quic_connection_helper.cc13
-rw-r--r--net/quic/quic_connection_helper_test.cc5
-rw-r--r--net/quic/quic_connection_test.cc1
4 files changed, 16 insertions, 8 deletions
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<StringIOBuffer> 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();
}