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 #include "net/tools/quic/test_tools/quic_test_utils.h" | 5 #include "net/tools/quic/test_tools/quic_test_utils.h" |
6 | 6 |
7 #include "net/quic/quic_connection.h" | 7 #include "net/quic/quic_connection.h" |
8 #include "net/quic/test_tools/quic_connection_peer.h" | 8 #include "net/quic/test_tools/quic_connection_peer.h" |
9 #include "net/quic/test_tools/quic_test_utils.h" | 9 #include "net/quic/test_tools/quic_test_utils.h" |
10 #include "net/tools/quic/quic_epoll_connection_helper.h" | 10 #include "net/tools/quic/quic_epoll_connection_helper.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Add enough missing packets to get num_nack_ranges nack ranges. | 90 // Add enough missing packets to get num_nack_ranges nack ranges. |
91 for (QuicPacketSequenceNumber i = 1; i < 2 * num_nack_ranges; i += 2) { | 91 for (QuicPacketSequenceNumber i = 1; i < 2 * num_nack_ranges; i += 2) { |
92 ack.missing_packets.insert(least_unacked + i); | 92 ack.missing_packets.insert(least_unacked + i); |
93 } | 93 } |
94 return ack; | 94 return ack; |
95 } | 95 } |
96 | 96 |
97 TestSession::TestSession(QuicConnection* connection, | 97 TestSession::TestSession(QuicConnection* connection, |
98 const QuicConfig& config) | 98 const QuicConfig& config) |
99 : QuicSession(connection, config), | 99 : QuicSession(connection, config), |
100 crypto_stream_(NULL) { | 100 crypto_stream_(nullptr) { |
101 InitializeSession(); | 101 InitializeSession(); |
102 } | 102 } |
103 | 103 |
104 TestSession::~TestSession() {} | 104 TestSession::~TestSession() {} |
105 | 105 |
106 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { | 106 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { |
107 crypto_stream_ = stream; | 107 crypto_stream_ = stream; |
108 } | 108 } |
109 | 109 |
110 QuicCryptoStream* TestSession::GetCryptoStream() { | 110 QuicCryptoStream* TestSession::GetCryptoStream() { |
(...skipping 11 matching lines...) Expand all Loading... |
122 | 122 |
123 MockQuicServerSessionVisitor::~MockQuicServerSessionVisitor() { | 123 MockQuicServerSessionVisitor::~MockQuicServerSessionVisitor() { |
124 } | 124 } |
125 | 125 |
126 MockAckNotifierDelegate::MockAckNotifierDelegate() { | 126 MockAckNotifierDelegate::MockAckNotifierDelegate() { |
127 } | 127 } |
128 | 128 |
129 MockAckNotifierDelegate::~MockAckNotifierDelegate() { | 129 MockAckNotifierDelegate::~MockAckNotifierDelegate() { |
130 } | 130 } |
131 | 131 |
132 TestWriterFactory::TestWriterFactory() : current_writer_(NULL) {} | 132 TestWriterFactory::TestWriterFactory() : current_writer_(nullptr) {} |
133 TestWriterFactory::~TestWriterFactory() {} | 133 TestWriterFactory::~TestWriterFactory() {} |
134 | 134 |
135 QuicPacketWriter* TestWriterFactory::Create(QuicPacketWriter* writer, | 135 QuicPacketWriter* TestWriterFactory::Create(QuicPacketWriter* writer, |
136 QuicConnection* connection) { | 136 QuicConnection* connection) { |
137 return new PerConnectionPacketWriter(this, writer, connection); | 137 return new PerConnectionPacketWriter(this, writer, connection); |
138 } | 138 } |
139 | 139 |
140 void TestWriterFactory::OnPacketSent(WriteResult result) { | 140 void TestWriterFactory::OnPacketSent(WriteResult result) { |
141 if (current_writer_ != NULL && result.status == WRITE_STATUS_ERROR) { | 141 if (current_writer_ != nullptr && result.status == WRITE_STATUS_ERROR) { |
142 current_writer_->connection()->OnWriteError(result.error_code); | 142 current_writer_->connection()->OnWriteError(result.error_code); |
143 current_writer_ = NULL; | 143 current_writer_ = nullptr; |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 void TestWriterFactory::Unregister(PerConnectionPacketWriter* writer) { | 147 void TestWriterFactory::Unregister(PerConnectionPacketWriter* writer) { |
148 if (current_writer_ == writer) { | 148 if (current_writer_ == writer) { |
149 current_writer_ = NULL; | 149 current_writer_ = nullptr; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 TestWriterFactory::PerConnectionPacketWriter::PerConnectionPacketWriter( | 153 TestWriterFactory::PerConnectionPacketWriter::PerConnectionPacketWriter( |
154 TestWriterFactory* factory, | 154 TestWriterFactory* factory, |
155 QuicPacketWriter* writer, | 155 QuicPacketWriter* writer, |
156 QuicConnection* connection) | 156 QuicConnection* connection) |
157 : QuicPerConnectionPacketWriter(writer, connection), | 157 : QuicPerConnectionPacketWriter(writer, connection), |
158 factory_(factory) { | 158 factory_(factory) { |
159 } | 159 } |
160 | 160 |
161 TestWriterFactory::PerConnectionPacketWriter::~PerConnectionPacketWriter() { | 161 TestWriterFactory::PerConnectionPacketWriter::~PerConnectionPacketWriter() { |
162 factory_->Unregister(this); | 162 factory_->Unregister(this); |
163 } | 163 } |
164 | 164 |
165 WriteResult TestWriterFactory::PerConnectionPacketWriter::WritePacket( | 165 WriteResult TestWriterFactory::PerConnectionPacketWriter::WritePacket( |
166 const char* buffer, | 166 const char* buffer, |
167 size_t buf_len, | 167 size_t buf_len, |
168 const IPAddressNumber& self_address, | 168 const IPAddressNumber& self_address, |
169 const IPEndPoint& peer_address) { | 169 const IPEndPoint& peer_address) { |
170 // A DCHECK(factory_current_writer_ == NULL) would be wrong here -- this class | 170 // A DCHECK(factory_current_writer_ == nullptr) would be wrong here -- this |
171 // may be used in a setting where connection()->OnPacketSent() is called in a | 171 // class may be used in a setting where connection()->OnPacketSent() is called |
172 // different way, so TestWriterFactory::OnPacketSent might never be called. | 172 // in a different way, so TestWriterFactory::OnPacketSent might never be |
| 173 // called. |
173 factory_->current_writer_ = this; | 174 factory_->current_writer_ = this; |
174 return QuicPerConnectionPacketWriter::WritePacket(buffer, | 175 return QuicPerConnectionPacketWriter::WritePacket(buffer, |
175 buf_len, | 176 buf_len, |
176 self_address, | 177 self_address, |
177 peer_address); | 178 peer_address); |
178 } | 179 } |
179 | 180 |
180 } // namespace test | 181 } // namespace test |
181 } // namespace tools | 182 } // namespace tools |
182 } // namespace net | 183 } // namespace net |
OLD | NEW |