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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 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
« no previous file with comments | « net/quic/test_tools/simple_quic_framer.h ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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) OVERRIDE { 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) OVERRIDE { 28 virtual bool OnProtocolVersionMismatch(QuicTag version) OVERRIDE {
29 return false; 29 return false;
30 } 30 }
31 31
32 virtual void OnPacket() OVERRIDE {} 32 virtual void OnPacket() OVERRIDE {}
33 virtual void OnPublicResetPacket( 33 virtual void OnPublicResetPacket(
34 const QuicPublicResetPacket& packet) OVERRIDE {} 34 const QuicPublicResetPacket& packet) OVERRIDE {}
35 virtual void OnVersionNegotiationPacket( 35 virtual void OnVersionNegotiationPacket(
36 const QuicVersionNegotiationPacket& packet) OVERRIDE {} 36 const QuicVersionNegotiationPacket& packet) OVERRIDE {}
37 virtual void OnRevivedPacket() OVERRIDE {} 37 virtual void OnRevivedPacket() OVERRIDE {}
38 38
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 vector<QuicStreamFrame> stream_frames_; 121 vector<QuicStreamFrame> stream_frames_;
122 vector<QuicRstStreamFrame> rst_stream_frames_; 122 vector<QuicRstStreamFrame> rst_stream_frames_;
123 vector<QuicGoAwayFrame> goaway_frames_; 123 vector<QuicGoAwayFrame> goaway_frames_;
124 vector<QuicConnectionCloseFrame> connection_close_frames_; 124 vector<QuicConnectionCloseFrame> connection_close_frames_;
125 vector<string> stream_data_; 125 vector<string> stream_data_;
126 126
127 DISALLOW_COPY_AND_ASSIGN(SimpleFramerVisitor); 127 DISALLOW_COPY_AND_ASSIGN(SimpleFramerVisitor);
128 }; 128 };
129 129
130 SimpleQuicFramer::SimpleQuicFramer() 130 SimpleQuicFramer::SimpleQuicFramer()
131 : framer_(kQuicVersion1, 131 : framer_(kQuicVersion1, QuicTime::Zero(), true) {
132 QuicTime::Zero(),
133 true) {
134 } 132 }
135 133
136 SimpleQuicFramer::~SimpleQuicFramer() { 134 SimpleQuicFramer::~SimpleQuicFramer() {
137 } 135 }
138 136
139 bool SimpleQuicFramer::ProcessPacket(const QuicPacket& packet) { 137 bool SimpleQuicFramer::ProcessPacket(const QuicPacket& packet) {
140 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( 138 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
141 ENCRYPTION_NONE, 0, packet)); 139 ENCRYPTION_NONE, 0, packet));
142 return ProcessPacket(*encrypted); 140 return ProcessPacket(*encrypted);
143 } 141 }
144 142
145 bool SimpleQuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) { 143 bool SimpleQuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) {
146 visitor_.reset(new SimpleFramerVisitor); 144 visitor_.reset(new SimpleFramerVisitor);
147 framer_.set_visitor(visitor_.get()); 145 framer_.set_visitor(visitor_.get());
148 return framer_.ProcessPacket(packet); 146 return framer_.ProcessPacket(packet);
149 } 147 }
150 148
151 const QuicPacketHeader& SimpleQuicFramer::header() const { 149 const QuicPacketHeader& SimpleQuicFramer::header() const {
152 return visitor_->header(); 150 return visitor_->header();
153 } 151 }
154 152
155 const QuicFecData& SimpleQuicFramer::fec_data() const { 153 const QuicFecData& SimpleQuicFramer::fec_data() const {
156 return visitor_->fec_data(); 154 return visitor_->fec_data();
157 } 155 }
158 156
157 QuicFramer* SimpleQuicFramer::framer() {
158 return &framer_;
159 }
160
159 size_t SimpleQuicFramer::num_frames() const { 161 size_t SimpleQuicFramer::num_frames() const {
160 return ack_frames().size() + 162 return ack_frames().size() +
161 stream_frames().size() + 163 stream_frames().size() +
162 feedback_frames().size() + 164 feedback_frames().size() +
163 rst_stream_frames().size() + 165 rst_stream_frames().size() +
164 goaway_frames().size() + 166 goaway_frames().size() +
165 connection_close_frames().size(); 167 connection_close_frames().size();
166 } 168 }
167 169
168 const vector<QuicAckFrame>& SimpleQuicFramer::ack_frames() const { 170 const vector<QuicAckFrame>& SimpleQuicFramer::ack_frames() const {
(...skipping 18 matching lines...) Expand all
187 return visitor_->goaway_frames(); 189 return visitor_->goaway_frames();
188 } 190 }
189 191
190 const vector<QuicConnectionCloseFrame>& 192 const vector<QuicConnectionCloseFrame>&
191 SimpleQuicFramer::connection_close_frames() const { 193 SimpleQuicFramer::connection_close_frames() const {
192 return visitor_->connection_close_frames(); 194 return visitor_->connection_close_frames();
193 } 195 }
194 196
195 } // namespace test 197 } // namespace test
196 } // namespace net 198 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/simple_quic_framer.h ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698