Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: net/quic/test_tools/simple_quic_framer.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/quic/test_tools/simple_quic_framer.h" 5 #include "net/quic/test_tools/simple_quic_framer.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/crypto/crypto_framer.h" 8 #include "net/quic/crypto/crypto_framer.h"
9 #include "net/quic/crypto/quic_decrypter.h" 9 #include "net/quic/crypto/quic_decrypter.h"
10 #include "net/quic/crypto/quic_encrypter.h" 10 #include "net/quic/crypto/quic_encrypter.h"
11 11
12 using base::StringPiece; 12 using base::StringPiece;
13 using std::string; 13 using std::string;
14 using std::vector; 14 using std::vector;
15 15
16 namespace net { 16 namespace net {
17 namespace test { 17 namespace test {
18 18
19 class SimpleFramerVisitor : public QuicFramerVisitorInterface { 19 class SimpleFramerVisitor : public QuicFramerVisitorInterface {
20 public: 20 public:
21 SimpleFramerVisitor() 21 SimpleFramerVisitor() : error_(QUIC_NO_ERROR) {}
22 : error_(QUIC_NO_ERROR) {
23 }
24 22
25 virtual ~SimpleFramerVisitor() { 23 virtual ~SimpleFramerVisitor() { STLDeleteElements(&stream_data_); }
26 STLDeleteElements(&stream_data_);
27 }
28 24
29 virtual void OnError(QuicFramer* framer) OVERRIDE { 25 virtual void OnError(QuicFramer* framer) OVERRIDE {
30 error_ = framer->error(); 26 error_ = framer->error();
31 } 27 }
32 28
33 virtual bool OnProtocolVersionMismatch(QuicVersion version) OVERRIDE { 29 virtual bool OnProtocolVersionMismatch(QuicVersion version) OVERRIDE {
34 return false; 30 return false;
35 } 31 }
36 32
37 virtual void OnPacket() OVERRIDE {} 33 virtual void OnPacket() OVERRIDE {}
38 virtual void OnPublicResetPacket( 34 virtual void OnPublicResetPacket(
39 const QuicPublicResetPacket& packet) OVERRIDE { 35 const QuicPublicResetPacket& packet) OVERRIDE {
40 public_reset_packet_.reset(new QuicPublicResetPacket(packet)); 36 public_reset_packet_.reset(new QuicPublicResetPacket(packet));
41 } 37 }
42 virtual void OnVersionNegotiationPacket( 38 virtual void OnVersionNegotiationPacket(
43 const QuicVersionNegotiationPacket& packet) OVERRIDE { 39 const QuicVersionNegotiationPacket& packet) OVERRIDE {
44 version_negotiation_packet_.reset( 40 version_negotiation_packet_.reset(new QuicVersionNegotiationPacket(packet));
45 new QuicVersionNegotiationPacket(packet));
46 } 41 }
47 virtual void OnRevivedPacket() OVERRIDE {} 42 virtual void OnRevivedPacket() OVERRIDE {}
48 43
49 virtual bool OnUnauthenticatedPublicHeader( 44 virtual bool OnUnauthenticatedPublicHeader(
50 const QuicPacketPublicHeader& header) OVERRIDE { 45 const QuicPacketPublicHeader& header) OVERRIDE {
51 return true; 46 return true;
52 } 47 }
53 virtual bool OnUnauthenticatedHeader( 48 virtual bool OnUnauthenticatedHeader(
54 const QuicPacketHeader& header) OVERRIDE { 49 const QuicPacketHeader& header) OVERRIDE {
55 return true; 50 return true;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 139 }
145 const vector<QuicRstStreamFrame>& rst_stream_frames() const { 140 const vector<QuicRstStreamFrame>& rst_stream_frames() const {
146 return rst_stream_frames_; 141 return rst_stream_frames_;
147 } 142 }
148 const vector<QuicStreamFrame>& stream_frames() const { 143 const vector<QuicStreamFrame>& stream_frames() const {
149 return stream_frames_; 144 return stream_frames_;
150 } 145 }
151 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const { 146 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const {
152 return stop_waiting_frames_; 147 return stop_waiting_frames_;
153 } 148 }
154 const vector<QuicPingFrame>& ping_frames() const { 149 const vector<QuicPingFrame>& ping_frames() const { return ping_frames_; }
155 return ping_frames_; 150 const QuicFecData& fec_data() const { return fec_data_; }
156 }
157 const QuicFecData& fec_data() const {
158 return fec_data_;
159 }
160 const QuicVersionNegotiationPacket* version_negotiation_packet() const { 151 const QuicVersionNegotiationPacket* version_negotiation_packet() const {
161 return version_negotiation_packet_.get(); 152 return version_negotiation_packet_.get();
162 } 153 }
163 const QuicPublicResetPacket* public_reset_packet() const { 154 const QuicPublicResetPacket* public_reset_packet() const {
164 return public_reset_packet_.get(); 155 return public_reset_packet_.get();
165 } 156 }
166 157
167 private: 158 private:
168 QuicErrorCode error_; 159 QuicErrorCode error_;
169 bool has_header_; 160 bool has_header_;
(...skipping 22 matching lines...) Expand all
192 } 183 }
193 184
194 SimpleQuicFramer::SimpleQuicFramer(const QuicVersionVector& supported_versions) 185 SimpleQuicFramer::SimpleQuicFramer(const QuicVersionVector& supported_versions)
195 : framer_(supported_versions, QuicTime::Zero(), true) { 186 : framer_(supported_versions, QuicTime::Zero(), true) {
196 } 187 }
197 188
198 SimpleQuicFramer::~SimpleQuicFramer() { 189 SimpleQuicFramer::~SimpleQuicFramer() {
199 } 190 }
200 191
201 bool SimpleQuicFramer::ProcessPacket(const QuicPacket& packet) { 192 bool SimpleQuicFramer::ProcessPacket(const QuicPacket& packet) {
202 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( 193 scoped_ptr<QuicEncryptedPacket> encrypted(
203 ENCRYPTION_NONE, 0, packet)); 194 framer_.EncryptPacket(ENCRYPTION_NONE, 0, packet));
204 return ProcessPacket(*encrypted); 195 return ProcessPacket(*encrypted);
205 } 196 }
206 197
207 bool SimpleQuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) { 198 bool SimpleQuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) {
208 visitor_.reset(new SimpleFramerVisitor); 199 visitor_.reset(new SimpleFramerVisitor);
209 framer_.set_visitor(visitor_.get()); 200 framer_.set_visitor(visitor_.get());
210 return framer_.ProcessPacket(packet); 201 return framer_.ProcessPacket(packet);
211 } 202 }
212 203
213 void SimpleQuicFramer::Reset() { 204 void SimpleQuicFramer::Reset() {
214 visitor_.reset(new SimpleFramerVisitor); 205 visitor_.reset(new SimpleFramerVisitor);
215 } 206 }
216 207
217
218 const QuicPacketHeader& SimpleQuicFramer::header() const { 208 const QuicPacketHeader& SimpleQuicFramer::header() const {
219 return visitor_->header(); 209 return visitor_->header();
220 } 210 }
221 211
222 const QuicFecData& SimpleQuicFramer::fec_data() const { 212 const QuicFecData& SimpleQuicFramer::fec_data() const {
223 return visitor_->fec_data(); 213 return visitor_->fec_data();
224 } 214 }
225 215
226 const QuicVersionNegotiationPacket* 216 const QuicVersionNegotiationPacket*
227 SimpleQuicFramer::version_negotiation_packet() const { 217 SimpleQuicFramer::version_negotiation_packet() const {
228 return visitor_->version_negotiation_packet(); 218 return visitor_->version_negotiation_packet();
229 } 219 }
230 220
231 const QuicPublicResetPacket* SimpleQuicFramer::public_reset_packet() const { 221 const QuicPublicResetPacket* SimpleQuicFramer::public_reset_packet() const {
232 return visitor_->public_reset_packet(); 222 return visitor_->public_reset_packet();
233 } 223 }
234 224
235 QuicFramer* SimpleQuicFramer::framer() { 225 QuicFramer* SimpleQuicFramer::framer() {
236 return &framer_; 226 return &framer_;
237 } 227 }
238 228
239 size_t SimpleQuicFramer::num_frames() const { 229 size_t SimpleQuicFramer::num_frames() const {
240 return ack_frames().size() + 230 return ack_frames().size() + feedback_frames().size() +
241 feedback_frames().size() + 231 goaway_frames().size() + rst_stream_frames().size() +
242 goaway_frames().size() + 232 stop_waiting_frames().size() + stream_frames().size() +
243 rst_stream_frames().size() + 233 ping_frames().size() + connection_close_frames().size();
244 stop_waiting_frames().size() +
245 stream_frames().size() +
246 ping_frames().size() +
247 connection_close_frames().size();
248 } 234 }
249 235
250 const vector<QuicAckFrame>& SimpleQuicFramer::ack_frames() const { 236 const vector<QuicAckFrame>& SimpleQuicFramer::ack_frames() const {
251 return visitor_->ack_frames(); 237 return visitor_->ack_frames();
252 } 238 }
253 239
254 const vector<QuicStopWaitingFrame>& 240 const vector<QuicStopWaitingFrame>& SimpleQuicFramer::stop_waiting_frames()
255 SimpleQuicFramer::stop_waiting_frames() const { 241 const {
256 return visitor_->stop_waiting_frames(); 242 return visitor_->stop_waiting_frames();
257 } 243 }
258 244
259 const vector<QuicPingFrame>& SimpleQuicFramer::ping_frames() const { 245 const vector<QuicPingFrame>& SimpleQuicFramer::ping_frames() const {
260 return visitor_->ping_frames(); 246 return visitor_->ping_frames();
261 } 247 }
262 248
263 const vector<QuicStreamFrame>& SimpleQuicFramer::stream_frames() const { 249 const vector<QuicStreamFrame>& SimpleQuicFramer::stream_frames() const {
264 return visitor_->stream_frames(); 250 return visitor_->stream_frames();
265 } 251 }
266 252
267 const vector<QuicRstStreamFrame>& SimpleQuicFramer::rst_stream_frames() const { 253 const vector<QuicRstStreamFrame>& SimpleQuicFramer::rst_stream_frames() const {
268 return visitor_->rst_stream_frames(); 254 return visitor_->rst_stream_frames();
269 } 255 }
270 256
271 const vector<QuicCongestionFeedbackFrame>& 257 const vector<QuicCongestionFeedbackFrame>& SimpleQuicFramer::feedback_frames()
272 SimpleQuicFramer::feedback_frames() const { 258 const {
273 return visitor_->feedback_frames(); 259 return visitor_->feedback_frames();
274 } 260 }
275 261
276 const vector<QuicGoAwayFrame>& 262 const vector<QuicGoAwayFrame>& SimpleQuicFramer::goaway_frames() const {
277 SimpleQuicFramer::goaway_frames() const {
278 return visitor_->goaway_frames(); 263 return visitor_->goaway_frames();
279 } 264 }
280 265
281 const vector<QuicConnectionCloseFrame>& 266 const vector<QuicConnectionCloseFrame>&
282 SimpleQuicFramer::connection_close_frames() const { 267 SimpleQuicFramer::connection_close_frames() const {
283 return visitor_->connection_close_frames(); 268 return visitor_->connection_close_frames();
284 } 269 }
285 270
286 } // namespace test 271 } // namespace test
287 } // namespace net 272 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698