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

Side by Side Diff: net/quic/chromium/quic_network_transaction_unittest.cc

Issue 2948143002: Add an async method to QuicChromiumClientSession::Handle for (Closed)
Patch Set: Address comments Created 3 years, 6 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
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 <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <ostream> 7 #include <ostream>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 4282 matching lines...) Expand 10 before | Expand all | Expand 10 after
4293 net_log_.GetEntries(&entries); 4293 net_log_.GetEntries(&entries);
4294 EXPECT_LT(0u, entries.size()); 4294 EXPECT_LT(0u, entries.size());
4295 4295
4296 // Check that we logged a QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM 4296 // Check that we logged a QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM
4297 int pos = ExpectLogContainsSomewhere( 4297 int pos = ExpectLogContainsSomewhere(
4298 entries, 0, NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM, 4298 entries, 0, NetLogEventType::QUIC_HTTP_STREAM_ADOPTED_PUSH_STREAM,
4299 NetLogEventPhase::NONE); 4299 NetLogEventPhase::NONE);
4300 EXPECT_LT(0, pos); 4300 EXPECT_LT(0, pos);
4301 } 4301 }
4302 4302
4303 // Regression test for http://crbug.com/719461 in which a promised stream
4304 // is closed before the pushed headers arrive, but after the connection
4305 // is closed and before the callbacks are executed.
4306 TEST_P(QuicNetworkTransactionTest, CancelServerPushAfterConnectionClose) {
4307 session_params_.origins_to_force_quic_on.insert(
4308 HostPortPair::FromString("mail.example.org:443"));
4309
4310 MockQuicData mock_quic_data;
4311 QuicStreamOffset header_stream_offset = 0;
4312 // Initial SETTINGS frame.
4313 mock_quic_data.AddWrite(
4314 ConstructInitialSettingsPacket(1, &header_stream_offset));
4315 // First request: GET https://mail.example.org/
4316 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket(
4317 2, GetNthClientInitiatedStreamId(0), true, true,
4318 GetRequestHeaders("GET", "https", "/"), &header_stream_offset));
4319 QuicStreamOffset server_header_offset = 0;
4320 // Server promise for: https://mail.example.org/pushed.jpg
4321 mock_quic_data.AddRead(ConstructServerPushPromisePacket(
4322 1, GetNthClientInitiatedStreamId(0), GetNthServerInitiatedStreamId(0),
4323 false, GetRequestHeaders("GET", "https", "/pushed.jpg"),
4324 &server_header_offset, &server_maker_));
4325 // Response headers for first request.
4326 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket(
4327 2, GetNthClientInitiatedStreamId(0), false, false,
4328 GetResponseHeaders("200 OK"), &server_header_offset));
4329 // Client ACKs the response headers.
4330 mock_quic_data.AddWrite(ConstructClientAckPacket(3, 2, 1, 1));
4331 // Response body for first request.
4332 mock_quic_data.AddRead(ConstructServerDataPacket(
4333 3, GetNthClientInitiatedStreamId(0), false, true, 0, "hello!"));
4334 // Write error for the third request.
4335 mock_quic_data.AddWrite(SYNCHRONOUS, ERR_FAILED);
4336 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read
4337 mock_quic_data.AddRead(ASYNC, 0); // EOF
4338 mock_quic_data.AddSocketDataToFactory(&socket_factory_);
4339
4340 CreateSession();
4341
4342 // Send a request which triggers a push promise from the server.
4343 SendRequestAndExpectQuicResponse("hello!");
4344
4345 {
4346 // Start a push transaction that will be cancelled after the connection
4347 // is closed, but before the callback is executed.
4348 request_.url = GURL("https://mail.example.org/pushed.jpg");
4349 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get());
xunjieli 2017/06/22 14:43:30 Minor nit: could you name this trans2, callback2?
Ryan Hamilton 2017/06/22 20:40:38 Done.
4350 TestCompletionCallback callback;
4351 int rv = trans.Start(&request_, callback.callback(), net_log_.bound());
4352 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
4353 base::RunLoop().RunUntilIdle();
4354
4355 // Cause the connection to close on a write error.
4356 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session_.get());
xunjieli 2017/06/22 14:43:30 Minor nit: could you name this trans3, callback3 a
Ryan Hamilton 2017/06/22 20:40:38 Done.
4357 TestCompletionCallback callback2;
4358 HttpRequestInfo request2;
4359 request2.method = "GET";
4360 request2.url = GURL("https://mail.example.org/");
4361 request2.load_flags = 0;
4362 EXPECT_THAT(trans2.Start(&request2, callback2.callback(), net_log_.bound()),
4363 IsError(ERR_IO_PENDING));
4364
4365 base::RunLoop().RunUntilIdle();
xunjieli 2017/06/22 14:43:30 |callback2| has completed at this point, right? To
Ryan Hamilton 2017/06/22 20:40:38 Sure. Good point. In the process of doing this, I
4366
4367 // When |trans| goes out of scope, the underlying stream will be closed
4368 }
4369 }
4370
4303 TEST_P(QuicNetworkTransactionTest, QuicForceHolBlocking) { 4371 TEST_P(QuicNetworkTransactionTest, QuicForceHolBlocking) {
4304 session_params_.quic_force_hol_blocking = true; 4372 session_params_.quic_force_hol_blocking = true;
4305 session_params_.origins_to_force_quic_on.insert( 4373 session_params_.origins_to_force_quic_on.insert(
4306 HostPortPair::FromString("mail.example.org:443")); 4374 HostPortPair::FromString("mail.example.org:443"));
4307 4375
4308 MockQuicData mock_quic_data; 4376 MockQuicData mock_quic_data;
4309 4377
4310 QuicStreamOffset offset = 0; 4378 QuicStreamOffset offset = 0;
4311 mock_quic_data.AddWrite(ConstructInitialSettingsPacket(1, &offset)); 4379 mock_quic_data.AddWrite(ConstructInitialSettingsPacket(1, &offset));
4312 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( 4380 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket(
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
5027 5095
5028 request_.url = GURL("https://mail.example.org/pushed.jpg"); 5096 request_.url = GURL("https://mail.example.org/pushed.jpg");
5029 ChunkedUploadDataStream upload_data(0); 5097 ChunkedUploadDataStream upload_data(0);
5030 upload_data.AppendData("1", 1, true); 5098 upload_data.AppendData("1", 1, true);
5031 request_.upload_data_stream = &upload_data; 5099 request_.upload_data_stream = &upload_data;
5032 SendRequestAndExpectQuicResponse("and hello!"); 5100 SendRequestAndExpectQuicResponse("and hello!");
5033 } 5101 }
5034 5102
5035 } // namespace test 5103 } // namespace test
5036 } // namespace net 5104 } // namespace net
OLDNEW
« net/quic/chromium/quic_chromium_client_session.cc ('K') | « net/quic/chromium/quic_http_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698