Chromium Code Reviews| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 std::vector<QuicEncryptedPacket*> packets_; | 98 std::vector<QuicEncryptedPacket*> packets_; |
| 99 std::vector<MockWrite> writes_; | 99 std::vector<MockWrite> writes_; |
| 100 std::vector<MockRead> reads_; | 100 std::vector<MockRead> reads_; |
| 101 size_t sequence_number_; | 101 size_t sequence_number_; |
| 102 scoped_ptr<SocketDataProvider> socket_data_; | 102 scoped_ptr<SocketDataProvider> socket_data_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 class ProxyHeadersHandler { | |
| 106 public: | |
| 107 ProxyHeadersHandler() : was_called_(false) {} | |
| 108 | |
| 109 bool WasCalled() { return was_called_; } | |
| 110 | |
| 111 void OnBeforeProxyHeadersSent(const ProxyInfo& proxy_info, | |
| 112 HttpRequestHeaders* request_headers) { | |
| 113 was_called_ = true; | |
| 114 } | |
| 115 | |
| 116 private: | |
| 117 bool was_called_; | |
| 118 }; | |
| 119 | |
| 105 class QuicNetworkTransactionTest | 120 class QuicNetworkTransactionTest |
| 106 : public PlatformTest, | 121 : public PlatformTest, |
| 107 public ::testing::WithParamInterface<QuicVersion> { | 122 public ::testing::WithParamInterface<QuicVersion> { |
| 108 protected: | 123 protected: |
| 109 QuicNetworkTransactionTest() | 124 QuicNetworkTransactionTest() |
| 110 : clock_(new MockClock), | 125 : clock_(new MockClock), |
| 111 maker_(GetParam(), 0, clock_), | 126 maker_(GetParam(), 0, clock_), |
| 112 ssl_config_service_(new SSLConfigServiceDefaults), | 127 ssl_config_service_(new SSLConfigServiceDefaults), |
| 113 proxy_service_(ProxyService::CreateDirect()), | 128 proxy_service_(ProxyService::CreateDirect()), |
| 114 auth_handler_factory_( | 129 auth_handler_factory_( |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 } | 276 } |
| 262 | 277 |
| 263 void SendRequestAndExpectHttpResponse(const std::string& expected) { | 278 void SendRequestAndExpectHttpResponse(const std::string& expected) { |
| 264 scoped_ptr<HttpNetworkTransaction> trans( | 279 scoped_ptr<HttpNetworkTransaction> trans( |
| 265 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 280 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
| 266 RunTransaction(trans.get()); | 281 RunTransaction(trans.get()); |
| 267 CheckWasHttpResponse(trans); | 282 CheckWasHttpResponse(trans); |
| 268 CheckResponseData(trans.get(), expected); | 283 CheckResponseData(trans.get(), expected); |
| 269 } | 284 } |
| 270 | 285 |
| 271 void SendRequestAndExpectQuicResponse(const std::string& expected) { | 286 void SendRequestAndExpectQuicResponse(const std::string& expected, |
| 287 bool expect_headers_callback = false) { | |
|
bengr
2015/02/05 00:34:07
Don't use default values
tbansal1
2015/02/05 01:06:45
Done.
| |
| 272 scoped_ptr<HttpNetworkTransaction> trans( | 288 scoped_ptr<HttpNetworkTransaction> trans( |
| 273 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 289 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
| 290 ProxyHeadersHandler proxy_headers_handler; | |
| 291 trans->SetBeforeProxyHeadersSentCallback( | |
| 292 base::Bind(&ProxyHeadersHandler::OnBeforeProxyHeadersSent, | |
| 293 base::Unretained(&proxy_headers_handler))); | |
| 274 RunTransaction(trans.get()); | 294 RunTransaction(trans.get()); |
| 275 CheckWasQuicResponse(trans); | 295 CheckWasQuicResponse(trans); |
| 276 CheckResponseData(trans.get(), expected); | 296 CheckResponseData(trans.get(), expected); |
| 297 EXPECT_TRUE(!expect_headers_callback || proxy_headers_handler.WasCalled()); | |
| 277 } | 298 } |
| 278 | 299 |
| 279 void AddQuicAlternateProtocolMapping( | 300 void AddQuicAlternateProtocolMapping( |
| 280 MockCryptoClientStream::HandshakeMode handshake_mode) { | 301 MockCryptoClientStream::HandshakeMode handshake_mode) { |
| 281 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); | 302 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); |
| 282 session_->http_server_properties()->SetAlternateProtocol( | 303 session_->http_server_properties()->SetAlternateProtocol( |
| 283 HostPortPair::FromURL(request_.url), 80, QUIC, 1); | 304 HostPortPair::FromURL(request_.url), 80, QUIC, 1); |
| 284 } | 305 } |
| 285 | 306 |
| 286 void ExpectBrokenAlternateProtocolMapping() { | 307 void ExpectBrokenAlternateProtocolMapping() { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 428 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
| 408 mock_quic_data.AddRead(SYNCHRONOUS, 0); // EOF | 429 mock_quic_data.AddRead(SYNCHRONOUS, 0); // EOF |
| 409 | 430 |
| 410 mock_quic_data.AddDelayedSocketDataToFactory(&socket_factory_, 1); | 431 mock_quic_data.AddDelayedSocketDataToFactory(&socket_factory_, 1); |
| 411 | 432 |
| 412 // There is no need to set up an alternate protocol job, because | 433 // There is no need to set up an alternate protocol job, because |
| 413 // no attempt will be made to speak to the proxy over TCP. | 434 // no attempt will be made to speak to the proxy over TCP. |
| 414 | 435 |
| 415 CreateSession(); | 436 CreateSession(); |
| 416 | 437 |
| 417 SendRequestAndExpectQuicResponse("hello!"); | 438 SendRequestAndExpectQuicResponse("hello!", true); |
| 418 } | 439 } |
| 419 | 440 |
| 420 TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { | 441 TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { |
| 421 params_.origin_to_force_quic_on = | 442 params_.origin_to_force_quic_on = |
| 422 HostPortPair::FromString("www.google.com:80"); | 443 HostPortPair::FromString("www.google.com:80"); |
| 423 | 444 |
| 424 MockQuicData mock_quic_data; | 445 MockQuicData mock_quic_data; |
| 425 mock_quic_data.AddRead(ASYNC, ERR_SOCKET_NOT_CONNECTED); | 446 mock_quic_data.AddRead(ASYNC, ERR_SOCKET_NOT_CONNECTED); |
| 426 | 447 |
| 427 mock_quic_data.AddDelayedSocketDataToFactory(&socket_factory_, 0); | 448 mock_quic_data.AddDelayedSocketDataToFactory(&socket_factory_, 0); |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1035 nullptr, | 1056 nullptr, |
| 1036 net_log_.bound()); | 1057 net_log_.bound()); |
| 1037 | 1058 |
| 1038 CreateSessionWithNextProtos(); | 1059 CreateSessionWithNextProtos(); |
| 1039 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1060 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 1040 SendRequestAndExpectHttpResponse("hello world"); | 1061 SendRequestAndExpectHttpResponse("hello world"); |
| 1041 } | 1062 } |
| 1042 | 1063 |
| 1043 } // namespace test | 1064 } // namespace test |
| 1044 } // namespace net | 1065 } // namespace net |
| 1066 | |
|
bengr
2015/02/05 00:34:07
Remove the newline
tbansal1
2015/02/05 01:06:45
Done.
| |
| OLD | NEW |