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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 959743002: Account for HTTP/2 padding in receive windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more mock implementation. Created 5 years, 9 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/spdy/spdy_session.cc ('k') | net/spdy/spdy_stream.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/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 3612 matching lines...) Expand 10 before | Expand all | Expand 10 after
3623 3623
3624 data.RunFor(1); 3624 data.RunFor(1);
3625 3625
3626 EXPECT_EQ(SpdySession::GetInitialWindowSize(GetParam()), 3626 EXPECT_EQ(SpdySession::GetInitialWindowSize(GetParam()),
3627 session->session_recv_window_size_); 3627 session->session_recv_window_size_);
3628 EXPECT_EQ(kUploadDataSize, session->session_unacked_recv_window_bytes_); 3628 EXPECT_EQ(kUploadDataSize, session->session_unacked_recv_window_bytes_);
3629 3629
3630 data.RunFor(1); 3630 data.RunFor(1);
3631 } 3631 }
3632 3632
3633 // The frame header is not included in flow control, but frame payload
3634 // (including optional pad length and padding) is.
3635 TEST_P(SpdySessionTest, SessionFlowControlPadding) {
3636 // Padding only exists in HTTP/2.
3637 if (GetParam() < kProtoSPDY4MinimumVersion)
3638 return;
3639
3640 session_deps_.host_resolver->set_synchronous_mode(true);
3641
3642 const int padding_length = 42;
3643 MockConnect connect_data(SYNCHRONOUS, OK);
3644 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyBodyFrame(
3645 1, kUploadData, kUploadDataSize, false, padding_length));
3646 MockRead reads[] = {
3647 CreateMockRead(*resp, 0), MockRead(ASYNC, 0, 1) // EOF
3648 };
3649 DeterministicSocketData data(reads, arraysize(reads), NULL, 0);
3650 data.set_connect_data(connect_data);
3651 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data);
3652
3653 CreateDeterministicNetworkSession();
3654 base::WeakPtr<SpdySession> session =
3655 CreateInsecureSpdySession(http_session_, key_, BoundNetLog());
3656 EXPECT_EQ(SpdySession::FLOW_CONTROL_STREAM_AND_SESSION,
3657 session->flow_control_state());
3658
3659 EXPECT_EQ(SpdySession::GetInitialWindowSize(GetParam()),
3660 session->session_recv_window_size_);
3661 EXPECT_EQ(0, session->session_unacked_recv_window_bytes_);
3662
3663 data.RunFor(1);
3664
3665 EXPECT_EQ(SpdySession::GetInitialWindowSize(GetParam()),
3666 session->session_recv_window_size_);
3667 EXPECT_EQ(kUploadDataSize + padding_length,
3668 session->session_unacked_recv_window_bytes_);
3669
3670 data.RunFor(1);
3671 }
3672
3633 // A delegate that drops any received data. 3673 // A delegate that drops any received data.
3634 class DropReceivedDataDelegate : public test::StreamDelegateSendImmediate { 3674 class DropReceivedDataDelegate : public test::StreamDelegateSendImmediate {
3635 public: 3675 public:
3636 DropReceivedDataDelegate(const base::WeakPtr<SpdyStream>& stream, 3676 DropReceivedDataDelegate(const base::WeakPtr<SpdyStream>& stream,
3637 base::StringPiece data) 3677 base::StringPiece data)
3638 : StreamDelegateSendImmediate(stream, data) {} 3678 : StreamDelegateSendImmediate(stream, data) {}
3639 3679
3640 ~DropReceivedDataDelegate() override {} 3680 ~DropReceivedDataDelegate() override {}
3641 3681
3642 // Drop any received data. 3682 // Drop any received data.
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
5124 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5164 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5125 "spdy_pooling.pem"); 5165 "spdy_pooling.pem");
5126 ssl_info.is_issued_by_known_root = true; 5166 ssl_info.is_issued_by_known_root = true;
5127 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5167 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5128 5168
5129 EXPECT_TRUE(SpdySession::CanPool( 5169 EXPECT_TRUE(SpdySession::CanPool(
5130 &tss, ssl_info, "www.example.org", "mail.example.org")); 5170 &tss, ssl_info, "www.example.org", "mail.example.org"));
5131 } 5171 }
5132 5172
5133 } // namespace net 5173 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | net/spdy/spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698