| 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "net/base/chunked_upload_data_stream.h" |
| 13 #include "net/base/network_quality_estimator.h" | 14 #include "net/base/network_quality_estimator.h" |
| 14 #include "net/base/socket_performance_watcher.h" | 15 #include "net/base/socket_performance_watcher.h" |
| 15 #include "net/base/test_completion_callback.h" | 16 #include "net/base/test_completion_callback.h" |
| 16 #include "net/base/test_data_directory.h" | 17 #include "net/base/test_data_directory.h" |
| 17 #include "net/cert/mock_cert_verifier.h" | 18 #include "net/cert/mock_cert_verifier.h" |
| 18 #include "net/cert/multi_log_ct_verifier.h" | 19 #include "net/cert/multi_log_ct_verifier.h" |
| 19 #include "net/dns/mock_host_resolver.h" | 20 #include "net/dns/mock_host_resolver.h" |
| 20 #include "net/http/http_auth_handler_factory.h" | 21 #include "net/http/http_auth_handler_factory.h" |
| 21 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
| 22 #include "net/http/http_network_transaction.h" | 23 #include "net/http/http_network_transaction.h" |
| (...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2252 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 2253 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 2253 | 2254 |
| 2254 request_.url = GURL("https://www.example.org:443"); | 2255 request_.url = GURL("https://www.example.org:443"); |
| 2255 AddHangingNonAlternateProtocolSocketData(); | 2256 AddHangingNonAlternateProtocolSocketData(); |
| 2256 CreateSessionWithNextProtos(); | 2257 CreateSessionWithNextProtos(); |
| 2257 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2258 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2258 SendRequestAndExpectQuicResponse("hello!"); | 2259 SendRequestAndExpectQuicResponse("hello!"); |
| 2259 EXPECT_TRUE(rtt_observer_.rtt_notification_received()); | 2260 EXPECT_TRUE(rtt_observer_.rtt_notification_received()); |
| 2260 } | 2261 } |
| 2261 | 2262 |
| 2263 TEST_P(QuicNetworkTransactionTest, QuicUpload) { |
| 2264 params_.origin_to_force_quic_on = |
| 2265 HostPortPair::FromString("mail.example.com:443"); |
| 2266 |
| 2267 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 2268 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)}; |
| 2269 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 2270 arraysize(writes)); |
| 2271 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2272 |
| 2273 // The non-alternate protocol job needs to hang in order to guarantee that |
| 2274 // the alternate-protocol job will "win". |
| 2275 AddHangingNonAlternateProtocolSocketData(); |
| 2276 |
| 2277 CreateSession(); |
| 2278 request_.method = "POST"; |
| 2279 ChunkedUploadDataStream upload_data(0); |
| 2280 upload_data.AppendData("1", 1, true); |
| 2281 |
| 2282 request_.upload_data_stream = &upload_data; |
| 2283 |
| 2284 scoped_ptr<HttpNetworkTransaction> trans( |
| 2285 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
| 2286 TestCompletionCallback callback; |
| 2287 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
| 2288 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2289 EXPECT_NE(OK, callback.WaitForResult()); |
| 2290 } |
| 2291 |
| 2262 } // namespace test | 2292 } // namespace test |
| 2263 } // namespace net | 2293 } // namespace net |
| OLD | NEW |