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 <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 header_buffer_length_ += len; | 320 header_buffer_length_ += len; |
321 return true; | 321 return true; |
322 } | 322 } |
323 | 323 |
324 virtual void OnSynStream(SpdyStreamId stream_id, | 324 virtual void OnSynStream(SpdyStreamId stream_id, |
325 SpdyStreamId associated_stream_id, | 325 SpdyStreamId associated_stream_id, |
326 SpdyPriority priority, | 326 SpdyPriority priority, |
327 bool fin, | 327 bool fin, |
328 bool unidirectional) OVERRIDE { | 328 bool unidirectional) OVERRIDE { |
329 ++syn_frame_count_; | 329 ++syn_frame_count_; |
330 InitHeaderStreaming(SYN_STREAM, stream_id); | 330 if (framer_.protocol_version() > SPDY3) { |
| 331 InitHeaderStreaming(HEADERS, stream_id); |
| 332 } else { |
| 333 InitHeaderStreaming(SYN_STREAM, stream_id); |
| 334 } |
331 if (fin) { | 335 if (fin) { |
332 ++fin_flag_count_; | 336 ++fin_flag_count_; |
333 } | 337 } |
334 } | 338 } |
335 | 339 |
336 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE { | 340 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE { |
337 ++syn_reply_frame_count_; | 341 ++syn_reply_frame_count_; |
338 InitHeaderStreaming(SYN_REPLY, stream_id); | 342 if (framer_.protocol_version() > SPDY3) { |
| 343 InitHeaderStreaming(HEADERS, stream_id); |
| 344 } else { |
| 345 InitHeaderStreaming(SYN_REPLY, stream_id); |
| 346 } |
339 if (fin) { | 347 if (fin) { |
340 ++fin_flag_count_; | 348 ++fin_flag_count_; |
341 } | 349 } |
342 } | 350 } |
343 | 351 |
344 virtual void OnRstStream(SpdyStreamId stream_id, | 352 virtual void OnRstStream(SpdyStreamId stream_id, |
345 SpdyRstStreamStatus status) OVERRIDE { | 353 SpdyRstStreamStatus status) OVERRIDE { |
346 ++fin_frame_count_; | 354 ++fin_frame_count_; |
347 } | 355 } |
348 | 356 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 size_t bytes_read = | 460 size_t bytes_read = |
453 (rand() % min(input_remaining, kMaxReadSize)) + 1; | 461 (rand() % min(input_remaining, kMaxReadSize)) + 1; |
454 size_t bytes_processed = framer_.ProcessInput(input_ptr, bytes_read); | 462 size_t bytes_processed = framer_.ProcessInput(input_ptr, bytes_read); |
455 input_remaining -= bytes_processed; | 463 input_remaining -= bytes_processed; |
456 input_ptr += bytes_processed; | 464 input_ptr += bytes_processed; |
457 } | 465 } |
458 } | 466 } |
459 | 467 |
460 void InitHeaderStreaming(SpdyFrameType header_control_type, | 468 void InitHeaderStreaming(SpdyFrameType header_control_type, |
461 SpdyStreamId stream_id) { | 469 SpdyStreamId stream_id) { |
462 DCHECK_GE(header_control_type, FIRST_CONTROL_TYPE); | 470 if (!SpdyConstants::IsValidFrameType(framer_.protocol_version(), |
463 DCHECK_LE(header_control_type, LAST_CONTROL_TYPE); | 471 SpdyConstants::SerializeFrameType(framer_.protocol_version(), |
| 472 header_control_type))) { |
| 473 DLOG(FATAL) << "Attempted to init header streaming with " |
| 474 << "invalid control frame type: " |
| 475 << header_control_type; |
| 476 } |
464 memset(header_buffer_.get(), 0, header_buffer_size_); | 477 memset(header_buffer_.get(), 0, header_buffer_size_); |
465 header_buffer_length_ = 0; | 478 header_buffer_length_ = 0; |
466 header_stream_id_ = stream_id; | 479 header_stream_id_ = stream_id; |
467 header_control_type_ = header_control_type; | 480 header_control_type_ = header_control_type; |
468 header_buffer_valid_ = true; | 481 header_buffer_valid_ = true; |
469 DCHECK_NE(header_stream_id_, SpdyFramer::kInvalidStream); | 482 DCHECK_NE(header_stream_id_, SpdyFramer::kInvalidStream); |
470 } | 483 } |
471 | 484 |
472 // Override the default buffer size (16K). Call before using the framer! | 485 // Override the default buffer size (16K). Call before using the framer! |
473 void set_header_buffer_size(size_t header_buffer_size) { | 486 void set_header_buffer_size(size_t header_buffer_size) { |
(...skipping 3836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4310 EXPECT_STREQ("DATA", | 4323 EXPECT_STREQ("DATA", |
4311 SpdyFramer::FrameTypeToString(DATA)); | 4324 SpdyFramer::FrameTypeToString(DATA)); |
4312 EXPECT_STREQ("SYN_STREAM", | 4325 EXPECT_STREQ("SYN_STREAM", |
4313 SpdyFramer::FrameTypeToString(SYN_STREAM)); | 4326 SpdyFramer::FrameTypeToString(SYN_STREAM)); |
4314 EXPECT_STREQ("SYN_REPLY", | 4327 EXPECT_STREQ("SYN_REPLY", |
4315 SpdyFramer::FrameTypeToString(SYN_REPLY)); | 4328 SpdyFramer::FrameTypeToString(SYN_REPLY)); |
4316 EXPECT_STREQ("RST_STREAM", | 4329 EXPECT_STREQ("RST_STREAM", |
4317 SpdyFramer::FrameTypeToString(RST_STREAM)); | 4330 SpdyFramer::FrameTypeToString(RST_STREAM)); |
4318 EXPECT_STREQ("SETTINGS", | 4331 EXPECT_STREQ("SETTINGS", |
4319 SpdyFramer::FrameTypeToString(SETTINGS)); | 4332 SpdyFramer::FrameTypeToString(SETTINGS)); |
4320 EXPECT_STREQ("NOOP", | |
4321 SpdyFramer::FrameTypeToString(NOOP)); | |
4322 EXPECT_STREQ("PING", | 4333 EXPECT_STREQ("PING", |
4323 SpdyFramer::FrameTypeToString(PING)); | 4334 SpdyFramer::FrameTypeToString(PING)); |
4324 EXPECT_STREQ("GOAWAY", | 4335 EXPECT_STREQ("GOAWAY", |
4325 SpdyFramer::FrameTypeToString(GOAWAY)); | 4336 SpdyFramer::FrameTypeToString(GOAWAY)); |
4326 EXPECT_STREQ("HEADERS", | 4337 EXPECT_STREQ("HEADERS", |
4327 SpdyFramer::FrameTypeToString(HEADERS)); | 4338 SpdyFramer::FrameTypeToString(HEADERS)); |
4328 EXPECT_STREQ("WINDOW_UPDATE", | 4339 EXPECT_STREQ("WINDOW_UPDATE", |
4329 SpdyFramer::FrameTypeToString(WINDOW_UPDATE)); | 4340 SpdyFramer::FrameTypeToString(WINDOW_UPDATE)); |
4330 EXPECT_STREQ("PUSH_PROMISE", | 4341 EXPECT_STREQ("PUSH_PROMISE", |
4331 SpdyFramer::FrameTypeToString(PUSH_PROMISE)); | 4342 SpdyFramer::FrameTypeToString(PUSH_PROMISE)); |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5435 EXPECT_EQ(4u, framer.MapWeightToPriority(109)); | 5446 EXPECT_EQ(4u, framer.MapWeightToPriority(109)); |
5436 EXPECT_EQ(4u, framer.MapWeightToPriority(74)); | 5447 EXPECT_EQ(4u, framer.MapWeightToPriority(74)); |
5437 EXPECT_EQ(5u, framer.MapWeightToPriority(73)); | 5448 EXPECT_EQ(5u, framer.MapWeightToPriority(73)); |
5438 EXPECT_EQ(5u, framer.MapWeightToPriority(37)); | 5449 EXPECT_EQ(5u, framer.MapWeightToPriority(37)); |
5439 EXPECT_EQ(6u, framer.MapWeightToPriority(36)); | 5450 EXPECT_EQ(6u, framer.MapWeightToPriority(36)); |
5440 EXPECT_EQ(6u, framer.MapWeightToPriority(1)); | 5451 EXPECT_EQ(6u, framer.MapWeightToPriority(1)); |
5441 EXPECT_EQ(7u, framer.MapWeightToPriority(0)); | 5452 EXPECT_EQ(7u, framer.MapWeightToPriority(0)); |
5442 } | 5453 } |
5443 | 5454 |
5444 } // namespace net | 5455 } // namespace net |
OLD | NEW |