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" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ack_frames_.push_back(frame); | 73 ack_frames_.push_back(frame); |
74 return true; | 74 return true; |
75 } | 75 } |
76 | 76 |
77 virtual bool OnCongestionFeedbackFrame( | 77 virtual bool OnCongestionFeedbackFrame( |
78 const QuicCongestionFeedbackFrame& frame) OVERRIDE { | 78 const QuicCongestionFeedbackFrame& frame) OVERRIDE { |
79 feedback_frames_.push_back(frame); | 79 feedback_frames_.push_back(frame); |
80 return true; | 80 return true; |
81 } | 81 } |
82 | 82 |
| 83 virtual bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) OVERRIDE { |
| 84 stop_waiting_frames_.push_back(frame); |
| 85 return true; |
| 86 } |
| 87 |
83 virtual void OnFecData(const QuicFecData& fec) OVERRIDE { | 88 virtual void OnFecData(const QuicFecData& fec) OVERRIDE { |
84 fec_data_ = fec; | 89 fec_data_ = fec; |
85 fec_redundancy_ = fec_data_.redundancy.as_string(); | 90 fec_redundancy_ = fec_data_.redundancy.as_string(); |
86 fec_data_.redundancy = fec_redundancy_; | 91 fec_data_.redundancy = fec_redundancy_; |
87 } | 92 } |
88 | 93 |
89 virtual bool OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE { | 94 virtual bool OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE { |
90 rst_stream_frames_.push_back(frame); | 95 rst_stream_frames_.push_back(frame); |
91 return true; | 96 return true; |
92 } | 97 } |
93 | 98 |
94 virtual bool OnConnectionCloseFrame( | 99 virtual bool OnConnectionCloseFrame( |
95 const QuicConnectionCloseFrame& frame) OVERRIDE { | 100 const QuicConnectionCloseFrame& frame) OVERRIDE { |
96 connection_close_frames_.push_back(frame); | 101 connection_close_frames_.push_back(frame); |
97 return true; | 102 return true; |
98 } | 103 } |
99 | 104 |
100 virtual bool OnGoAwayFrame(const QuicGoAwayFrame& frame) OVERRIDE { | 105 virtual bool OnGoAwayFrame(const QuicGoAwayFrame& frame) OVERRIDE { |
101 goaway_frames_.push_back(frame); | 106 goaway_frames_.push_back(frame); |
102 return true; | 107 return true; |
103 } | 108 } |
104 | 109 |
105 virtual bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) | 110 virtual bool OnWindowUpdateFrame( |
106 OVERRIDE { | 111 const QuicWindowUpdateFrame& frame) OVERRIDE { |
107 window_update_frames_.push_back(frame); | 112 window_update_frames_.push_back(frame); |
108 return true; | 113 return true; |
109 } | 114 } |
110 | 115 |
111 virtual bool OnBlockedFrame(const QuicBlockedFrame& frame) OVERRIDE { | 116 virtual bool OnBlockedFrame(const QuicBlockedFrame& frame) OVERRIDE { |
112 blocked_frames_.push_back(frame); | 117 blocked_frames_.push_back(frame); |
113 return true; | 118 return true; |
114 } | 119 } |
115 | 120 |
116 virtual void OnPacketComplete() OVERRIDE {} | 121 virtual void OnPacketComplete() OVERRIDE {} |
117 | 122 |
118 const QuicPacketHeader& header() const { return header_; } | 123 const QuicPacketHeader& header() const { return header_; } |
119 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; } | 124 const vector<QuicAckFrame>& ack_frames() const { return ack_frames_; } |
120 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { | 125 const vector<QuicConnectionCloseFrame>& connection_close_frames() const { |
121 return connection_close_frames_; | 126 return connection_close_frames_; |
122 } | 127 } |
123 const vector<QuicCongestionFeedbackFrame>& feedback_frames() const { | 128 const vector<QuicCongestionFeedbackFrame>& feedback_frames() const { |
124 return feedback_frames_; | 129 return feedback_frames_; |
125 } | 130 } |
126 const vector<QuicGoAwayFrame>& goaway_frames() const { | 131 const vector<QuicGoAwayFrame>& goaway_frames() const { |
127 return goaway_frames_; | 132 return goaway_frames_; |
128 } | 133 } |
129 const vector<QuicRstStreamFrame>& rst_stream_frames() const { | 134 const vector<QuicRstStreamFrame>& rst_stream_frames() const { |
130 return rst_stream_frames_; | 135 return rst_stream_frames_; |
131 } | 136 } |
132 const vector<QuicStreamFrame>& stream_frames() const { | 137 const vector<QuicStreamFrame>& stream_frames() const { |
133 return stream_frames_; | 138 return stream_frames_; |
134 } | 139 } |
| 140 const vector<QuicStopWaitingFrame>& stop_waiting_frames() const { |
| 141 return stop_waiting_frames_; |
| 142 } |
135 const vector<QuicWindowUpdateFrame>& window_update_frames() const { | 143 const vector<QuicWindowUpdateFrame>& window_update_frames() const { |
136 return window_update_frames_; | 144 return window_update_frames_; |
137 } | 145 } |
138 const vector<QuicBlockedFrame>& blocked_frames() const { | 146 const vector<QuicBlockedFrame>& blocked_frames() const { |
139 return blocked_frames_; | 147 return blocked_frames_; |
140 } | 148 } |
141 const QuicFecData& fec_data() const { | 149 const QuicFecData& fec_data() const { |
142 return fec_data_; | 150 return fec_data_; |
143 } | 151 } |
144 | 152 |
145 private: | 153 private: |
146 QuicErrorCode error_; | 154 QuicErrorCode error_; |
147 bool has_header_; | 155 bool has_header_; |
148 QuicPacketHeader header_; | 156 QuicPacketHeader header_; |
149 QuicFecData fec_data_; | 157 QuicFecData fec_data_; |
150 string fec_redundancy_; | 158 string fec_redundancy_; |
151 vector<QuicAckFrame> ack_frames_; | 159 vector<QuicAckFrame> ack_frames_; |
152 vector<QuicCongestionFeedbackFrame> feedback_frames_; | 160 vector<QuicCongestionFeedbackFrame> feedback_frames_; |
| 161 vector<QuicStopWaitingFrame> stop_waiting_frames_; |
153 vector<QuicStreamFrame> stream_frames_; | 162 vector<QuicStreamFrame> stream_frames_; |
154 vector<QuicRstStreamFrame> rst_stream_frames_; | 163 vector<QuicRstStreamFrame> rst_stream_frames_; |
155 vector<QuicGoAwayFrame> goaway_frames_; | 164 vector<QuicGoAwayFrame> goaway_frames_; |
156 vector<QuicConnectionCloseFrame> connection_close_frames_; | 165 vector<QuicConnectionCloseFrame> connection_close_frames_; |
157 vector<QuicWindowUpdateFrame> window_update_frames_; | 166 vector<QuicWindowUpdateFrame> window_update_frames_; |
158 vector<QuicBlockedFrame> blocked_frames_; | 167 vector<QuicBlockedFrame> blocked_frames_; |
159 vector<string*> stream_data_; | 168 vector<string*> stream_data_; |
160 | 169 |
161 DISALLOW_COPY_AND_ASSIGN(SimpleFramerVisitor); | 170 DISALLOW_COPY_AND_ASSIGN(SimpleFramerVisitor); |
162 }; | 171 }; |
(...skipping 28 matching lines...) Expand all Loading... |
191 const QuicFecData& SimpleQuicFramer::fec_data() const { | 200 const QuicFecData& SimpleQuicFramer::fec_data() const { |
192 return visitor_->fec_data(); | 201 return visitor_->fec_data(); |
193 } | 202 } |
194 | 203 |
195 QuicFramer* SimpleQuicFramer::framer() { | 204 QuicFramer* SimpleQuicFramer::framer() { |
196 return &framer_; | 205 return &framer_; |
197 } | 206 } |
198 | 207 |
199 size_t SimpleQuicFramer::num_frames() const { | 208 size_t SimpleQuicFramer::num_frames() const { |
200 return ack_frames().size() + | 209 return ack_frames().size() + |
| 210 feedback_frames().size() + |
| 211 goaway_frames().size() + |
| 212 rst_stream_frames().size() + |
| 213 stop_waiting_frames().size() + |
201 stream_frames().size() + | 214 stream_frames().size() + |
202 feedback_frames().size() + | |
203 rst_stream_frames().size() + | |
204 goaway_frames().size() + | |
205 connection_close_frames().size(); | 215 connection_close_frames().size(); |
206 } | 216 } |
207 | 217 |
208 const vector<QuicAckFrame>& SimpleQuicFramer::ack_frames() const { | 218 const vector<QuicAckFrame>& SimpleQuicFramer::ack_frames() const { |
209 return visitor_->ack_frames(); | 219 return visitor_->ack_frames(); |
210 } | 220 } |
211 | 221 |
| 222 const vector<QuicStopWaitingFrame>& |
| 223 SimpleQuicFramer::stop_waiting_frames() const { |
| 224 return visitor_->stop_waiting_frames(); |
| 225 } |
| 226 |
212 const vector<QuicStreamFrame>& SimpleQuicFramer::stream_frames() const { | 227 const vector<QuicStreamFrame>& SimpleQuicFramer::stream_frames() const { |
213 return visitor_->stream_frames(); | 228 return visitor_->stream_frames(); |
214 } | 229 } |
215 | 230 |
216 const vector<QuicRstStreamFrame>& SimpleQuicFramer::rst_stream_frames() const { | 231 const vector<QuicRstStreamFrame>& SimpleQuicFramer::rst_stream_frames() const { |
217 return visitor_->rst_stream_frames(); | 232 return visitor_->rst_stream_frames(); |
218 } | 233 } |
219 | 234 |
220 const vector<QuicCongestionFeedbackFrame>& | 235 const vector<QuicCongestionFeedbackFrame>& |
221 SimpleQuicFramer::feedback_frames() const { | 236 SimpleQuicFramer::feedback_frames() const { |
222 return visitor_->feedback_frames(); | 237 return visitor_->feedback_frames(); |
223 } | 238 } |
224 | 239 |
225 const vector<QuicGoAwayFrame>& | 240 const vector<QuicGoAwayFrame>& |
226 SimpleQuicFramer::goaway_frames() const { | 241 SimpleQuicFramer::goaway_frames() const { |
227 return visitor_->goaway_frames(); | 242 return visitor_->goaway_frames(); |
228 } | 243 } |
229 | 244 |
230 const vector<QuicConnectionCloseFrame>& | 245 const vector<QuicConnectionCloseFrame>& |
231 SimpleQuicFramer::connection_close_frames() const { | 246 SimpleQuicFramer::connection_close_frames() const { |
232 return visitor_->connection_close_frames(); | 247 return visitor_->connection_close_frames(); |
233 } | 248 } |
234 | 249 |
235 } // namespace test | 250 } // namespace test |
236 } // namespace net | 251 } // namespace net |
OLD | NEW |