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

Side by Side Diff: net/spdy/core/spdy_framer_test.cc

Issue 2849713002: Remove one layer of abstraction from HTTP/2 frame representations. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | net/spdy/core/spdy_protocol.h » ('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/spdy/core/spdy_framer.h" 5 #include "net/spdy/core/spdy_framer.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 error_count_(0), 389 error_count_(0),
390 headers_frame_count_(0), 390 headers_frame_count_(0),
391 push_promise_frame_count_(0), 391 push_promise_frame_count_(0),
392 goaway_count_(0), 392 goaway_count_(0),
393 setting_count_(0), 393 setting_count_(0),
394 settings_ack_sent_(0), 394 settings_ack_sent_(0),
395 settings_ack_received_(0), 395 settings_ack_received_(0),
396 continuation_count_(0), 396 continuation_count_(0),
397 altsvc_count_(0), 397 altsvc_count_(0),
398 priority_count_(0), 398 priority_count_(0),
399 test_altsvc_ir_(0),
400 on_unknown_frame_result_(false), 399 on_unknown_frame_result_(false),
401 last_window_update_stream_(0), 400 last_window_update_stream_(0),
402 last_window_update_delta_(0), 401 last_window_update_delta_(0),
403 last_push_promise_stream_(0), 402 last_push_promise_stream_(0),
404 last_push_promise_promised_stream_(0), 403 last_push_promise_promised_stream_(0),
405 data_bytes_(0), 404 data_bytes_(0),
406 fin_frame_count_(0), 405 fin_frame_count_(0),
407 fin_flag_count_(0), 406 fin_flag_count_(0),
408 end_of_stream_count_(0), 407 end_of_stream_count_(0),
409 control_frame_header_data_count_(0), 408 control_frame_header_data_count_(0),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 VLOG(1) << "OnContinuation(" << stream_id << ", " << end << ")"; 543 VLOG(1) << "OnContinuation(" << stream_id << ", " << end << ")";
545 ++continuation_count_; 544 ++continuation_count_;
546 } 545 }
547 546
548 void OnAltSvc(SpdyStreamId stream_id, 547 void OnAltSvc(SpdyStreamId stream_id,
549 SpdyStringPiece origin, 548 SpdyStringPiece origin,
550 const SpdyAltSvcWireFormat::AlternativeServiceVector& 549 const SpdyAltSvcWireFormat::AlternativeServiceVector&
551 altsvc_vector) override { 550 altsvc_vector) override {
552 VLOG(1) << "OnAltSvc(" << stream_id << ", \"" << origin 551 VLOG(1) << "OnAltSvc(" << stream_id << ", \"" << origin
553 << "\", altsvc_vector)"; 552 << "\", altsvc_vector)";
554 test_altsvc_ir_.set_stream_id(stream_id); 553 test_altsvc_ir_ = SpdyMakeUnique<SpdyAltSvcIR>(stream_id);
555 if (origin.length() > 0) { 554 if (origin.length() > 0) {
556 test_altsvc_ir_.set_origin(SpdyString(origin)); 555 test_altsvc_ir_->set_origin(SpdyString(origin));
557 } 556 }
558 for (const auto& altsvc : altsvc_vector) { 557 for (const auto& altsvc : altsvc_vector) {
559 test_altsvc_ir_.add_altsvc(altsvc); 558 test_altsvc_ir_->add_altsvc(altsvc);
560 } 559 }
561 ++altsvc_count_; 560 ++altsvc_count_;
562 } 561 }
563 562
564 void OnPriority(SpdyStreamId stream_id, 563 void OnPriority(SpdyStreamId stream_id,
565 SpdyStreamId parent_stream_id, 564 SpdyStreamId parent_stream_id,
566 int weight, 565 int weight,
567 bool exclusive) override { 566 bool exclusive) override {
568 VLOG(1) << "OnPriority(" << stream_id << ", " << parent_stream_id << ", " 567 VLOG(1) << "OnPriority(" << stream_id << ", " << parent_stream_id << ", "
569 << weight << ", " << (exclusive ? 1 : 0) << ")"; 568 << weight << ", " << (exclusive ? 1 : 0) << ")";
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 int error_count_; 656 int error_count_;
658 int headers_frame_count_; 657 int headers_frame_count_;
659 int push_promise_frame_count_; 658 int push_promise_frame_count_;
660 int goaway_count_; 659 int goaway_count_;
661 int setting_count_; 660 int setting_count_;
662 int settings_ack_sent_; 661 int settings_ack_sent_;
663 int settings_ack_received_; 662 int settings_ack_received_;
664 int continuation_count_; 663 int continuation_count_;
665 int altsvc_count_; 664 int altsvc_count_;
666 int priority_count_; 665 int priority_count_;
667 SpdyAltSvcIR test_altsvc_ir_; 666 std::unique_ptr<SpdyAltSvcIR> test_altsvc_ir_;
668 bool on_unknown_frame_result_; 667 bool on_unknown_frame_result_;
669 SpdyStreamId last_window_update_stream_; 668 SpdyStreamId last_window_update_stream_;
670 int last_window_update_delta_; 669 int last_window_update_delta_;
671 SpdyStreamId last_push_promise_stream_; 670 SpdyStreamId last_push_promise_stream_;
672 SpdyStreamId last_push_promise_promised_stream_; 671 SpdyStreamId last_push_promise_promised_stream_;
673 int data_bytes_; 672 int data_bytes_;
674 int fin_frame_count_; // The count of RST_STREAM type frames received. 673 int fin_frame_count_; // The count of RST_STREAM type frames received.
675 int fin_flag_count_; // The count of frames with the FIN flag set. 674 int fin_flag_count_; // The count of frames with the FIN flag set.
676 int end_of_stream_count_; // The count of zero-length data frames. 675 int end_of_stream_count_; // The count of zero-length data frames.
677 int control_frame_header_data_count_; // The count of chunks received. 676 int control_frame_header_data_count_; // The count of chunks received.
(...skipping 3808 matching lines...) Expand 10 before | Expand all | Expand 10 after
4486 while (unframed_data > 0) { 4485 while (unframed_data > 0) {
4487 size_t to_read = std::min(kReadChunkSize, unframed_data); 4486 size_t to_read = std::min(kReadChunkSize, unframed_data);
4488 visitor.SimulateInFramer( 4487 visitor.SimulateInFramer(
4489 reinterpret_cast<unsigned char*>(control_frame.data() + framed_data), 4488 reinterpret_cast<unsigned char*>(control_frame.data() + framed_data),
4490 to_read); 4489 to_read);
4491 unframed_data -= to_read; 4490 unframed_data -= to_read;
4492 framed_data += to_read; 4491 framed_data += to_read;
4493 } 4492 }
4494 EXPECT_EQ(0, visitor.error_count_); 4493 EXPECT_EQ(0, visitor.error_count_);
4495 EXPECT_EQ(1, visitor.altsvc_count_); 4494 EXPECT_EQ(1, visitor.altsvc_count_);
4496 ASSERT_EQ(2u, visitor.test_altsvc_ir_.altsvc_vector().size()); 4495 ASSERT_NE(nullptr, visitor.test_altsvc_ir_);
4497 EXPECT_TRUE(visitor.test_altsvc_ir_.altsvc_vector()[0] == altsvc1); 4496 ASSERT_EQ(2u, visitor.test_altsvc_ir_->altsvc_vector().size());
4498 EXPECT_TRUE(visitor.test_altsvc_ir_.altsvc_vector()[1] == altsvc2); 4497 EXPECT_TRUE(visitor.test_altsvc_ir_->altsvc_vector()[0] == altsvc1);
4498 EXPECT_TRUE(visitor.test_altsvc_ir_->altsvc_vector()[1] == altsvc2);
4499 } 4499 }
4500 4500
4501 // While RFC7838 Section 4 says that an ALTSVC frame on stream 0 with empty 4501 // While RFC7838 Section 4 says that an ALTSVC frame on stream 0 with empty
4502 // origin MUST be ignored, it is not implemented at the framer level: instead, 4502 // origin MUST be ignored, it is not implemented at the framer level: instead,
4503 // such frames are passed on to the consumer. 4503 // such frames are passed on to the consumer.
4504 TEST_P(SpdyFramerTest, ReadAltSvcFrame) { 4504 TEST_P(SpdyFramerTest, ReadAltSvcFrame) {
4505 constexpr struct { 4505 constexpr struct {
4506 uint32_t stream_id; 4506 uint32_t stream_id;
4507 const char* origin; 4507 const char* origin;
4508 } test_cases[] = {{0, ""}, 4508 } test_cases[] = {{0, ""},
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
4812 4812
4813 EXPECT_EQ(1, visitor->data_frame_count_); 4813 EXPECT_EQ(1, visitor->data_frame_count_);
4814 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_)); 4814 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_));
4815 EXPECT_EQ(0, visitor->headers_frame_count_); 4815 EXPECT_EQ(0, visitor->headers_frame_count_);
4816 } 4816 }
4817 } 4817 }
4818 4818
4819 } // namespace test 4819 } // namespace test
4820 4820
4821 } // namespace net 4821 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/core/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698