| 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/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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 SpdySessionPool* spdy_session_pool_; | 175 SpdySessionPool* spdy_session_pool_; |
| 176 GURL test_url_; | 176 GURL test_url_; |
| 177 HostPortPair test_host_port_pair_; | 177 HostPortPair test_host_port_pair_; |
| 178 SpdySessionKey key_; | 178 SpdySessionKey key_; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 INSTANTIATE_TEST_CASE_P( | 181 INSTANTIATE_TEST_CASE_P( |
| 182 NextProto, | 182 NextProto, |
| 183 SpdySessionTest, | 183 SpdySessionTest, |
| 184 testing::Values(kProtoDeprecatedSPDY2, | 184 testing::Values(kProtoDeprecatedSPDY2, |
| 185 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); | 185 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4_14, kProtoSPDY4_15)); |
| 186 | 186 |
| 187 // Try to create a SPDY session that will fail during | 187 // Try to create a SPDY session that will fail during |
| 188 // initialization. Nothing should blow up. | 188 // initialization. Nothing should blow up. |
| 189 TEST_P(SpdySessionTest, InitialReadError) { | 189 TEST_P(SpdySessionTest, InitialReadError) { |
| 190 CreateDeterministicNetworkSession(); | 190 CreateDeterministicNetworkSession(); |
| 191 | 191 |
| 192 base::WeakPtr<SpdySession> session = TryCreateFakeSpdySessionExpectingFailure( | 192 base::WeakPtr<SpdySession> session = TryCreateFakeSpdySessionExpectingFailure( |
| 193 spdy_session_pool_, key_, ERR_CONNECTION_CLOSED); | 193 spdy_session_pool_, key_, ERR_CONNECTION_CLOSED); |
| 194 EXPECT_TRUE(session); | 194 EXPECT_TRUE(session); |
| 195 // Flush the read. | 195 // Flush the read. |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kInitialRecvWindowSize); | 1549 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kInitialRecvWindowSize); |
| 1550 } | 1550 } |
| 1551 MockConnect connect_data(SYNCHRONOUS, OK); | 1551 MockConnect connect_data(SYNCHRONOUS, OK); |
| 1552 scoped_ptr<SpdyFrame> settings_frame( | 1552 scoped_ptr<SpdyFrame> settings_frame( |
| 1553 spdy_util_.ConstructSpdySettings(settings)); | 1553 spdy_util_.ConstructSpdySettings(settings)); |
| 1554 scoped_ptr<SpdyFrame> initial_window_update( | 1554 scoped_ptr<SpdyFrame> initial_window_update( |
| 1555 spdy_util_.ConstructSpdyWindowUpdate( | 1555 spdy_util_.ConstructSpdyWindowUpdate( |
| 1556 kSessionFlowControlStreamId, | 1556 kSessionFlowControlStreamId, |
| 1557 kDefaultInitialRecvWindowSize - kSpdySessionInitialWindowSize)); | 1557 kDefaultInitialRecvWindowSize - kSpdySessionInitialWindowSize)); |
| 1558 std::vector<MockWrite> writes; | 1558 std::vector<MockWrite> writes; |
| 1559 if (GetParam() == kProtoSPDY4) { | 1559 if ((GetParam() >= kProtoSPDY4MinimumVersion) && |
| 1560 (GetParam() <= kProtoSPDY4MaximumVersion)) { |
| 1560 writes.push_back( | 1561 writes.push_back( |
| 1561 MockWrite(ASYNC, | 1562 MockWrite(ASYNC, |
| 1562 kHttp2ConnectionHeaderPrefix, | 1563 kHttp2ConnectionHeaderPrefix, |
| 1563 kHttp2ConnectionHeaderPrefixSize)); | 1564 kHttp2ConnectionHeaderPrefixSize)); |
| 1564 } | 1565 } |
| 1565 writes.push_back(CreateMockWrite(*settings_frame)); | 1566 writes.push_back(CreateMockWrite(*settings_frame)); |
| 1566 if (GetParam() >= kProtoSPDY31) { | 1567 if (GetParam() >= kProtoSPDY31) { |
| 1567 writes.push_back(CreateMockWrite(*initial_window_update)); | 1568 writes.push_back(CreateMockWrite(*initial_window_update)); |
| 1568 }; | 1569 }; |
| 1569 | 1570 |
| (...skipping 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5012 MapFramerErrorToNetError(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE)); | 5013 MapFramerErrorToNetError(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE)); |
| 5013 } | 5014 } |
| 5014 | 5015 |
| 5015 TEST(MapRstStreamStatusToProtocolError, MapsValues) { | 5016 TEST(MapRstStreamStatusToProtocolError, MapsValues) { |
| 5016 CHECK_EQ(STATUS_CODE_PROTOCOL_ERROR, | 5017 CHECK_EQ(STATUS_CODE_PROTOCOL_ERROR, |
| 5017 MapRstStreamStatusToProtocolError(RST_STREAM_PROTOCOL_ERROR)); | 5018 MapRstStreamStatusToProtocolError(RST_STREAM_PROTOCOL_ERROR)); |
| 5018 CHECK_EQ(STATUS_CODE_FRAME_SIZE_ERROR, | 5019 CHECK_EQ(STATUS_CODE_FRAME_SIZE_ERROR, |
| 5019 MapRstStreamStatusToProtocolError(RST_STREAM_FRAME_SIZE_ERROR)); | 5020 MapRstStreamStatusToProtocolError(RST_STREAM_FRAME_SIZE_ERROR)); |
| 5020 CHECK_EQ(STATUS_CODE_ENHANCE_YOUR_CALM, | 5021 CHECK_EQ(STATUS_CODE_ENHANCE_YOUR_CALM, |
| 5021 MapRstStreamStatusToProtocolError(RST_STREAM_ENHANCE_YOUR_CALM)); | 5022 MapRstStreamStatusToProtocolError(RST_STREAM_ENHANCE_YOUR_CALM)); |
| 5023 CHECK_EQ(STATUS_CODE_INADEQUATE_SECURITY, |
| 5024 MapRstStreamStatusToProtocolError(RST_STREAM_INADEQUATE_SECURITY)); |
| 5025 CHECK_EQ(STATUS_CODE_HTTP_1_1_REQUIRED, |
| 5026 MapRstStreamStatusToProtocolError(RST_STREAM_HTTP_1_1_REQUIRED)); |
| 5022 } | 5027 } |
| 5023 | 5028 |
| 5024 TEST(MapNetErrorToGoAwayStatus, MapsValue) { | 5029 TEST(MapNetErrorToGoAwayStatus, MapsValue) { |
| 5025 CHECK_EQ(GOAWAY_INADEQUATE_SECURITY, | 5030 CHECK_EQ(GOAWAY_INADEQUATE_SECURITY, |
| 5026 MapNetErrorToGoAwayStatus(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY)); | 5031 MapNetErrorToGoAwayStatus(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY)); |
| 5027 CHECK_EQ(GOAWAY_FLOW_CONTROL_ERROR, | 5032 CHECK_EQ(GOAWAY_FLOW_CONTROL_ERROR, |
| 5028 MapNetErrorToGoAwayStatus(ERR_SPDY_FLOW_CONTROL_ERROR)); | 5033 MapNetErrorToGoAwayStatus(ERR_SPDY_FLOW_CONTROL_ERROR)); |
| 5029 CHECK_EQ(GOAWAY_PROTOCOL_ERROR, | 5034 CHECK_EQ(GOAWAY_PROTOCOL_ERROR, |
| 5030 MapNetErrorToGoAwayStatus(ERR_SPDY_PROTOCOL_ERROR)); | 5035 MapNetErrorToGoAwayStatus(ERR_SPDY_PROTOCOL_ERROR)); |
| 5031 CHECK_EQ(GOAWAY_COMPRESSION_ERROR, | 5036 CHECK_EQ(GOAWAY_COMPRESSION_ERROR, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5133 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5138 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
| 5134 "spdy_pooling.pem"); | 5139 "spdy_pooling.pem"); |
| 5135 ssl_info.is_issued_by_known_root = true; | 5140 ssl_info.is_issued_by_known_root = true; |
| 5136 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5141 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
| 5137 | 5142 |
| 5138 EXPECT_TRUE(SpdySession::CanPool( | 5143 EXPECT_TRUE(SpdySession::CanPool( |
| 5139 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5144 &tss, ssl_info, "www.example.org", "mail.example.org")); |
| 5140 } | 5145 } |
| 5141 | 5146 |
| 5142 } // namespace net | 5147 } // namespace net |
| OLD | NEW |