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/quic/test_tools/simple_quic_framer.h" | 5 #include "net/quic/test_tools/simple_quic_framer.h" |
6 | 6 |
7 #include "net/quic/crypto/crypto_framer.h" | 7 #include "net/quic/crypto/crypto_framer.h" |
8 #include "net/quic/crypto/quic_decrypter.h" | 8 #include "net/quic/crypto/quic_decrypter.h" |
9 #include "net/quic/crypto/quic_encrypter.h" | 9 #include "net/quic/crypto/quic_encrypter.h" |
10 | 10 |
11 using base::StringPiece; | 11 using base::StringPiece; |
12 using std::string; | 12 using std::string; |
13 using std::vector; | 13 using std::vector; |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 namespace test { | 16 namespace test { |
17 | 17 |
18 class SimpleFramerVisitor : public QuicFramerVisitorInterface { | 18 class SimpleFramerVisitor : public QuicFramerVisitorInterface { |
19 public: | 19 public: |
20 SimpleFramerVisitor() | 20 SimpleFramerVisitor() |
21 : error_(QUIC_NO_ERROR) { | 21 : error_(QUIC_NO_ERROR) { |
22 } | 22 } |
23 | 23 |
24 virtual void OnError(QuicFramer* framer) { | 24 virtual void OnError(QuicFramer* framer) OVERRIDE { |
25 error_ = framer->error(); | 25 error_ = framer->error(); |
26 } | 26 } |
27 | 27 |
28 virtual bool OnProtocolVersionMismatch(QuicVersionTag version) { | 28 virtual bool OnProtocolVersionMismatch(QuicVersionTag version) { |
29 return false; | 29 return false; |
30 } | 30 } |
31 | 31 |
32 virtual void OnPacket() {} | 32 virtual void OnPacket() OVERRIDE {} |
33 virtual void OnPublicResetPacket(const QuicPublicResetPacket& packet) {} | 33 virtual void OnPublicResetPacket( |
| 34 const QuicPublicResetPacket& packet) OVERRIDE {} |
34 virtual void OnVersionNegotiationPacket( | 35 virtual void OnVersionNegotiationPacket( |
35 const QuicVersionNegotiationPacket& packet) {} | 36 const QuicVersionNegotiationPacket& packet) OVERRIDE {} |
36 virtual void OnRevivedPacket() {} | 37 virtual void OnRevivedPacket() OVERRIDE {} |
37 | 38 |
38 virtual bool OnPacketHeader(const QuicPacketHeader& header) { | 39 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE { |
39 has_header_ = true; | 40 has_header_ = true; |
40 header_ = header; | 41 header_ = header; |
41 return true; | 42 return true; |
42 } | 43 } |
43 | 44 |
44 virtual void OnFecProtectedPayload(StringPiece payload) {} | 45 virtual void OnFecProtectedPayload(StringPiece payload) OVERRIDE {} |
45 | 46 |
46 virtual void OnStreamFrame(const QuicStreamFrame& frame) { | 47 virtual void OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE { |
47 // Save a copy of the data so it is valid after the packet is processed. | 48 // Save a copy of the data so it is valid after the packet is processed. |
48 stream_data_.push_back(frame.data.as_string()); | 49 stream_data_.push_back(frame.data.as_string()); |
49 QuicStreamFrame stream_frame(frame); | 50 QuicStreamFrame stream_frame(frame); |
50 // Make sure that the stream frame points to this data. | 51 // Make sure that the stream frame points to this data. |
51 stream_frame.data = stream_data_.back(); | 52 stream_frame.data = stream_data_.back(); |
52 stream_frames_.push_back(stream_frame); | 53 stream_frames_.push_back(stream_frame); |
53 } | 54 } |
54 | 55 |
55 virtual void OnAckFrame(const QuicAckFrame& frame) { | 56 virtual void OnAckFrame(const QuicAckFrame& frame) OVERRIDE { |
56 ack_frames_.push_back(frame); | 57 ack_frames_.push_back(frame); |
57 } | 58 } |
58 | 59 |
59 virtual void OnCongestionFeedbackFrame( | 60 virtual void OnCongestionFeedbackFrame( |
60 const QuicCongestionFeedbackFrame& frame) { | 61 const QuicCongestionFeedbackFrame& frame) OVERRIDE { |
61 feedback_frames_.push_back(frame); | 62 feedback_frames_.push_back(frame); |
62 } | 63 } |
63 | 64 |
64 virtual void OnFecData(const QuicFecData& fec) { | 65 virtual void OnFecData(const QuicFecData& fec) OVERRIDE { |
65 fec_data_ = fec; | 66 fec_data_ = fec; |
66 fec_redundancy_ = fec_data_.redundancy.as_string(); | 67 fec_redundancy_ = fec_data_.redundancy.as_string(); |
67 fec_data_.redundancy = fec_redundancy_; | 68 fec_data_.redundancy = fec_redundancy_; |
68 } | 69 } |
69 | 70 |
70 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) { | 71 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE { |
71 rst_stream_frames_.push_back(frame); | 72 rst_stream_frames_.push_back(frame); |
72 } | 73 } |
73 | 74 |
74 virtual void OnConnectionCloseFrame( | 75 virtual void OnConnectionCloseFrame( |
75 const QuicConnectionCloseFrame& frame) { | 76 const QuicConnectionCloseFrame& frame) OVERRIDE { |
76 connection_close_frames_.push_back(frame); | 77 connection_close_frames_.push_back(frame); |
77 } | 78 } |
78 | 79 |
79 virtual void OnGoAwayFrame(const QuicGoAwayFrame& frame) { | 80 virtual void OnGoAwayFrame(const QuicGoAwayFrame& frame) OVERRIDE { |
80 goaway_frames_.push_back(frame); | 81 goaway_frames_.push_back(frame); |
81 } | 82 } |
82 | 83 |
83 virtual void OnPacketComplete() {} | 84 virtual void OnPacketComplete() OVERRIDE {} |
84 | 85 |
85 const QuicPacketHeader& header() const { return header_; } | 86 const QuicPacketHeader& header() const { return header_; } |
86 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; } | 87 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; } |
87 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { | 88 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { |
88 return connection_close_frames_; | 89 return connection_close_frames_; |
89 } | 90 } |
90 const vector<QuicCongestionFeedbackFrame>& feedback_frames() const { | 91 const vector<QuicCongestionFeedbackFrame>& feedback_frames() const { |
91 return feedback_frames_; | 92 return feedback_frames_; |
92 } | 93 } |
93 const vector<QuicGoAwayFrame>& goaway_frames() const { | 94 const vector<QuicGoAwayFrame>& goaway_frames() const { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return visitor_->goaway_frames(); | 189 return visitor_->goaway_frames(); |
189 } | 190 } |
190 | 191 |
191 const vector<QuicConnectionCloseFrame>& | 192 const vector<QuicConnectionCloseFrame>& |
192 SimpleQuicFramer::connection_close_frames() const { | 193 SimpleQuicFramer::connection_close_frames() const { |
193 return visitor_->connection_close_frames(); | 194 return visitor_->connection_close_frames(); |
194 } | 195 } |
195 | 196 |
196 } // namespace test | 197 } // namespace test |
197 } // namespace net | 198 } // namespace net |
OLD | NEW |