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 <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 Loading... | |
| 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 header arrive, but after the connection | |
|
xunjieli
2017/06/21 20:55:28
nit: s/arrive/arrives
Ryan Hamilton
2017/06/21 22:24:51
Done. (Well, s/header/headers/)
| |
| 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 mock_quic_data.AddWrite( | |
| 4313 ConstructInitialSettingsPacket(1, &header_stream_offset)); | |
| 4314 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( | |
| 4315 2, GetNthClientInitiatedStreamId(0), true, true, | |
| 4316 GetRequestHeaders("GET", "https", "/"), &header_stream_offset)); | |
| 4317 QuicStreamOffset server_header_offset = 0; | |
| 4318 mock_quic_data.AddRead(ConstructServerPushPromisePacket( | |
| 4319 1, GetNthClientInitiatedStreamId(0), GetNthServerInitiatedStreamId(0), | |
| 4320 false, GetRequestHeaders("GET", "https", "/pushed.jpg"), | |
| 4321 &server_header_offset, &server_maker_)); | |
| 4322 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | |
| 4323 2, GetNthClientInitiatedStreamId(0), false, false, | |
| 4324 GetResponseHeaders("200 OK"), &server_header_offset)); | |
|
xunjieli
2017/06/21 20:55:28
Sorry I am not familiar with how push promise work
Ryan Hamilton
2017/06/21 22:24:51
It's the response headers for the first request ("
| |
| 4325 mock_quic_data.AddWrite(ConstructClientAckPacket(3, 2, 1, 1)); | |
| 4326 mock_quic_data.AddRead(ConstructServerDataPacket( | |
| 4327 3, GetNthClientInitiatedStreamId(0), false, true, 0, "hello!")); | |
|
xunjieli
2017/06/21 20:55:28
Could you annotate these data packets?
Is this th
Ryan Hamilton
2017/06/21 22:24:51
Done.
| |
| 4328 mock_quic_data.AddWrite(SYNCHRONOUS, ERR_FAILED); | |
| 4329 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | |
| 4330 mock_quic_data.AddRead(ASYNC, 0); // EOF | |
| 4331 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | |
| 4332 | |
| 4333 CreateSession(); | |
| 4334 | |
| 4335 // Send a request which triggers a push promise from the server. | |
| 4336 SendRequestAndExpectQuicResponse("hello!"); | |
| 4337 | |
| 4338 { | |
| 4339 // Start a push transaction that will be cancelled after the conneciton | |
|
xunjieli
2017/06/21 20:55:28
nit: typo in connection.
Ryan Hamilton
2017/06/21 22:24:51
Done.
| |
| 4340 // is closed, but before the callback is executed. | |
| 4341 request_.url = GURL("https://mail.example.org/pushed.jpg"); | |
| 4342 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get()); | |
| 4343 TestCompletionCallback callback; | |
|
xunjieli
2017/06/21 20:55:28
|callback| should still be notified, right?
Can we
Ryan Hamilton
2017/06/21 22:24:51
No, it will not be notified because the transactio
xunjieli
2017/06/22 14:43:30
Acknowledged.
| |
| 4344 int rv = trans.Start(&request_, callback.callback(), net_log_.bound()); | |
| 4345 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | |
| 4346 base::RunLoop().RunUntilIdle(); | |
| 4347 | |
| 4348 // Cause the connection to close on a write error. | |
| 4349 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, session_.get()); | |
| 4350 TestCompletionCallback callback2; | |
| 4351 request_.url = GURL("https://mail.example.org/"); | |
|
xunjieli
2017/06/21 20:55:28
nit: do not reuse |request_| for |trans2|. The Tra
Ryan Hamilton
2017/06/21 22:24:51
Done.
| |
| 4352 EXPECT_THAT(trans2.Start(&request_, callback2.callback(), net_log_.bound()), | |
| 4353 IsError(ERR_IO_PENDING)); | |
| 4354 | |
| 4355 base::RunLoop().RunUntilIdle(); | |
| 4356 | |
| 4357 // When |trans| goes out of scope, the underlying stream will be closed | |
| 4358 } | |
|
xunjieli
2017/06/21 20:55:28
why do we need this extra scope {}?
Ryan Hamilton
2017/06/21 22:24:51
Ah. We need this so that |trans| will be closed. T
xunjieli
2017/06/22 14:43:30
|trans| is going out of scope anyway, right? This
Ryan Hamilton
2017/06/22 20:40:38
Hahahhahahahahaha! Yes, you're obviously right, of
| |
| 4359 } | |
| 4360 | |
| 4303 TEST_P(QuicNetworkTransactionTest, QuicForceHolBlocking) { | 4361 TEST_P(QuicNetworkTransactionTest, QuicForceHolBlocking) { |
| 4304 session_params_.quic_force_hol_blocking = true; | 4362 session_params_.quic_force_hol_blocking = true; |
| 4305 session_params_.origins_to_force_quic_on.insert( | 4363 session_params_.origins_to_force_quic_on.insert( |
| 4306 HostPortPair::FromString("mail.example.org:443")); | 4364 HostPortPair::FromString("mail.example.org:443")); |
| 4307 | 4365 |
| 4308 MockQuicData mock_quic_data; | 4366 MockQuicData mock_quic_data; |
| 4309 | 4367 |
| 4310 QuicStreamOffset offset = 0; | 4368 QuicStreamOffset offset = 0; |
| 4311 mock_quic_data.AddWrite(ConstructInitialSettingsPacket(1, &offset)); | 4369 mock_quic_data.AddWrite(ConstructInitialSettingsPacket(1, &offset)); |
| 4312 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( | 4370 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5027 | 5085 |
| 5028 request_.url = GURL("https://mail.example.org/pushed.jpg"); | 5086 request_.url = GURL("https://mail.example.org/pushed.jpg"); |
| 5029 ChunkedUploadDataStream upload_data(0); | 5087 ChunkedUploadDataStream upload_data(0); |
| 5030 upload_data.AppendData("1", 1, true); | 5088 upload_data.AppendData("1", 1, true); |
| 5031 request_.upload_data_stream = &upload_data; | 5089 request_.upload_data_stream = &upload_data; |
| 5032 SendRequestAndExpectQuicResponse("and hello!"); | 5090 SendRequestAndExpectQuicResponse("and hello!"); |
| 5033 } | 5091 } |
| 5034 | 5092 |
| 5035 } // namespace test | 5093 } // namespace test |
| 5036 } // namespace net | 5094 } // namespace net |
| OLD | NEW |