| 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 "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() |
| 22 : error_(QUIC_NO_ERROR) { | 22 : error_(QUIC_NO_ERROR) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 virtual ~SimpleFramerVisitor() OVERRIDE { | 25 virtual ~SimpleFramerVisitor() override { |
| 26 STLDeleteElements(&stream_data_); | 26 STLDeleteElements(&stream_data_); |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual void OnError(QuicFramer* framer) OVERRIDE { | 29 virtual void OnError(QuicFramer* framer) override { |
| 30 error_ = framer->error(); | 30 error_ = framer->error(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual bool OnProtocolVersionMismatch(QuicVersion version) OVERRIDE { | 33 virtual bool OnProtocolVersionMismatch(QuicVersion version) override { |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual void OnPacket() OVERRIDE {} | 37 virtual void OnPacket() override {} |
| 38 virtual void OnPublicResetPacket( | 38 virtual void OnPublicResetPacket( |
| 39 const QuicPublicResetPacket& packet) OVERRIDE { | 39 const QuicPublicResetPacket& packet) override { |
| 40 public_reset_packet_.reset(new QuicPublicResetPacket(packet)); | 40 public_reset_packet_.reset(new QuicPublicResetPacket(packet)); |
| 41 } | 41 } |
| 42 virtual void OnVersionNegotiationPacket( | 42 virtual void OnVersionNegotiationPacket( |
| 43 const QuicVersionNegotiationPacket& packet) OVERRIDE { | 43 const QuicVersionNegotiationPacket& packet) override { |
| 44 version_negotiation_packet_.reset( | 44 version_negotiation_packet_.reset( |
| 45 new QuicVersionNegotiationPacket(packet)); | 45 new QuicVersionNegotiationPacket(packet)); |
| 46 } | 46 } |
| 47 virtual void OnRevivedPacket() OVERRIDE {} | 47 virtual void OnRevivedPacket() override {} |
| 48 | 48 |
| 49 virtual bool OnUnauthenticatedPublicHeader( | 49 virtual bool OnUnauthenticatedPublicHeader( |
| 50 const QuicPacketPublicHeader& header) OVERRIDE { | 50 const QuicPacketPublicHeader& header) override { |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 virtual bool OnUnauthenticatedHeader( | 53 virtual bool OnUnauthenticatedHeader( |
| 54 const QuicPacketHeader& header) OVERRIDE { | 54 const QuicPacketHeader& header) override { |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 virtual void OnDecryptedPacket(EncryptionLevel level) OVERRIDE {} | 57 virtual void OnDecryptedPacket(EncryptionLevel level) override {} |
| 58 virtual bool OnPacketHeader(const QuicPacketHeader& header) OVERRIDE { | 58 virtual bool OnPacketHeader(const QuicPacketHeader& header) override { |
| 59 has_header_ = true; | 59 has_header_ = true; |
| 60 header_ = header; | 60 header_ = header; |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void OnFecProtectedPayload(StringPiece payload) OVERRIDE {} | 64 virtual void OnFecProtectedPayload(StringPiece payload) override {} |
| 65 | 65 |
| 66 virtual bool OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE { | 66 virtual bool OnStreamFrame(const QuicStreamFrame& frame) override { |
| 67 // Save a copy of the data so it is valid after the packet is processed. | 67 // Save a copy of the data so it is valid after the packet is processed. |
| 68 stream_data_.push_back(frame.GetDataAsString()); | 68 stream_data_.push_back(frame.GetDataAsString()); |
| 69 QuicStreamFrame stream_frame(frame); | 69 QuicStreamFrame stream_frame(frame); |
| 70 // Make sure that the stream frame points to this data. | 70 // Make sure that the stream frame points to this data. |
| 71 stream_frame.data.Clear(); | 71 stream_frame.data.Clear(); |
| 72 stream_frame.data.Append(const_cast<char*>(stream_data_.back()->data()), | 72 stream_frame.data.Append(const_cast<char*>(stream_data_.back()->data()), |
| 73 stream_data_.back()->size()); | 73 stream_data_.back()->size()); |
| 74 stream_frames_.push_back(stream_frame); | 74 stream_frames_.push_back(stream_frame); |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 virtual bool OnAckFrame(const QuicAckFrame& frame) OVERRIDE { | 78 virtual bool OnAckFrame(const QuicAckFrame& frame) override { |
| 79 ack_frames_.push_back(frame); | 79 ack_frames_.push_back(frame); |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual bool OnCongestionFeedbackFrame( | 83 virtual bool OnCongestionFeedbackFrame( |
| 84 const QuicCongestionFeedbackFrame& frame) OVERRIDE { | 84 const QuicCongestionFeedbackFrame& frame) override { |
| 85 feedback_frames_.push_back(frame); | 85 feedback_frames_.push_back(frame); |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) OVERRIDE { | 89 virtual bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override { |
| 90 stop_waiting_frames_.push_back(frame); | 90 stop_waiting_frames_.push_back(frame); |
| 91 return true; | 91 return true; |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual bool OnPingFrame(const QuicPingFrame& frame) OVERRIDE { | 94 virtual bool OnPingFrame(const QuicPingFrame& frame) override { |
| 95 ping_frames_.push_back(frame); | 95 ping_frames_.push_back(frame); |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual void OnFecData(const QuicFecData& fec) OVERRIDE { | 99 virtual void OnFecData(const QuicFecData& fec) override { |
| 100 fec_data_ = fec; | 100 fec_data_ = fec; |
| 101 fec_redundancy_ = fec_data_.redundancy.as_string(); | 101 fec_redundancy_ = fec_data_.redundancy.as_string(); |
| 102 fec_data_.redundancy = fec_redundancy_; | 102 fec_data_.redundancy = fec_redundancy_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual bool OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE { | 105 virtual bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override { |
| 106 rst_stream_frames_.push_back(frame); | 106 rst_stream_frames_.push_back(frame); |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| 109 | 109 |
| 110 virtual bool OnConnectionCloseFrame( | 110 virtual bool OnConnectionCloseFrame( |
| 111 const QuicConnectionCloseFrame& frame) OVERRIDE { | 111 const QuicConnectionCloseFrame& frame) override { |
| 112 connection_close_frames_.push_back(frame); | 112 connection_close_frames_.push_back(frame); |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 | 115 |
| 116 virtual bool OnGoAwayFrame(const QuicGoAwayFrame& frame) OVERRIDE { | 116 virtual bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override { |
| 117 goaway_frames_.push_back(frame); | 117 goaway_frames_.push_back(frame); |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| 120 | 120 |
| 121 virtual bool OnWindowUpdateFrame( | 121 virtual bool OnWindowUpdateFrame( |
| 122 const QuicWindowUpdateFrame& frame) OVERRIDE { | 122 const QuicWindowUpdateFrame& frame) override { |
| 123 window_update_frames_.push_back(frame); | 123 window_update_frames_.push_back(frame); |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual bool OnBlockedFrame(const QuicBlockedFrame& frame) OVERRIDE { | 127 virtual bool OnBlockedFrame(const QuicBlockedFrame& frame) override { |
| 128 blocked_frames_.push_back(frame); | 128 blocked_frames_.push_back(frame); |
| 129 return true; | 129 return true; |
| 130 } | 130 } |
| 131 | 131 |
| 132 virtual void OnPacketComplete() OVERRIDE {} | 132 virtual void OnPacketComplete() override {} |
| 133 | 133 |
| 134 const QuicPacketHeader& header() const { return header_; } | 134 const QuicPacketHeader& header() const { return header_; } |
| 135 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; } | 135 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; } |
| 136 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { | 136 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { |
| 137 return connection_close_frames_; | 137 return connection_close_frames_; |
| 138 } | 138 } |
| 139 const vector<QuicCongestionFeedbackFrame>& feedback_frames() const { | 139 const vector<QuicCongestionFeedbackFrame>& feedback_frames() const { |
| 140 return feedback_frames_; | 140 return feedback_frames_; |
| 141 } | 141 } |
| 142 const vector<QuicGoAwayFrame>& goaway_frames() const { | 142 const vector<QuicGoAwayFrame>& goaway_frames() const { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return visitor_->goaway_frames(); | 278 return visitor_->goaway_frames(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 const vector<QuicConnectionCloseFrame>& | 281 const vector<QuicConnectionCloseFrame>& |
| 282 SimpleQuicFramer::connection_close_frames() const { | 282 SimpleQuicFramer::connection_close_frames() const { |
| 283 return visitor_->connection_close_frames(); | 283 return visitor_->connection_close_frames(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace test | 286 } // namespace test |
| 287 } // namespace net | 287 } // namespace net |
| OLD | NEW |