OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_QUIC_CHROMIUM_MOCK_QUIC_DATA_H_ | 5 #ifndef NET_QUIC_CHROMIUM_MOCK_QUIC_DATA_H_ |
6 #define NET_QUIC_CHROMIUM_MOCK_QUIC_DATA_H_ | 6 #define NET_QUIC_CHROMIUM_MOCK_QUIC_DATA_H_ |
7 | 7 |
8 #include "net/quic/core/quic_packets.h" | 8 #include "net/quic/core/quic_packets.h" |
9 #include "net/socket/socket_test_util.h" | 9 #include "net/socket/socket_test_util.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 void AddRead(std::unique_ptr<QuicEncryptedPacket> packet); | 31 void AddRead(std::unique_ptr<QuicEncryptedPacket> packet); |
32 | 32 |
33 // Adds a read at the next sequence number which will return |rv| either | 33 // Adds a read at the next sequence number which will return |rv| either |
34 // synchronously or asynchronously based on |mode|. | 34 // synchronously or asynchronously based on |mode|. |
35 void AddRead(IoMode mode, int rv); | 35 void AddRead(IoMode mode, int rv); |
36 | 36 |
37 // Adds a synchronous write at the next sequence number which will write | 37 // Adds a synchronous write at the next sequence number which will write |
38 // |packet|. | 38 // |packet|. |
39 void AddWrite(std::unique_ptr<QuicEncryptedPacket> packet); | 39 void AddWrite(std::unique_ptr<QuicEncryptedPacket> packet); |
40 | 40 |
| 41 // Adds an asynchronous write at the next sequence number which will write |
| 42 // |packet|. |
| 43 void AddAsyncWrite(std::unique_ptr<QuicEncryptedPacket> packet); |
| 44 |
41 // Adds a write at the next sequence number which will return |rv| either | 45 // Adds a write at the next sequence number which will return |rv| either |
42 // synchronously or asynchronously based on |mode|. | 46 // synchronously or asynchronously based on |mode|. |
43 void AddWrite(IoMode mode, int rv); | 47 void AddWrite(IoMode mode, int rv); |
44 | 48 |
45 // Adds the reads and writes to |factory|. | 49 // Adds the reads and writes to |factory|. |
46 void AddSocketDataToFactory(MockClientSocketFactory* factory); | 50 void AddSocketDataToFactory(MockClientSocketFactory* factory); |
47 | 51 |
48 // Returns true if all reads have been consumed. | 52 // Returns true if all reads have been consumed. |
49 bool AllReadDataConsumed(); | 53 bool AllReadDataConsumed(); |
50 | 54 |
51 // Returns true if all writes have been consumed. | 55 // Returns true if all writes have been consumed. |
52 bool AllWriteDataConsumed(); | 56 bool AllWriteDataConsumed(); |
53 | 57 |
54 // Resumes I/O after it is paused. | 58 // Resumes I/O after it is paused. |
55 void Resume(); | 59 void Resume(); |
56 | 60 |
57 private: | 61 private: |
58 std::vector<std::unique_ptr<QuicEncryptedPacket>> packets_; | 62 std::vector<std::unique_ptr<QuicEncryptedPacket>> packets_; |
59 std::unique_ptr<MockConnect> connect_; | 63 std::unique_ptr<MockConnect> connect_; |
60 std::vector<MockWrite> writes_; | 64 std::vector<MockWrite> writes_; |
61 std::vector<MockRead> reads_; | 65 std::vector<MockRead> reads_; |
62 size_t sequence_number_; | 66 size_t sequence_number_; |
63 std::unique_ptr<SequencedSocketData> socket_data_; | 67 std::unique_ptr<SequencedSocketData> socket_data_; |
64 }; | 68 }; |
65 | 69 |
66 } // namespace test | 70 } // namespace test |
67 } // namespace net | 71 } // namespace net |
68 | 72 |
69 #endif // NET_QUIC_CHROMIUM_MOCK_QUIC_DATA_H_ | 73 #endif // NET_QUIC_CHROMIUM_MOCK_QUIC_DATA_H_ |
OLD | NEW |