| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/p2p/quic/reliablequicstream.h" | 11 #include "webrtc/p2p/quic/reliablequicstream.h" |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "net/base/ip_address_number.h" | 15 #include "net/base/ip_address_number.h" |
| 16 #include "net/quic/quic_connection.h" | 16 #include "net/quic/quic_connection.h" |
| 17 #include "net/quic/quic_protocol.h" | 17 #include "net/quic/quic_protocol.h" |
| 18 #include "net/quic/quic_session.h" | 18 #include "net/quic/quic_session.h" |
| 19 #include "webrtc/base/buffer.h" | 19 #include "webrtc/base/buffer.h" |
| 20 #include "webrtc/base/gunit.h" | 20 #include "webrtc/base/gunit.h" |
| 21 #include "webrtc/base/sigslot.h" | 21 #include "webrtc/base/sigslot.h" |
| 22 #include "webrtc/base/stream.h" | 22 #include "webrtc/base/stream.h" |
| 23 #include "webrtc/p2p/quic/quicconnectionhelper.h" | 23 #include "webrtc/p2p/quic/quicconnectionhelper.h" |
| 24 | 24 |
| 25 using cricket::QuicConnectionHelper; | 25 using cricket::QuicConnectionHelper; |
| 26 using cricket::ReliableQuicStream; | 26 using cricket::ReliableQuicStream; |
| 27 | 27 |
| 28 using net::FecProtection; | |
| 29 using net::IPAddress; | 28 using net::IPAddress; |
| 30 using net::IPEndPoint; | 29 using net::IPEndPoint; |
| 31 using net::PerPacketOptions; | 30 using net::PerPacketOptions; |
| 32 using net::Perspective; | 31 using net::Perspective; |
| 33 using net::QuicAckListenerInterface; | 32 using net::QuicAckListenerInterface; |
| 34 using net::QuicConfig; | 33 using net::QuicConfig; |
| 35 using net::QuicConnection; | 34 using net::QuicConnection; |
| 36 using net::QuicConsumedData; | 35 using net::QuicConsumedData; |
| 37 using net::QuicCryptoStream; | 36 using net::QuicCryptoStream; |
| 38 using net::QuicErrorCode; | 37 using net::QuicErrorCode; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 58 const QuicConfig& config, | 57 const QuicConfig& config, |
| 59 std::string* write_buffer) | 58 std::string* write_buffer) |
| 60 : QuicSession(connection, config), write_buffer_(write_buffer) {} | 59 : QuicSession(connection, config), write_buffer_(write_buffer) {} |
| 61 | 60 |
| 62 // Writes outgoing data from ReliableQuicStream to a string. | 61 // Writes outgoing data from ReliableQuicStream to a string. |
| 63 QuicConsumedData WritevData( | 62 QuicConsumedData WritevData( |
| 64 QuicStreamId id, | 63 QuicStreamId id, |
| 65 QuicIOVector iovector, | 64 QuicIOVector iovector, |
| 66 QuicStreamOffset offset, | 65 QuicStreamOffset offset, |
| 67 bool fin, | 66 bool fin, |
| 68 FecProtection fec_protection, | |
| 69 QuicAckListenerInterface* ack_notifier_delegate) override { | 67 QuicAckListenerInterface* ack_notifier_delegate) override { |
| 70 if (!writable_) { | 68 if (!writable_) { |
| 71 return QuicConsumedData(0, false); | 69 return QuicConsumedData(0, false); |
| 72 } | 70 } |
| 73 | 71 |
| 74 const char* data = reinterpret_cast<const char*>(iovector.iov->iov_base); | 72 const char* data = reinterpret_cast<const char*>(iovector.iov->iov_base); |
| 75 size_t len = iovector.total_length; | 73 size_t len = iovector.total_length; |
| 76 write_buffer_->append(data, len); | 74 write_buffer_->append(data, len); |
| 77 return QuicConsumedData(len, false); | 75 return QuicConsumedData(len, false); |
| 78 } | 76 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 EXPECT_EQ("Hello", read_buffer_); | 247 EXPECT_EQ("Hello", read_buffer_); |
| 250 } | 248 } |
| 251 | 249 |
| 252 // Test that closing the stream results in a callback. | 250 // Test that closing the stream results in a callback. |
| 253 TEST_F(ReliableQuicStreamTest, CloseStream) { | 251 TEST_F(ReliableQuicStreamTest, CloseStream) { |
| 254 CreateReliableQuicStream(); | 252 CreateReliableQuicStream(); |
| 255 EXPECT_FALSE(closed_); | 253 EXPECT_FALSE(closed_); |
| 256 stream_->OnClose(); | 254 stream_->OnClose(); |
| 257 EXPECT_TRUE(closed_); | 255 EXPECT_TRUE(closed_); |
| 258 } | 256 } |
| OLD | NEW |