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/spdy/buffered_spdy_framer.h" | 5 #include "net/spdy/buffered_spdy_framer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 altsvc_count_(0), | 27 altsvc_count_(0), |
28 header_stream_id_(static_cast<SpdyStreamId>(-1)), | 28 header_stream_id_(static_cast<SpdyStreamId>(-1)), |
29 promised_stream_id_(static_cast<SpdyStreamId>(-1)) {} | 29 promised_stream_id_(static_cast<SpdyStreamId>(-1)) {} |
30 | 30 |
31 void OnError(SpdyFramer::SpdyFramerError spdy_framer_error) override { | 31 void OnError(SpdyFramer::SpdyFramerError spdy_framer_error) override { |
32 VLOG(1) << "SpdyFramer Error: " << spdy_framer_error; | 32 VLOG(1) << "SpdyFramer Error: " << spdy_framer_error; |
33 error_count_++; | 33 error_count_++; |
34 } | 34 } |
35 | 35 |
36 void OnStreamError(SpdyStreamId stream_id, | 36 void OnStreamError(SpdyStreamId stream_id, |
37 const std::string& description) override { | 37 const SpdyString& description) override { |
38 VLOG(1) << "SpdyFramer Error on stream: " << stream_id << " " | 38 VLOG(1) << "SpdyFramer Error on stream: " << stream_id << " " |
39 << description; | 39 << description; |
40 error_count_++; | 40 error_count_++; |
41 } | 41 } |
42 | 42 |
43 void OnHeaders(SpdyStreamId stream_id, | 43 void OnHeaders(SpdyStreamId stream_id, |
44 bool has_priority, | 44 bool has_priority, |
45 int weight, | 45 int weight, |
46 SpdyStreamId parent_stream_id, | 46 SpdyStreamId parent_stream_id, |
47 bool exclusive, | 47 bool exclusive, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Header block streaming state: | 160 // Header block streaming state: |
161 SpdyStreamId header_stream_id_; | 161 SpdyStreamId header_stream_id_; |
162 SpdyStreamId promised_stream_id_; | 162 SpdyStreamId promised_stream_id_; |
163 | 163 |
164 // Headers from OnHeaders and OnPushPromise for verification. | 164 // Headers from OnHeaders and OnPushPromise for verification. |
165 SpdyHeaderBlock headers_; | 165 SpdyHeaderBlock headers_; |
166 | 166 |
167 // OnGoAway parameters. | 167 // OnGoAway parameters. |
168 SpdyStreamId goaway_last_accepted_stream_id_; | 168 SpdyStreamId goaway_last_accepted_stream_id_; |
169 SpdyErrorCode goaway_error_code_; | 169 SpdyErrorCode goaway_error_code_; |
170 std::string goaway_debug_data_; | 170 SpdyString goaway_debug_data_; |
171 | 171 |
172 // OnAltSvc parameters. | 172 // OnAltSvc parameters. |
173 SpdyStreamId altsvc_stream_id_; | 173 SpdyStreamId altsvc_stream_id_; |
174 std::string altsvc_origin_; | 174 SpdyString altsvc_origin_; |
175 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector_; | 175 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector_; |
176 }; | 176 }; |
177 | 177 |
178 } // namespace | 178 } // namespace |
179 | 179 |
180 class BufferedSpdyFramerTest : public PlatformTest {}; | 180 class BufferedSpdyFramerTest : public PlatformTest {}; |
181 | 181 |
182 TEST_F(BufferedSpdyFramerTest, OnSetting) { | 182 TEST_F(BufferedSpdyFramerTest, OnSetting) { |
183 SpdyFramer framer(SpdyFramer::ENABLE_COMPRESSION); | 183 SpdyFramer framer(SpdyFramer::ENABLE_COMPRESSION); |
184 SpdySettingsIR settings_ir; | 184 SpdySettingsIR settings_ir; |
185 settings_ir.AddSetting(SETTINGS_INITIAL_WINDOW_SIZE, 2); | 185 settings_ir.AddSetting(SETTINGS_INITIAL_WINDOW_SIZE, 2); |
186 settings_ir.AddSetting(SETTINGS_MAX_CONCURRENT_STREAMS, 3); | 186 settings_ir.AddSetting(SETTINGS_MAX_CONCURRENT_STREAMS, 3); |
187 SpdySerializedFrame control_frame(framer.SerializeSettings(settings_ir)); | 187 SpdySerializedFrame control_frame(framer.SerializeSettings(settings_ir)); |
188 TestBufferedSpdyVisitor visitor; | 188 TestBufferedSpdyVisitor visitor; |
189 | 189 |
190 visitor.SimulateInFramer(control_frame); | 190 visitor.SimulateInFramer(control_frame); |
191 EXPECT_EQ(0, visitor.error_count_); | 191 EXPECT_EQ(0, visitor.error_count_); |
192 EXPECT_EQ(2, visitor.setting_count_); | 192 EXPECT_EQ(2, visitor.setting_count_); |
193 } | 193 } |
194 | 194 |
195 TEST_F(BufferedSpdyFramerTest, HeaderListTooLarge) { | 195 TEST_F(BufferedSpdyFramerTest, HeaderListTooLarge) { |
196 SpdyHeaderBlock headers; | 196 SpdyHeaderBlock headers; |
197 std::string long_header_value(256 * 1024, 'x'); | 197 SpdyString long_header_value(256 * 1024, 'x'); |
198 headers["foo"] = long_header_value; | 198 headers["foo"] = long_header_value; |
199 SpdyHeadersIR headers_ir(/*stream_id=*/1, std::move(headers)); | 199 SpdyHeadersIR headers_ir(/*stream_id=*/1, std::move(headers)); |
200 | 200 |
201 BufferedSpdyFramer framer; | 201 BufferedSpdyFramer framer; |
202 SpdySerializedFrame control_frame = framer.SerializeFrame(headers_ir); | 202 SpdySerializedFrame control_frame = framer.SerializeFrame(headers_ir); |
203 | 203 |
204 TestBufferedSpdyVisitor visitor; | 204 TestBufferedSpdyVisitor visitor; |
205 visitor.SimulateInFramer(control_frame); | 205 visitor.SimulateInFramer(control_frame); |
206 | 206 |
207 EXPECT_EQ(1, visitor.error_count_); | 207 EXPECT_EQ(1, visitor.error_count_); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 visitor.SimulateInFramer(altsvc_frame); | 322 visitor.SimulateInFramer(altsvc_frame); |
323 EXPECT_EQ(0, visitor.error_count_); | 323 EXPECT_EQ(0, visitor.error_count_); |
324 EXPECT_EQ(1, visitor.altsvc_count_); | 324 EXPECT_EQ(1, visitor.altsvc_count_); |
325 EXPECT_EQ(altsvc_stream_id, visitor.altsvc_stream_id_); | 325 EXPECT_EQ(altsvc_stream_id, visitor.altsvc_stream_id_); |
326 EXPECT_TRUE(visitor.altsvc_origin_.empty()); | 326 EXPECT_TRUE(visitor.altsvc_origin_.empty()); |
327 ASSERT_EQ(1u, visitor.altsvc_vector_.size()); | 327 ASSERT_EQ(1u, visitor.altsvc_vector_.size()); |
328 EXPECT_EQ(alternative_service, visitor.altsvc_vector_[0]); | 328 EXPECT_EQ(alternative_service, visitor.altsvc_vector_[0]); |
329 } | 329 } |
330 | 330 |
331 } // namespace net | 331 } // namespace net |
OLD | NEW |