| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 class TestSession : public QuicSession { | 97 class TestSession : public QuicSession { |
| 98 public: | 98 public: |
| 99 TestSession(QuicConnection* connection, const QuicConfig& config); | 99 TestSession(QuicConnection* connection, const QuicConfig& config); |
| 100 virtual ~TestSession(); | 100 virtual ~TestSession(); |
| 101 | 101 |
| 102 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); | 102 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); |
| 103 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); | 103 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); |
| 104 | 104 |
| 105 void SetCryptoStream(QuicCryptoStream* stream); | 105 void SetCryptoStream(QuicCryptoStream* stream); |
| 106 | 106 |
| 107 virtual QuicCryptoStream* GetCryptoStream() OVERRIDE; | 107 virtual QuicCryptoStream* GetCryptoStream() override; |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 QuicCryptoStream* crypto_stream_; | 110 QuicCryptoStream* crypto_stream_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(TestSession); | 112 DISALLOW_COPY_AND_ASSIGN(TestSession); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 class MockPacketWriter : public QuicPacketWriter { | 115 class MockPacketWriter : public QuicPacketWriter { |
| 116 public: | 116 public: |
| 117 MockPacketWriter(); | 117 MockPacketWriter(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual ~TestWriterFactory(); |
| 170 | 170 |
| 171 virtual QuicPacketWriter* Create(QuicPacketWriter* writer, | 171 virtual 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 virtual ~PerConnectionPacketWriter(); |
| 185 | 185 |
| 186 virtual WriteResult WritePacket( | 186 virtual WriteResult WritePacket( |
| 187 const char* buffer, | 187 const char* buffer, |
| 188 size_t buf_len, | 188 size_t buf_len, |
| 189 const IPAddressNumber& self_address, | 189 const IPAddressNumber& self_address, |
| 190 const IPEndPoint& peer_address) OVERRIDE; | 190 const IPEndPoint& peer_address) override; |
| 191 | 191 |
| 192 private: | 192 private: |
| 193 TestWriterFactory* factory_; | 193 TestWriterFactory* factory_; |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 // If an asynchronous write is happening and |writer| gets deleted, this | 196 // If an asynchronous write is happening and |writer| gets deleted, this |
| 197 // clears the pointer to it to prevent use-after-free. | 197 // clears the pointer to it to prevent use-after-free. |
| 198 void Unregister(PerConnectionPacketWriter* writer); | 198 void Unregister(PerConnectionPacketWriter* writer); |
| 199 | 199 |
| 200 PerConnectionPacketWriter* current_writer_; | 200 PerConnectionPacketWriter* current_writer_; |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 } // namespace test | 203 } // namespace test |
| 204 } // namespace tools | 204 } // namespace tools |
| 205 } // namespace net | 205 } // namespace net |
| 206 | 206 |
| 207 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 207 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |