OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
6 | 6 |
7 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
8 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); | 160 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); |
161 }; | 161 }; |
162 | 162 |
163 // Creates per-connection packet writers that register themselves with the | 163 // Creates per-connection packet writers that register themselves with the |
164 // TestWriterFactory on each write so that TestWriterFactory::OnPacketSent can | 164 // TestWriterFactory on each write so that TestWriterFactory::OnPacketSent can |
165 // be routed to the appropriate QuicConnection. | 165 // be routed to the appropriate QuicConnection. |
166 class TestWriterFactory : public QuicDispatcher::PacketWriterFactory { | 166 class TestWriterFactory : public QuicDispatcher::PacketWriterFactory { |
167 public: | 167 public: |
168 TestWriterFactory(); | 168 TestWriterFactory(); |
169 virtual ~TestWriterFactory(); | 169 ~TestWriterFactory() override; |
170 | 170 |
171 virtual QuicPacketWriter* Create(QuicPacketWriter* writer, | 171 QuicPacketWriter* Create(QuicPacketWriter* writer, |
172 QuicConnection* connection) override; | 172 QuicConnection* connection) override; |
173 | 173 |
174 // Calls OnPacketSent on the last QuicConnection to write through one of the | 174 // Calls OnPacketSent on the last QuicConnection to write through one of the |
175 // packet writers created by this factory. | 175 // packet writers created by this factory. |
176 void OnPacketSent(WriteResult result); | 176 void OnPacketSent(WriteResult result); |
177 | 177 |
178 private: | 178 private: |
179 class PerConnectionPacketWriter : public QuicPerConnectionPacketWriter { | 179 class PerConnectionPacketWriter : public QuicPerConnectionPacketWriter { |
180 public: | 180 public: |
181 PerConnectionPacketWriter(TestWriterFactory* factory, | 181 PerConnectionPacketWriter(TestWriterFactory* factory, |
182 QuicPacketWriter* writer, | 182 QuicPacketWriter* writer, |
183 QuicConnection* connection); | 183 QuicConnection* connection); |
184 virtual ~PerConnectionPacketWriter(); | 184 ~PerConnectionPacketWriter() override; |
185 | 185 |
186 virtual WriteResult WritePacket( | 186 WriteResult WritePacket(const char* buffer, |
187 const char* buffer, | 187 size_t buf_len, |
188 size_t buf_len, | 188 const IPAddressNumber& self_address, |
189 const IPAddressNumber& self_address, | 189 const IPEndPoint& peer_address) override; |
190 const IPEndPoint& peer_address) override; | |
191 | 190 |
192 private: | 191 private: |
193 TestWriterFactory* factory_; | 192 TestWriterFactory* factory_; |
194 }; | 193 }; |
195 | 194 |
196 // If an asynchronous write is happening and |writer| gets deleted, this | 195 // If an asynchronous write is happening and |writer| gets deleted, this |
197 // clears the pointer to it to prevent use-after-free. | 196 // clears the pointer to it to prevent use-after-free. |
198 void Unregister(PerConnectionPacketWriter* writer); | 197 void Unregister(PerConnectionPacketWriter* writer); |
199 | 198 |
200 PerConnectionPacketWriter* current_writer_; | 199 PerConnectionPacketWriter* current_writer_; |
201 }; | 200 }; |
202 | 201 |
203 } // namespace test | 202 } // namespace test |
204 } // namespace tools | 203 } // namespace tools |
205 } // namespace net | 204 } // namespace net |
206 | 205 |
207 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 206 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |