summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
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();
}