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

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

Issue 2417023003: Remove stl_util's deletion functions from: (Closed)
Patch Set: internal snapshot 10 Created 4 years, 2 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
« 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 <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/stl_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "net/quic/core/crypto/quic_decrypter.h" 11 #include "net/quic/core/crypto/quic_decrypter.h"
12 #include "net/quic/core/crypto/quic_encrypter.h" 12 #include "net/quic/core/crypto/quic_encrypter.h"
13 13
14 using base::StringPiece; 14 using base::StringPiece;
15 using std::string; 15 using std::string;
16 using std::vector; 16 using std::vector;
17 17
18 namespace net { 18 namespace net {
19 namespace test { 19 namespace test {
20 20
21 class SimpleFramerVisitor : public QuicFramerVisitorInterface { 21 class SimpleFramerVisitor : public QuicFramerVisitorInterface {
22 public: 22 public:
23 SimpleFramerVisitor() : error_(QUIC_NO_ERROR) {} 23 SimpleFramerVisitor() : error_(QUIC_NO_ERROR) {}
24 24
25 ~SimpleFramerVisitor() override { 25 ~SimpleFramerVisitor() override {}
26 base::STLDeleteElements(&stream_frames_);
27 base::STLDeleteElements(&stream_data_);
28 }
29 26
30 void OnError(QuicFramer* framer) override { error_ = framer->error(); } 27 void OnError(QuicFramer* framer) override { error_ = framer->error(); }
31 28
32 bool OnProtocolVersionMismatch(QuicVersion version) override { return false; } 29 bool OnProtocolVersionMismatch(QuicVersion version) override { return false; }
33 30
34 void OnPacket() override {} 31 void OnPacket() override {}
35 void OnPublicResetPacket(const QuicPublicResetPacket& packet) override { 32 void OnPublicResetPacket(const QuicPublicResetPacket& packet) override {
36 public_reset_packet_.reset(new QuicPublicResetPacket(packet)); 33 public_reset_packet_.reset(new QuicPublicResetPacket(packet));
37 } 34 }
38 void OnVersionNegotiationPacket( 35 void OnVersionNegotiationPacket(
(...skipping 13 matching lines...) Expand all
52 has_header_ = true; 49 has_header_ = true;
53 header_ = header; 50 header_ = header;
54 return true; 51 return true;
55 } 52 }
56 53
57 bool OnStreamFrame(const QuicStreamFrame& frame) override { 54 bool OnStreamFrame(const QuicStreamFrame& frame) override {
58 // Save a copy of the data so it is valid after the packet is processed. 55 // Save a copy of the data so it is valid after the packet is processed.
59 string* string_data = new string(); 56 string* string_data = new string();
60 StringPiece(frame.data_buffer, frame.data_length) 57 StringPiece(frame.data_buffer, frame.data_length)
61 .AppendToString(string_data); 58 .AppendToString(string_data);
62 stream_data_.push_back(string_data); 59 stream_data_.push_back(base::WrapUnique(string_data));
63 // TODO(ianswett): A pointer isn't necessary with emplace_back. 60 // TODO(ianswett): A pointer isn't necessary with emplace_back.
64 stream_frames_.push_back(new QuicStreamFrame( 61 stream_frames_.push_back(base::MakeUnique<QuicStreamFrame>(
65 frame.stream_id, frame.fin, frame.offset, StringPiece(*string_data))); 62 frame.stream_id, frame.fin, frame.offset, StringPiece(*string_data)));
66 return true; 63 return true;
67 } 64 }
68 65
69 bool OnAckFrame(const QuicAckFrame& frame) override { 66 bool OnAckFrame(const QuicAckFrame& frame) override {
70 ack_frames_.push_back(frame); 67 ack_frames_.push_back(frame);
71 return true; 68 return true;
72 } 69 }
73 70
74 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override { 71 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; } 119 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; }
123 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { 120 const vector<QuicConnectionCloseFrame>& connection_close_frames() const {
124 return connection_close_frames_; 121 return connection_close_frames_;
125 } 122 }
126 const vector<QuicGoAwayFrame>& goaway_frames() const { 123 const vector<QuicGoAwayFrame>& goaway_frames() const {
127 return goaway_frames_; 124 return goaway_frames_;
128 } 125 }
129 const vector<QuicRstStreamFrame>& rst_stream_frames() const { 126 const vector<QuicRstStreamFrame>& rst_stream_frames() const {
130 return rst_stream_frames_; 127 return rst_stream_frames_;
131 } 128 }
132 const vector<QuicStreamFrame*>& stream_frames() const { 129 const vector<std::unique_ptr<QuicStreamFrame>>& stream_frames() const {
133 return stream_frames_; 130 return stream_frames_;
134 } 131 }
135 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const { 132 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const {
136 return stop_waiting_frames_; 133 return stop_waiting_frames_;
137 } 134 }
138 const vector<QuicPingFrame>& ping_frames() const { return ping_frames_; } 135 const vector<QuicPingFrame>& ping_frames() const { return ping_frames_; }
139 const QuicVersionNegotiationPacket* version_negotiation_packet() const { 136 const QuicVersionNegotiationPacket* version_negotiation_packet() const {
140 return version_negotiation_packet_.get(); 137 return version_negotiation_packet_.get();
141 } 138 }
142 139
143 private: 140 private:
144 QuicErrorCode error_; 141 QuicErrorCode error_;
145 bool has_header_; 142 bool has_header_;
146 QuicPacketHeader header_; 143 QuicPacketHeader header_;
147 std::unique_ptr<QuicVersionNegotiationPacket> version_negotiation_packet_; 144 std::unique_ptr<QuicVersionNegotiationPacket> version_negotiation_packet_;
148 std::unique_ptr<QuicPublicResetPacket> public_reset_packet_; 145 std::unique_ptr<QuicPublicResetPacket> public_reset_packet_;
149 vector<QuicAckFrame> ack_frames_; 146 vector<QuicAckFrame> ack_frames_;
150 vector<QuicStopWaitingFrame> stop_waiting_frames_; 147 vector<QuicStopWaitingFrame> stop_waiting_frames_;
151 vector<QuicPaddingFrame> padding_frames_; 148 vector<QuicPaddingFrame> padding_frames_;
152 vector<QuicPingFrame> ping_frames_; 149 vector<QuicPingFrame> ping_frames_;
153 vector<QuicStreamFrame*> stream_frames_; 150 vector<std::unique_ptr<QuicStreamFrame>> stream_frames_;
154 vector<QuicRstStreamFrame> rst_stream_frames_; 151 vector<QuicRstStreamFrame> rst_stream_frames_;
155 vector<QuicGoAwayFrame> goaway_frames_; 152 vector<QuicGoAwayFrame> goaway_frames_;
156 vector<QuicConnectionCloseFrame> connection_close_frames_; 153 vector<QuicConnectionCloseFrame> connection_close_frames_;
157 vector<QuicWindowUpdateFrame> window_update_frames_; 154 vector<QuicWindowUpdateFrame> window_update_frames_;
158 vector<QuicBlockedFrame> blocked_frames_; 155 vector<QuicBlockedFrame> blocked_frames_;
159 vector<QuicPathCloseFrame> path_close_frames_; 156 vector<QuicPathCloseFrame> path_close_frames_;
160 vector<string*> stream_data_; 157 vector<std::unique_ptr<string>> stream_data_;
161 158
162 DISALLOW_COPY_AND_ASSIGN(SimpleFramerVisitor); 159 DISALLOW_COPY_AND_ASSIGN(SimpleFramerVisitor);
163 }; 160 };
164 161
165 SimpleQuicFramer::SimpleQuicFramer() 162 SimpleQuicFramer::SimpleQuicFramer()
166 : framer_(AllSupportedVersions(), 163 : framer_(AllSupportedVersions(),
167 QuicTime::Zero(), 164 QuicTime::Zero(),
168 Perspective::IS_SERVER) {} 165 Perspective::IS_SERVER) {}
169 166
170 SimpleQuicFramer::SimpleQuicFramer(const QuicVersionVector& supported_versions) 167 SimpleQuicFramer::SimpleQuicFramer(const QuicVersionVector& supported_versions)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 209
213 const vector<QuicStopWaitingFrame>& SimpleQuicFramer::stop_waiting_frames() 210 const vector<QuicStopWaitingFrame>& SimpleQuicFramer::stop_waiting_frames()
214 const { 211 const {
215 return visitor_->stop_waiting_frames(); 212 return visitor_->stop_waiting_frames();
216 } 213 }
217 214
218 const vector<QuicPingFrame>& SimpleQuicFramer::ping_frames() const { 215 const vector<QuicPingFrame>& SimpleQuicFramer::ping_frames() const {
219 return visitor_->ping_frames(); 216 return visitor_->ping_frames();
220 } 217 }
221 218
222 const vector<QuicStreamFrame*>& SimpleQuicFramer::stream_frames() const { 219 const vector<std::unique_ptr<QuicStreamFrame>>&
220 SimpleQuicFramer::stream_frames() const {
223 return visitor_->stream_frames(); 221 return visitor_->stream_frames();
224 } 222 }
225 223
226 const vector<QuicRstStreamFrame>& SimpleQuicFramer::rst_stream_frames() const { 224 const vector<QuicRstStreamFrame>& SimpleQuicFramer::rst_stream_frames() const {
227 return visitor_->rst_stream_frames(); 225 return visitor_->rst_stream_frames();
228 } 226 }
229 227
230 const vector<QuicGoAwayFrame>& SimpleQuicFramer::goaway_frames() const { 228 const vector<QuicGoAwayFrame>& SimpleQuicFramer::goaway_frames() const {
231 return visitor_->goaway_frames(); 229 return visitor_->goaway_frames();
232 } 230 }
233 231
234 const vector<QuicConnectionCloseFrame>& 232 const vector<QuicConnectionCloseFrame>&
235 SimpleQuicFramer::connection_close_frames() const { 233 SimpleQuicFramer::connection_close_frames() const {
236 return visitor_->connection_close_frames(); 234 return visitor_->connection_close_frames();
237 } 235 }
238 236
239 } // namespace test 237 } // namespace test
240 } // namespace net 238 } // 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