| 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 <cmath> | 5 #include <cmath> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 507 } |
| 508 | 508 |
| 509 static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper, | 509 static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper, |
| 510 int result) { | 510 int result) { |
| 511 helper->ResetTrans(); | 511 helper->ResetTrans(); |
| 512 } | 512 } |
| 513 | 513 |
| 514 static void StartTransactionCallback(HttpNetworkSession* session, | 514 static void StartTransactionCallback(HttpNetworkSession* session, |
| 515 GURL url, | 515 GURL url, |
| 516 int result) { | 516 int result) { |
| 517 HttpRequestInfo request; |
| 517 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session); | 518 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session); |
| 518 TestCompletionCallback callback; | 519 TestCompletionCallback callback; |
| 519 HttpRequestInfo request; | |
| 520 request.method = "GET"; | 520 request.method = "GET"; |
| 521 request.url = url; | 521 request.url = url; |
| 522 request.load_flags = 0; | 522 request.load_flags = 0; |
| 523 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 523 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
| 524 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 524 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 525 callback.WaitForResult(); | 525 callback.WaitForResult(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 ChunkedUploadDataStream* upload_chunked_data_stream() const { | 528 ChunkedUploadDataStream* upload_chunked_data_stream() const { |
| 529 return upload_chunked_data_stream_.get(); | 529 return upload_chunked_data_stream_.get(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 TransactionHelperResult out; | 693 TransactionHelperResult out; |
| 694 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 694 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 695 NetLogWithSource(), nullptr); | 695 NetLogWithSource(), nullptr); |
| 696 helper.RunPreTestSetup(); | 696 helper.RunPreTestSetup(); |
| 697 helper.AddData(&data); | 697 helper.AddData(&data); |
| 698 // We require placeholder data because three get requests are sent out at | 698 // We require placeholder data because three get requests are sent out at |
| 699 // the same time which results in three sockets being connected. The first | 699 // the same time which results in three sockets being connected. The first |
| 700 // on will negotiate SPDY and will be used for all requests. | 700 // on will negotiate SPDY and will be used for all requests. |
| 701 helper.AddData(&data_placeholder1); | 701 helper.AddData(&data_placeholder1); |
| 702 helper.AddData(&data_placeholder2); | 702 helper.AddData(&data_placeholder2); |
| 703 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); | |
| 704 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); | |
| 705 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); | |
| 706 | |
| 707 TestCompletionCallback callback1; | 703 TestCompletionCallback callback1; |
| 708 TestCompletionCallback callback2; | 704 TestCompletionCallback callback2; |
| 709 TestCompletionCallback callback3; | 705 TestCompletionCallback callback3; |
| 710 | 706 |
| 711 HttpRequestInfo httpreq1 = CreateGetRequest(); | 707 HttpRequestInfo httpreq1 = CreateGetRequest(); |
| 712 HttpRequestInfo httpreq2 = CreateGetRequest(); | 708 HttpRequestInfo httpreq2 = CreateGetRequest(); |
| 713 HttpRequestInfo httpreq3 = CreateGetRequest(); | 709 HttpRequestInfo httpreq3 = CreateGetRequest(); |
| 714 | 710 |
| 711 HttpNetworkTransaction trans1(DEFAULT_PRIORITY, helper.session()); |
| 712 HttpNetworkTransaction trans2(DEFAULT_PRIORITY, helper.session()); |
| 713 HttpNetworkTransaction trans3(DEFAULT_PRIORITY, helper.session()); |
| 714 |
| 715 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); | 715 out.rv = trans1.Start(&httpreq1, callback1.callback(), log); |
| 716 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); | 716 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
| 717 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); | 717 out.rv = trans2.Start(&httpreq2, callback2.callback(), log); |
| 718 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); | 718 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
| 719 out.rv = trans3.Start(&httpreq3, callback3.callback(), log); | 719 out.rv = trans3.Start(&httpreq3, callback3.callback(), log); |
| 720 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); | 720 ASSERT_THAT(out.rv, IsError(ERR_IO_PENDING)); |
| 721 | 721 |
| 722 out.rv = callback1.WaitForResult(); | 722 out.rv = callback1.WaitForResult(); |
| 723 ASSERT_THAT(out.rv, IsOk()); | 723 ASSERT_THAT(out.rv, IsOk()); |
| 724 out.rv = callback3.WaitForResult(); | 724 out.rv = callback3.WaitForResult(); |
| (...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2623 // Start the ordinary requests. | 2623 // Start the ordinary requests. |
| 2624 NetLogWithSource log; | 2624 NetLogWithSource log; |
| 2625 ASSERT_THAT(trans1.Start(&CreateGetRequest(), callback1.callback(), log), | 2625 ASSERT_THAT(trans1.Start(&CreateGetRequest(), callback1.callback(), log), |
| 2626 IsError(ERR_IO_PENDING)); | 2626 IsError(ERR_IO_PENDING)); |
| 2627 ASSERT_THAT(trans3.Start(&CreateGetRequest(), callback3.callback(), log), | 2627 ASSERT_THAT(trans3.Start(&CreateGetRequest(), callback3.callback(), log), |
| 2628 IsError(ERR_IO_PENDING)); | 2628 IsError(ERR_IO_PENDING)); |
| 2629 ASSERT_THAT(trans5.Start(&CreateGetRequest(), callback5.callback(), log), | 2629 ASSERT_THAT(trans5.Start(&CreateGetRequest(), callback5.callback(), log), |
| 2630 IsError(ERR_IO_PENDING)); | 2630 IsError(ERR_IO_PENDING)); |
| 2631 data.RunUntilPaused(); | 2631 data.RunUntilPaused(); |
| 2632 | 2632 |
| 2633 HttpNetworkTransaction trans2(HIGHEST, helper.session()); | |
| 2634 TestCompletionCallback callback2; | |
| 2635 | |
| 2636 // Start a request that matches the push. | 2633 // Start a request that matches the push. |
| 2637 HttpRequestInfo push_req = CreateGetRequest(); | 2634 HttpRequestInfo push_req = CreateGetRequest(); |
| 2638 push_req.url = GURL(GetDefaultUrlWithPath("/foo.dat")); | 2635 push_req.url = GURL(GetDefaultUrlWithPath("/foo.dat")); |
| 2636 |
| 2637 HttpNetworkTransaction trans2(HIGHEST, helper.session()); |
| 2638 TestCompletionCallback callback2; |
| 2639 ASSERT_THAT(trans2.Start(&push_req, callback2.callback(), log), | 2639 ASSERT_THAT(trans2.Start(&push_req, callback2.callback(), log), |
| 2640 IsError(ERR_IO_PENDING)); | 2640 IsError(ERR_IO_PENDING)); |
| 2641 data.Resume(); | 2641 data.Resume(); |
| 2642 | 2642 |
| 2643 base::RunLoop().RunUntilIdle(); | 2643 base::RunLoop().RunUntilIdle(); |
| 2644 ASSERT_THAT(callback1.WaitForResult(), IsOk()); | 2644 ASSERT_THAT(callback1.WaitForResult(), IsOk()); |
| 2645 ASSERT_THAT(callback2.WaitForResult(), IsOk()); | 2645 ASSERT_THAT(callback2.WaitForResult(), IsOk()); |
| 2646 ASSERT_THAT(callback3.WaitForResult(), IsOk()); | 2646 ASSERT_THAT(callback3.WaitForResult(), IsOk()); |
| 2647 ASSERT_THAT(callback5.WaitForResult(), IsOk()); | 2647 ASSERT_THAT(callback5.WaitForResult(), IsOk()); |
| 2648 helper.VerifyDataConsumed(); | 2648 helper.VerifyDataConsumed(); |
| (...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5433 data.Resume(); | 5433 data.Resume(); |
| 5434 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 5434 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 5435 | 5435 |
| 5436 // And now we can allow everything else to run to completion. | 5436 // And now we can allow everything else to run to completion. |
| 5437 data.Resume(); | 5437 data.Resume(); |
| 5438 base::RunLoop().RunUntilIdle(); | 5438 base::RunLoop().RunUntilIdle(); |
| 5439 EXPECT_THAT(callback2.WaitForResult(), IsOk()); | 5439 EXPECT_THAT(callback2.WaitForResult(), IsOk()); |
| 5440 EXPECT_THAT(callback3.WaitForResult(), IsOk()); | 5440 EXPECT_THAT(callback3.WaitForResult(), IsOk()); |
| 5441 | 5441 |
| 5442 helper.VerifyDataConsumed(); | 5442 helper.VerifyDataConsumed(); |
| 5443 |
| 5444 // At this point the test is completed and we need to safely destroy |
| 5445 // all allocated structures. Helper stores a transaction that has a |
| 5446 // reference to a stack allocated request, which has a short lifetime, |
| 5447 // and is accessed during the transaction destruction. We need to delete |
| 5448 // the transaction while the request is still a valid object. |
| 5449 helper.ResetTrans(); |
| 5443 } | 5450 } |
| 5444 | 5451 |
| 5445 // Test that sent data frames and received WINDOW_UPDATE frames change | 5452 // Test that sent data frames and received WINDOW_UPDATE frames change |
| 5446 // the send_window_size_ correctly. | 5453 // the send_window_size_ correctly. |
| 5447 | 5454 |
| 5448 // WINDOW_UPDATE is different than most other frames in that it can arrive | 5455 // WINDOW_UPDATE is different than most other frames in that it can arrive |
| 5449 // while the client is still sending the request body. In order to enforce | 5456 // while the client is still sending the request body. In order to enforce |
| 5450 // this scenario, we feed a couple of dummy frames and give a delay of 0 to | 5457 // this scenario, we feed a couple of dummy frames and give a delay of 0 to |
| 5451 // socket data provider, so that initial read that is done as soon as the | 5458 // socket data provider, so that initial read that is done as soon as the |
| 5452 // stream is created, succeeds and schedules another read. This way reads | 5459 // stream is created, succeeds and schedules another read. This way reads |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6544 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6551 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 6545 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 6552 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
| 6546 new SSLSocketDataProvider(ASYNC, OK)); | 6553 new SSLSocketDataProvider(ASYNC, OK)); |
| 6547 // Set to TLS_RSA_WITH_NULL_MD5 | 6554 // Set to TLS_RSA_WITH_NULL_MD5 |
| 6548 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6555 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 6549 | 6556 |
| 6550 RunTLSUsageCheckTest(std::move(ssl_provider)); | 6557 RunTLSUsageCheckTest(std::move(ssl_provider)); |
| 6551 } | 6558 } |
| 6552 | 6559 |
| 6553 } // namespace net | 6560 } // namespace net |
| OLD | NEW |