| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, false); | 287 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, false); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void SendRequestAndExpectQuicResponseFromProxy(const std::string& expected) { | 290 void SendRequestAndExpectQuicResponseFromProxy(const std::string& expected) { |
| 291 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true); | 291 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void AddQuicAlternateProtocolMapping( | 294 void AddQuicAlternateProtocolMapping( |
| 295 MockCryptoClientStream::HandshakeMode handshake_mode) { | 295 MockCryptoClientStream::HandshakeMode handshake_mode) { |
| 296 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); | 296 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); |
| 297 session_->http_server_properties()->SetAlternateProtocol( | 297 session_->http_server_properties()->AddAlternateProtocol( |
| 298 HostPortPair::FromURL(request_.url), 80, QUIC, 1); | 298 HostPortPair::FromURL(request_.url), 80, QUIC, 1.0); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void ExpectBrokenAlternateProtocolMapping() { | 301 void ExpectBrokenAlternateProtocolMapping() { |
| 302 const AlternateProtocolInfo alternate = | 302 const AlternateProtocols alternate_protocols = |
| 303 session_->http_server_properties()->GetAlternateProtocol( | 303 session_->http_server_properties()->GetAlternateProtocols( |
| 304 HostPortPair::FromURL(request_.url)); | 304 HostPortPair::FromURL(request_.url)); |
| 305 EXPECT_NE(UNINITIALIZED_ALTERNATE_PROTOCOL, alternate.protocol); | 305 for (const AlternateProtocolInfo& alternate : alternate_protocols) { |
| 306 EXPECT_TRUE(alternate.is_broken); | 306 if (alternate.is_broken) { |
| 307 return; |
| 308 } |
| 309 } |
| 310 EXPECT_FALSE(true) << "No broken alternate protocol found."; |
| 307 } | 311 } |
| 308 | 312 |
| 309 void ExpectQuicAlternateProtocolMapping() { | 313 void ExpectQuicAlternateProtocolMapping() { |
| 310 const AlternateProtocolInfo alternate = | 314 const AlternateProtocols alternate_protocols = |
| 311 session_->http_server_properties()->GetAlternateProtocol( | 315 session_->http_server_properties()->GetAlternateProtocols( |
| 312 HostPortPair::FromURL(request_.url)); | 316 HostPortPair::FromURL(request_.url)); |
| 313 EXPECT_EQ(QUIC, alternate.protocol); | 317 for (const AlternateProtocolInfo& alternate : alternate_protocols) { |
| 318 if (alternate.protocol == QUIC) { |
| 319 return; |
| 320 } |
| 321 } |
| 322 EXPECT_FALSE(true) << "No QUIC alternate protocol found."; |
| 314 } | 323 } |
| 315 | 324 |
| 316 void AddHangingNonAlternateProtocolSocketData() { | 325 void AddHangingNonAlternateProtocolSocketData() { |
| 317 MockConnect hanging_connect(SYNCHRONOUS, ERR_IO_PENDING); | 326 MockConnect hanging_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 318 hanging_data_.set_connect_data(hanging_connect); | 327 hanging_data_.set_connect_data(hanging_connect); |
| 319 socket_factory_.AddSocketDataProvider(&hanging_data_); | 328 socket_factory_.AddSocketDataProvider(&hanging_data_); |
| 320 } | 329 } |
| 321 | 330 |
| 322 MockClock* clock_; // Owned by QuicStreamFactory after CreateSession. | 331 MockClock* clock_; // Owned by QuicStreamFactory after CreateSession. |
| 323 QuicTestPacketMaker maker_; | 332 QuicTestPacketMaker maker_; |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 nullptr, | 1073 nullptr, |
| 1065 net_log_.bound()); | 1074 net_log_.bound()); |
| 1066 | 1075 |
| 1067 CreateSessionWithNextProtos(); | 1076 CreateSessionWithNextProtos(); |
| 1068 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1077 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 1069 SendRequestAndExpectHttpResponse("hello world"); | 1078 SendRequestAndExpectHttpResponse("hello world"); |
| 1070 } | 1079 } |
| 1071 | 1080 |
| 1072 } // namespace test | 1081 } // namespace test |
| 1073 } // namespace net | 1082 } // namespace net |
| OLD | NEW |