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

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 8990001: base::Bind: Convert most of net/http. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang. Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
10 #include "net/base/auth.h" 12 #include "net/base/auth.h"
11 #include "net/base/net_log_unittest.h" 13 #include "net/base/net_log_unittest.h"
12 #include "net/http/http_network_session_peer.h" 14 #include "net/http/http_network_session_peer.h"
13 #include "net/http/http_transaction_unittest.h" 15 #include "net/http/http_transaction_unittest.h"
14 #include "net/socket/client_socket_pool_base.h" 16 #include "net/socket/client_socket_pool_base.h"
15 #include "net/spdy/spdy_http_stream.h" 17 #include "net/spdy/spdy_http_stream.h"
16 #include "net/spdy/spdy_http_utils.h" 18 #include "net/spdy/spdy_http_utils.h"
17 #include "net/spdy/spdy_session.h" 19 #include "net/spdy/spdy_session.h"
18 #include "net/spdy/spdy_session_pool.h" 20 #include "net/spdy/spdy_session_pool.h"
19 #include "net/spdy/spdy_test_util.h" 21 #include "net/spdy/spdy_test_util.h"
(...skipping 30 matching lines...) Expand all
50 int rv; 52 int rv;
51 std::string status_line; 53 std::string status_line;
52 std::string response_data; 54 std::string response_data;
53 HttpResponseInfo response_info; 55 HttpResponseInfo response_info;
54 }; 56 };
55 57
56 void EnableCompression(bool enabled) { 58 void EnableCompression(bool enabled) {
57 spdy::SpdyFramer::set_enable_compression_default(enabled); 59 spdy::SpdyFramer::set_enable_compression_default(enabled);
58 } 60 }
59 61
60 class StartTransactionCallback;
61 class DeleteSessionCallback;
62
63 // A helper class that handles all the initial npn/ssl setup. 62 // A helper class that handles all the initial npn/ssl setup.
64 class NormalSpdyTransactionHelper { 63 class NormalSpdyTransactionHelper {
65 public: 64 public:
66 NormalSpdyTransactionHelper(const HttpRequestInfo& request, 65 NormalSpdyTransactionHelper(const HttpRequestInfo& request,
67 const BoundNetLog& log, 66 const BoundNetLog& log,
68 SpdyNetworkTransactionTestTypes test_type) 67 SpdyNetworkTransactionTestTypes test_type)
69 : request_(request), 68 : request_(request),
70 session_deps_(new SpdySessionDependencies()), 69 session_deps_(new SpdySessionDependencies()),
71 session_(SpdySessionDependencies::SpdyCreateSession( 70 session_(SpdySessionDependencies::SpdyCreateSession(
72 session_deps_.get())), 71 session_deps_.get())),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 default: 142 default:
144 NOTREACHED(); 143 NOTREACHED();
145 } 144 }
146 145
147 // We're now ready to use SSL-npn SPDY. 146 // We're now ready to use SSL-npn SPDY.
148 trans_.reset(new HttpNetworkTransaction(session_)); 147 trans_.reset(new HttpNetworkTransaction(session_));
149 } 148 }
150 149
151 // Start the transaction, read some data, finish. 150 // Start the transaction, read some data, finish.
152 void RunDefaultTest() { 151 void RunDefaultTest() {
153 output_.rv = trans_->Start(&request_, &callback, log_); 152 output_.rv = trans_->Start(&request_, callback.callback(), log_);
154 153
155 // We expect an IO Pending or some sort of error. 154 // We expect an IO Pending or some sort of error.
156 EXPECT_LT(output_.rv, 0); 155 EXPECT_LT(output_.rv, 0);
157 if (output_.rv != ERR_IO_PENDING) 156 if (output_.rv != ERR_IO_PENDING)
158 return; 157 return;
159 158
160 output_.rv = callback.WaitForResult(); 159 output_.rv = callback.WaitForResult();
161 if (output_.rv != OK) { 160 if (output_.rv != OK) {
162 session_->spdy_session_pool()->CloseCurrentSessions(); 161 session_->spdy_session_pool()->CloseCurrentSessions();
163 return; 162 return;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector; 316 typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector;
318 typedef std::vector<linked_ptr<StaticSocketDataProvider> > AlternateVector; 317 typedef std::vector<linked_ptr<StaticSocketDataProvider> > AlternateVector;
319 typedef std::vector<scoped_refptr<DeterministicSocketData> > 318 typedef std::vector<scoped_refptr<DeterministicSocketData> >
320 AlternateDeterministicVector; 319 AlternateDeterministicVector;
321 HttpRequestInfo request_; 320 HttpRequestInfo request_;
322 scoped_ptr<SpdySessionDependencies> session_deps_; 321 scoped_ptr<SpdySessionDependencies> session_deps_;
323 scoped_refptr<HttpNetworkSession> session_; 322 scoped_refptr<HttpNetworkSession> session_;
324 TransactionHelperResult output_; 323 TransactionHelperResult output_;
325 scoped_ptr<StaticSocketDataProvider> first_transaction_; 324 scoped_ptr<StaticSocketDataProvider> first_transaction_;
326 SSLVector ssl_vector_; 325 SSLVector ssl_vector_;
327 TestOldCompletionCallback callback; 326 TestCompletionCallback callback;
328 scoped_ptr<HttpNetworkTransaction> trans_; 327 scoped_ptr<HttpNetworkTransaction> trans_;
329 scoped_ptr<HttpNetworkTransaction> trans_http_; 328 scoped_ptr<HttpNetworkTransaction> trans_http_;
330 DataVector data_vector_; 329 DataVector data_vector_;
331 AlternateVector alternate_vector_; 330 AlternateVector alternate_vector_;
332 AlternateDeterministicVector alternate_deterministic_vector_; 331 AlternateDeterministicVector alternate_deterministic_vector_;
333 const BoundNetLog& log_; 332 const BoundNetLog& log_;
334 SpdyNetworkTransactionTestTypes test_type_; 333 SpdyNetworkTransactionTestTypes test_type_;
335 int port_; 334 int port_;
336 bool deterministic_; 335 bool deterministic_;
337 bool spdy_enabled_; 336 bool spdy_enabled_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // multiple transactions in the read pipeline; so as we read, we may have 400 // multiple transactions in the read pipeline; so as we read, we may have
402 // to skip over data destined for other transactions while we consume 401 // to skip over data destined for other transactions while we consume
403 // the data for |trans|. 402 // the data for |trans|.
404 int ReadResult(HttpNetworkTransaction* trans, 403 int ReadResult(HttpNetworkTransaction* trans,
405 StaticSocketDataProvider* data, 404 StaticSocketDataProvider* data,
406 std::string* result) { 405 std::string* result) {
407 const int kSize = 3000; 406 const int kSize = 3000;
408 407
409 int bytes_read = 0; 408 int bytes_read = 0;
410 scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(kSize)); 409 scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(kSize));
411 TestOldCompletionCallback callback; 410 TestCompletionCallback callback;
412 while (true) { 411 while (true) {
413 int rv = trans->Read(buf, kSize, &callback); 412 int rv = trans->Read(buf, kSize, callback.callback());
414 if (rv == ERR_IO_PENDING) { 413 if (rv == ERR_IO_PENDING) {
415 // Multiple transactions may be in the data set. Keep pulling off 414 // Multiple transactions may be in the data set. Keep pulling off
416 // reads until we complete our callback. 415 // reads until we complete our callback.
417 while (!callback.have_result()) { 416 while (!callback.have_result()) {
418 data->CompleteRead(); 417 data->CompleteRead();
419 MessageLoop::current()->RunAllPending(); 418 MessageLoop::current()->RunAllPending();
420 } 419 }
421 rv = callback.WaitForResult(); 420 rv = callback.WaitForResult();
422 } else if (rv <= 0) { 421 } else if (rv <= 0) {
423 break; 422 break;
(...skipping 27 matching lines...) Expand all
451 HttpResponseInfo* push_response, 450 HttpResponseInfo* push_response,
452 std::string& expected) { 451 std::string& expected) {
453 NormalSpdyTransactionHelper helper(CreateGetRequest(), 452 NormalSpdyTransactionHelper helper(CreateGetRequest(),
454 BoundNetLog(), GetParam()); 453 BoundNetLog(), GetParam());
455 helper.RunPreTestSetup(); 454 helper.RunPreTestSetup();
456 helper.AddData(data); 455 helper.AddData(data);
457 456
458 HttpNetworkTransaction* trans = helper.trans(); 457 HttpNetworkTransaction* trans = helper.trans();
459 458
460 // Start the transaction with basic parameters. 459 // Start the transaction with basic parameters.
461 TestOldCompletionCallback callback; 460 TestCompletionCallback callback;
462 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 461 int rv = trans->Start(
462 &CreateGetRequest(), callback.callback(), BoundNetLog());
463 EXPECT_EQ(ERR_IO_PENDING, rv); 463 EXPECT_EQ(ERR_IO_PENDING, rv);
464 rv = callback.WaitForResult(); 464 rv = callback.WaitForResult();
465 465
466 // Request the pushed path. 466 // Request the pushed path.
467 scoped_ptr<HttpNetworkTransaction> trans2( 467 scoped_ptr<HttpNetworkTransaction> trans2(
468 new HttpNetworkTransaction(helper.session())); 468 new HttpNetworkTransaction(helper.session()));
469 rv = trans2->Start(&CreateGetPushRequest(), &callback, BoundNetLog()); 469 rv = trans2->Start(
470 &CreateGetPushRequest(), callback.callback(), BoundNetLog());
470 EXPECT_EQ(ERR_IO_PENDING, rv); 471 EXPECT_EQ(ERR_IO_PENDING, rv);
471 MessageLoop::current()->RunAllPending(); 472 MessageLoop::current()->RunAllPending();
472 473
473 // The data for the pushed path may be coming in more than 1 packet. Compile 474 // The data for the pushed path may be coming in more than 1 packet. Compile
474 // the results into a single string. 475 // the results into a single string.
475 476
476 // Read the server push body. 477 // Read the server push body.
477 std::string result2; 478 std::string result2;
478 ReadResult(trans2.get(), data, &result2); 479 ReadResult(trans2.get(), data, &result2);
479 // Read the response body. 480 // Read the response body.
(...skipping 11 matching lines...) Expand all
491 << expected; 492 << expected;
492 493
493 // Verify the SYN_REPLY. 494 // Verify the SYN_REPLY.
494 // Copy the response info, because trans goes away. 495 // Copy the response info, because trans goes away.
495 *response = *trans->GetResponseInfo(); 496 *response = *trans->GetResponseInfo();
496 *push_response = *trans2->GetResponseInfo(); 497 *push_response = *trans2->GetResponseInfo();
497 498
498 VerifyStreamsClosed(helper); 499 VerifyStreamsClosed(helper);
499 } 500 }
500 501
502 static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper,
503 int result) {
504 helper->ResetTrans();
505 }
506
507 static void StartTransactionCallback(
508 const scoped_refptr<HttpNetworkSession>& session,
509 int result) {
510 scoped_ptr<HttpNetworkTransaction> trans(
511 new HttpNetworkTransaction(session));
512 TestCompletionCallback callback;
513 HttpRequestInfo request;
514 request.method = "GET";
515 request.url = GURL("http://www.google.com/");
516 request.load_flags = 0;
517 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
518 EXPECT_EQ(ERR_IO_PENDING, rv);
519 callback.WaitForResult();
520 }
521
501 private: 522 private:
502 bool google_get_request_initialized_; 523 bool google_get_request_initialized_;
503 bool google_post_request_initialized_; 524 bool google_post_request_initialized_;
504 bool google_chunked_post_request_initialized_; 525 bool google_chunked_post_request_initialized_;
505 HttpRequestInfo google_get_request_; 526 HttpRequestInfo google_get_request_;
506 HttpRequestInfo google_post_request_; 527 HttpRequestInfo google_post_request_;
507 HttpRequestInfo google_chunked_post_request_; 528 HttpRequestInfo google_chunked_post_request_;
508 HttpRequestInfo google_get_push_request_; 529 HttpRequestInfo google_get_push_request_;
509 }; 530 };
510 531
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // there needs to be three sets of SSL connection data. 684 // there needs to be three sets of SSL connection data.
664 helper.AddData(data_placeholder.get()); 685 helper.AddData(data_placeholder.get());
665 helper.AddData(data_placeholder.get()); 686 helper.AddData(data_placeholder.get());
666 scoped_ptr<HttpNetworkTransaction> trans1( 687 scoped_ptr<HttpNetworkTransaction> trans1(
667 new HttpNetworkTransaction(helper.session())); 688 new HttpNetworkTransaction(helper.session()));
668 scoped_ptr<HttpNetworkTransaction> trans2( 689 scoped_ptr<HttpNetworkTransaction> trans2(
669 new HttpNetworkTransaction(helper.session())); 690 new HttpNetworkTransaction(helper.session()));
670 scoped_ptr<HttpNetworkTransaction> trans3( 691 scoped_ptr<HttpNetworkTransaction> trans3(
671 new HttpNetworkTransaction(helper.session())); 692 new HttpNetworkTransaction(helper.session()));
672 693
673 TestOldCompletionCallback callback1; 694 TestCompletionCallback callback1;
674 TestOldCompletionCallback callback2; 695 TestCompletionCallback callback2;
675 TestOldCompletionCallback callback3; 696 TestCompletionCallback callback3;
676 697
677 HttpRequestInfo httpreq1 = CreateGetRequest(); 698 HttpRequestInfo httpreq1 = CreateGetRequest();
678 HttpRequestInfo httpreq2 = CreateGetRequest(); 699 HttpRequestInfo httpreq2 = CreateGetRequest();
679 HttpRequestInfo httpreq3 = CreateGetRequest(); 700 HttpRequestInfo httpreq3 = CreateGetRequest();
680 701
681 out.rv = trans1->Start(&httpreq1, &callback1, log); 702 out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
682 ASSERT_EQ(ERR_IO_PENDING, out.rv); 703 ASSERT_EQ(ERR_IO_PENDING, out.rv);
683 out.rv = trans2->Start(&httpreq2, &callback2, log); 704 out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
684 ASSERT_EQ(ERR_IO_PENDING, out.rv); 705 ASSERT_EQ(ERR_IO_PENDING, out.rv);
685 out.rv = trans3->Start(&httpreq3, &callback3, log); 706 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
686 ASSERT_EQ(ERR_IO_PENDING, out.rv); 707 ASSERT_EQ(ERR_IO_PENDING, out.rv);
687 708
688 out.rv = callback1.WaitForResult(); 709 out.rv = callback1.WaitForResult();
689 ASSERT_EQ(OK, out.rv); 710 ASSERT_EQ(OK, out.rv);
690 out.rv = callback3.WaitForResult(); 711 out.rv = callback3.WaitForResult();
691 ASSERT_EQ(OK, out.rv); 712 ASSERT_EQ(OK, out.rv);
692 713
693 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); 714 const HttpResponseInfo* response1 = trans1->GetResponseInfo();
694 EXPECT_TRUE(response1->headers != NULL); 715 EXPECT_TRUE(response1->headers != NULL);
695 EXPECT_TRUE(response1->was_fetched_via_spdy); 716 EXPECT_TRUE(response1->was_fetched_via_spdy);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 helper.RunPreTestSetup(); 769 helper.RunPreTestSetup();
749 helper.AddData(data.get()); 770 helper.AddData(data.get());
750 // We require placeholder data because two get requests are sent out, so 771 // We require placeholder data because two get requests are sent out, so
751 // there needs to be two sets of SSL connection data. 772 // there needs to be two sets of SSL connection data.
752 helper.AddData(data_placeholder.get()); 773 helper.AddData(data_placeholder.get());
753 scoped_ptr<HttpNetworkTransaction> trans1( 774 scoped_ptr<HttpNetworkTransaction> trans1(
754 new HttpNetworkTransaction(helper.session())); 775 new HttpNetworkTransaction(helper.session()));
755 scoped_ptr<HttpNetworkTransaction> trans2( 776 scoped_ptr<HttpNetworkTransaction> trans2(
756 new HttpNetworkTransaction(helper.session())); 777 new HttpNetworkTransaction(helper.session()));
757 778
758 TestOldCompletionCallback callback1; 779 TestCompletionCallback callback1;
759 TestOldCompletionCallback callback2; 780 TestCompletionCallback callback2;
760 781
761 HttpRequestInfo httpreq1 = CreateGetRequest(); 782 HttpRequestInfo httpreq1 = CreateGetRequest();
762 HttpRequestInfo httpreq2 = CreateGetRequest(); 783 HttpRequestInfo httpreq2 = CreateGetRequest();
763 784
764 out.rv = trans1->Start(&httpreq1, &callback1, log); 785 out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
765 ASSERT_EQ(ERR_IO_PENDING, out.rv); 786 ASSERT_EQ(ERR_IO_PENDING, out.rv);
766 out.rv = trans2->Start(&httpreq2, &callback2, log); 787 out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
767 ASSERT_EQ(ERR_IO_PENDING, out.rv); 788 ASSERT_EQ(ERR_IO_PENDING, out.rv);
768 789
769 out.rv = callback1.WaitForResult(); 790 out.rv = callback1.WaitForResult();
770 ASSERT_EQ(OK, out.rv); 791 ASSERT_EQ(OK, out.rv);
771 out.rv = callback2.WaitForResult(); 792 out.rv = callback2.WaitForResult();
772 ASSERT_EQ(OK, out.rv); 793 ASSERT_EQ(OK, out.rv);
773 794
774 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); 795 const HttpResponseInfo* response1 = trans1->GetResponseInfo();
775 EXPECT_TRUE(response1->headers != NULL); 796 EXPECT_TRUE(response1->headers != NULL);
776 EXPECT_TRUE(response1->was_fetched_via_spdy); 797 EXPECT_TRUE(response1->was_fetched_via_spdy);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 // We require placeholder data because 3 connections are attempted (first is 858 // We require placeholder data because 3 connections are attempted (first is
838 // the preconnect, 2nd and 3rd are the never finished connections. 859 // the preconnect, 2nd and 3rd are the never finished connections.
839 helper.AddData(data_placeholder.get()); 860 helper.AddData(data_placeholder.get());
840 helper.AddData(data_placeholder.get()); 861 helper.AddData(data_placeholder.get());
841 862
842 scoped_ptr<HttpNetworkTransaction> trans1( 863 scoped_ptr<HttpNetworkTransaction> trans1(
843 new HttpNetworkTransaction(helper.session())); 864 new HttpNetworkTransaction(helper.session()));
844 scoped_ptr<HttpNetworkTransaction> trans2( 865 scoped_ptr<HttpNetworkTransaction> trans2(
845 new HttpNetworkTransaction(helper.session())); 866 new HttpNetworkTransaction(helper.session()));
846 867
847 TestOldCompletionCallback callback1; 868 TestCompletionCallback callback1;
848 TestOldCompletionCallback callback2; 869 TestCompletionCallback callback2;
849 870
850 HttpRequestInfo httpreq = CreateGetRequest(); 871 HttpRequestInfo httpreq = CreateGetRequest();
851 872
852 // Preconnect the first. 873 // Preconnect the first.
853 SSLConfig preconnect_ssl_config; 874 SSLConfig preconnect_ssl_config;
854 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config); 875 helper.session()->ssl_config_service()->GetSSLConfig(&preconnect_ssl_config);
855 HttpStreamFactory* http_stream_factory = 876 HttpStreamFactory* http_stream_factory =
856 helper.session()->http_stream_factory(); 877 helper.session()->http_stream_factory();
857 if (http_stream_factory->has_next_protos()) { 878 if (http_stream_factory->has_next_protos()) {
858 preconnect_ssl_config.next_protos = http_stream_factory->next_protos(); 879 preconnect_ssl_config.next_protos = http_stream_factory->next_protos();
859 } 880 }
860 881
861 http_stream_factory->PreconnectStreams( 882 http_stream_factory->PreconnectStreams(
862 1, httpreq, preconnect_ssl_config, preconnect_ssl_config, log); 883 1, httpreq, preconnect_ssl_config, preconnect_ssl_config, log);
863 884
864 out.rv = trans1->Start(&httpreq, &callback1, log); 885 out.rv = trans1->Start(&httpreq, callback1.callback(), log);
865 ASSERT_EQ(ERR_IO_PENDING, out.rv); 886 ASSERT_EQ(ERR_IO_PENDING, out.rv);
866 out.rv = trans2->Start(&httpreq, &callback2, log); 887 out.rv = trans2->Start(&httpreq, callback2.callback(), log);
867 ASSERT_EQ(ERR_IO_PENDING, out.rv); 888 ASSERT_EQ(ERR_IO_PENDING, out.rv);
868 889
869 out.rv = callback1.WaitForResult(); 890 out.rv = callback1.WaitForResult();
870 ASSERT_EQ(OK, out.rv); 891 ASSERT_EQ(OK, out.rv);
871 out.rv = callback2.WaitForResult(); 892 out.rv = callback2.WaitForResult();
872 ASSERT_EQ(OK, out.rv); 893 ASSERT_EQ(OK, out.rv);
873 894
874 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); 895 const HttpResponseInfo* response1 = trans1->GetResponseInfo();
875 EXPECT_TRUE(response1->headers != NULL); 896 EXPECT_TRUE(response1->headers != NULL);
876 EXPECT_TRUE(response1->was_fetched_via_spdy); 897 EXPECT_TRUE(response1->was_fetched_via_spdy);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 // there needs to be three sets of SSL connection data. 983 // there needs to be three sets of SSL connection data.
963 helper.AddData(data_placeholder.get()); 984 helper.AddData(data_placeholder.get());
964 helper.AddData(data_placeholder.get()); 985 helper.AddData(data_placeholder.get());
965 scoped_ptr<HttpNetworkTransaction> trans1( 986 scoped_ptr<HttpNetworkTransaction> trans1(
966 new HttpNetworkTransaction(helper.session())); 987 new HttpNetworkTransaction(helper.session()));
967 scoped_ptr<HttpNetworkTransaction> trans2( 988 scoped_ptr<HttpNetworkTransaction> trans2(
968 new HttpNetworkTransaction(helper.session())); 989 new HttpNetworkTransaction(helper.session()));
969 scoped_ptr<HttpNetworkTransaction> trans3( 990 scoped_ptr<HttpNetworkTransaction> trans3(
970 new HttpNetworkTransaction(helper.session())); 991 new HttpNetworkTransaction(helper.session()));
971 992
972 TestOldCompletionCallback callback1; 993 TestCompletionCallback callback1;
973 TestOldCompletionCallback callback2; 994 TestCompletionCallback callback2;
974 TestOldCompletionCallback callback3; 995 TestCompletionCallback callback3;
975 996
976 HttpRequestInfo httpreq1 = CreateGetRequest(); 997 HttpRequestInfo httpreq1 = CreateGetRequest();
977 HttpRequestInfo httpreq2 = CreateGetRequest(); 998 HttpRequestInfo httpreq2 = CreateGetRequest();
978 HttpRequestInfo httpreq3 = CreateGetRequest(); 999 HttpRequestInfo httpreq3 = CreateGetRequest();
979 1000
980 out.rv = trans1->Start(&httpreq1, &callback1, log); 1001 out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
981 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1002 ASSERT_EQ(out.rv, ERR_IO_PENDING);
982 // run transaction 1 through quickly to force a read of our SETTINGS 1003 // run transaction 1 through quickly to force a read of our SETTINGS
983 // frame 1004 // frame
984 out.rv = callback1.WaitForResult(); 1005 out.rv = callback1.WaitForResult();
985 ASSERT_EQ(OK, out.rv); 1006 ASSERT_EQ(OK, out.rv);
986 1007
987 out.rv = trans2->Start(&httpreq2, &callback2, log); 1008 out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
988 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1009 ASSERT_EQ(out.rv, ERR_IO_PENDING);
989 out.rv = trans3->Start(&httpreq3, &callback3, log); 1010 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
990 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1011 ASSERT_EQ(out.rv, ERR_IO_PENDING);
991 out.rv = callback2.WaitForResult(); 1012 out.rv = callback2.WaitForResult();
992 ASSERT_EQ(OK, out.rv); 1013 ASSERT_EQ(OK, out.rv);
993 EXPECT_EQ(7U, data->read_index()); // i.e. the third trans was queued 1014 EXPECT_EQ(7U, data->read_index()); // i.e. the third trans was queued
994 1015
995 out.rv = callback3.WaitForResult(); 1016 out.rv = callback3.WaitForResult();
996 ASSERT_EQ(OK, out.rv); 1017 ASSERT_EQ(OK, out.rv);
997 1018
998 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); 1019 const HttpResponseInfo* response1 = trans1->GetResponseInfo();
999 ASSERT_TRUE(response1 != NULL); 1020 ASSERT_TRUE(response1 != NULL);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 helper.AddData(data_placeholder.get()); 1125 helper.AddData(data_placeholder.get());
1105 scoped_ptr<HttpNetworkTransaction> trans1( 1126 scoped_ptr<HttpNetworkTransaction> trans1(
1106 new HttpNetworkTransaction(helper.session())); 1127 new HttpNetworkTransaction(helper.session()));
1107 scoped_ptr<HttpNetworkTransaction> trans2( 1128 scoped_ptr<HttpNetworkTransaction> trans2(
1108 new HttpNetworkTransaction(helper.session())); 1129 new HttpNetworkTransaction(helper.session()));
1109 scoped_ptr<HttpNetworkTransaction> trans3( 1130 scoped_ptr<HttpNetworkTransaction> trans3(
1110 new HttpNetworkTransaction(helper.session())); 1131 new HttpNetworkTransaction(helper.session()));
1111 scoped_ptr<HttpNetworkTransaction> trans4( 1132 scoped_ptr<HttpNetworkTransaction> trans4(
1112 new HttpNetworkTransaction(helper.session())); 1133 new HttpNetworkTransaction(helper.session()));
1113 1134
1114 TestOldCompletionCallback callback1; 1135 TestCompletionCallback callback1;
1115 TestOldCompletionCallback callback2; 1136 TestCompletionCallback callback2;
1116 TestOldCompletionCallback callback3; 1137 TestCompletionCallback callback3;
1117 TestOldCompletionCallback callback4; 1138 TestCompletionCallback callback4;
1118 1139
1119 HttpRequestInfo httpreq1 = CreateGetRequest(); 1140 HttpRequestInfo httpreq1 = CreateGetRequest();
1120 HttpRequestInfo httpreq2 = CreateGetRequest(); 1141 HttpRequestInfo httpreq2 = CreateGetRequest();
1121 HttpRequestInfo httpreq3 = CreateGetRequest(); 1142 HttpRequestInfo httpreq3 = CreateGetRequest();
1122 HttpRequestInfo httpreq4 = CreateGetRequest(); 1143 HttpRequestInfo httpreq4 = CreateGetRequest();
1123 httpreq4.priority = HIGHEST; 1144 httpreq4.priority = HIGHEST;
1124 1145
1125 out.rv = trans1->Start(&httpreq1, &callback1, log); 1146 out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
1126 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1147 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1127 // run transaction 1 through quickly to force a read of our SETTINGS 1148 // run transaction 1 through quickly to force a read of our SETTINGS
1128 // frame 1149 // frame
1129 out.rv = callback1.WaitForResult(); 1150 out.rv = callback1.WaitForResult();
1130 ASSERT_EQ(OK, out.rv); 1151 ASSERT_EQ(OK, out.rv);
1131 1152
1132 out.rv = trans2->Start(&httpreq2, &callback2, log); 1153 out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
1133 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1154 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1134 out.rv = trans3->Start(&httpreq3, &callback3, log); 1155 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
1135 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1156 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1136 out.rv = trans4->Start(&httpreq4, &callback4, log); 1157 out.rv = trans4->Start(&httpreq4, callback4.callback(), log);
1137 ASSERT_EQ(ERR_IO_PENDING, out.rv); 1158 ASSERT_EQ(ERR_IO_PENDING, out.rv);
1138 1159
1139 out.rv = callback2.WaitForResult(); 1160 out.rv = callback2.WaitForResult();
1140 ASSERT_EQ(OK, out.rv); 1161 ASSERT_EQ(OK, out.rv);
1141 EXPECT_EQ(data->read_index(), 7U); // i.e. the third & fourth trans queued 1162 EXPECT_EQ(data->read_index(), 7U); // i.e. the third & fourth trans queued
1142 1163
1143 out.rv = callback3.WaitForResult(); 1164 out.rv = callback3.WaitForResult();
1144 ASSERT_EQ(OK, out.rv); 1165 ASSERT_EQ(OK, out.rv);
1145 1166
1146 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); 1167 const HttpResponseInfo* response1 = trans1->GetResponseInfo();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 // there needs to be three sets of SSL connection data. 1259 // there needs to be three sets of SSL connection data.
1239 helper.AddData(data_placeholder.get()); 1260 helper.AddData(data_placeholder.get());
1240 helper.AddData(data_placeholder.get()); 1261 helper.AddData(data_placeholder.get());
1241 scoped_ptr<HttpNetworkTransaction> trans1( 1262 scoped_ptr<HttpNetworkTransaction> trans1(
1242 new HttpNetworkTransaction(helper.session())); 1263 new HttpNetworkTransaction(helper.session()));
1243 scoped_ptr<HttpNetworkTransaction> trans2( 1264 scoped_ptr<HttpNetworkTransaction> trans2(
1244 new HttpNetworkTransaction(helper.session())); 1265 new HttpNetworkTransaction(helper.session()));
1245 scoped_ptr<HttpNetworkTransaction> trans3( 1266 scoped_ptr<HttpNetworkTransaction> trans3(
1246 new HttpNetworkTransaction(helper.session())); 1267 new HttpNetworkTransaction(helper.session()));
1247 1268
1248 TestOldCompletionCallback callback1; 1269 TestCompletionCallback callback1;
1249 TestOldCompletionCallback callback2; 1270 TestCompletionCallback callback2;
1250 TestOldCompletionCallback callback3; 1271 TestCompletionCallback callback3;
1251 1272
1252 HttpRequestInfo httpreq1 = CreateGetRequest(); 1273 HttpRequestInfo httpreq1 = CreateGetRequest();
1253 HttpRequestInfo httpreq2 = CreateGetRequest(); 1274 HttpRequestInfo httpreq2 = CreateGetRequest();
1254 HttpRequestInfo httpreq3 = CreateGetRequest(); 1275 HttpRequestInfo httpreq3 = CreateGetRequest();
1255 1276
1256 out.rv = trans1->Start(&httpreq1, &callback1, log); 1277 out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
1257 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1278 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1258 // run transaction 1 through quickly to force a read of our SETTINGS 1279 // run transaction 1 through quickly to force a read of our SETTINGS
1259 // frame 1280 // frame
1260 out.rv = callback1.WaitForResult(); 1281 out.rv = callback1.WaitForResult();
1261 ASSERT_EQ(OK, out.rv); 1282 ASSERT_EQ(OK, out.rv);
1262 1283
1263 out.rv = trans2->Start(&httpreq2, &callback2, log); 1284 out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
1264 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1285 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1265 out.rv = trans3->Start(&httpreq3, &callback3, log); 1286 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
1266 delete trans3.release(); 1287 delete trans3.release();
1267 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1288 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1268 out.rv = callback2.WaitForResult(); 1289 out.rv = callback2.WaitForResult();
1269 ASSERT_EQ(OK, out.rv); 1290 ASSERT_EQ(OK, out.rv);
1270 1291
1271 EXPECT_EQ(8U, data->read_index()); 1292 EXPECT_EQ(8U, data->read_index());
1272 1293
1273 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); 1294 const HttpResponseInfo* response1 = trans1->GetResponseInfo();
1274 ASSERT_TRUE(response1 != NULL); 1295 ASSERT_TRUE(response1 != NULL);
1275 EXPECT_TRUE(response1->headers != NULL); 1296 EXPECT_TRUE(response1->headers != NULL);
(...skipping 12 matching lines...) Expand all
1288 out.rv = ReadTransaction(trans2.get(), &out.response_data); 1309 out.rv = ReadTransaction(trans2.get(), &out.response_data);
1289 EXPECT_EQ(OK, out.rv); 1310 EXPECT_EQ(OK, out.rv);
1290 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1311 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1291 EXPECT_EQ("hello!hello!", out.response_data); 1312 EXPECT_EQ("hello!hello!", out.response_data);
1292 helper.VerifyDataConsumed(); 1313 helper.VerifyDataConsumed();
1293 EXPECT_EQ(OK, out.rv); 1314 EXPECT_EQ(OK, out.rv);
1294 } 1315 }
1295 1316
1296 // The KillerCallback will delete the transaction on error as part of the 1317 // The KillerCallback will delete the transaction on error as part of the
1297 // callback. 1318 // callback.
1298 class KillerCallback : public TestOldCompletionCallback { 1319 class KillerCallback : public TestCompletionCallbackBase {
1299 public: 1320 public:
1300 explicit KillerCallback(HttpNetworkTransaction* transaction) 1321 explicit KillerCallback(HttpNetworkTransaction* transaction)
1301 : transaction_(transaction) {} 1322 : transaction_(transaction),
1302 1323 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
1303 virtual void RunWithParams(const Tuple1<int>& params) { 1324 base::Bind(&KillerCallback::OnComplete, base::Unretained(this)))) {
1304 if (params.a < 0)
1305 delete transaction_;
1306 TestOldCompletionCallback::RunWithParams(params);
1307 } 1325 }
1308 1326
1327 virtual ~KillerCallback() {}
1328
1329 const CompletionCallback& callback() const { return callback_; }
1330
1309 private: 1331 private:
1332 void OnComplete(int result) {
1333 if (result < 0)
1334 delete transaction_;
1335
1336 SetResult(result);
1337 }
1338
1310 HttpNetworkTransaction* transaction_; 1339 HttpNetworkTransaction* transaction_;
1340 CompletionCallback callback_;
1311 }; 1341 };
1312 1342
1313 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test 1343 // Similar to ThreeGetsMaxConcurrrentDelete above, however, this test
1314 // closes the socket while we have a pending transaction waiting for 1344 // closes the socket while we have a pending transaction waiting for
1315 // a pending stream creation. http://crbug.com/52901 1345 // a pending stream creation. http://crbug.com/52901
1316 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { 1346 TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) {
1317 // Construct the request. 1347 // Construct the request.
1318 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 1348 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1319 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 1349 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
1320 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); 1350 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 helper.RunPreTestSetup(); 1386 helper.RunPreTestSetup();
1357 helper.AddData(data.get()); 1387 helper.AddData(data.get());
1358 // We require placeholder data because three get requests are sent out, so 1388 // We require placeholder data because three get requests are sent out, so
1359 // there needs to be three sets of SSL connection data. 1389 // there needs to be three sets of SSL connection data.
1360 helper.AddData(data_placeholder.get()); 1390 helper.AddData(data_placeholder.get());
1361 helper.AddData(data_placeholder.get()); 1391 helper.AddData(data_placeholder.get());
1362 HttpNetworkTransaction trans1(helper.session()); 1392 HttpNetworkTransaction trans1(helper.session());
1363 HttpNetworkTransaction trans2(helper.session()); 1393 HttpNetworkTransaction trans2(helper.session());
1364 HttpNetworkTransaction* trans3(new HttpNetworkTransaction(helper.session())); 1394 HttpNetworkTransaction* trans3(new HttpNetworkTransaction(helper.session()));
1365 1395
1366 TestOldCompletionCallback callback1; 1396 TestCompletionCallback callback1;
1367 TestOldCompletionCallback callback2; 1397 TestCompletionCallback callback2;
1368 KillerCallback callback3(trans3); 1398 KillerCallback callback3(trans3);
1369 1399
1370 HttpRequestInfo httpreq1 = CreateGetRequest(); 1400 HttpRequestInfo httpreq1 = CreateGetRequest();
1371 HttpRequestInfo httpreq2 = CreateGetRequest(); 1401 HttpRequestInfo httpreq2 = CreateGetRequest();
1372 HttpRequestInfo httpreq3 = CreateGetRequest(); 1402 HttpRequestInfo httpreq3 = CreateGetRequest();
1373 1403
1374 out.rv = trans1.Start(&httpreq1, &callback1, log); 1404 out.rv = trans1.Start(&httpreq1, callback1.callback(), log);
1375 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1405 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1376 // run transaction 1 through quickly to force a read of our SETTINGS 1406 // run transaction 1 through quickly to force a read of our SETTINGS
1377 // frame 1407 // frame
1378 out.rv = callback1.WaitForResult(); 1408 out.rv = callback1.WaitForResult();
1379 ASSERT_EQ(OK, out.rv); 1409 ASSERT_EQ(OK, out.rv);
1380 1410
1381 out.rv = trans2.Start(&httpreq2, &callback2, log); 1411 out.rv = trans2.Start(&httpreq2, callback2.callback(), log);
1382 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1412 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1383 out.rv = trans3->Start(&httpreq3, &callback3, log); 1413 out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
1384 ASSERT_EQ(out.rv, ERR_IO_PENDING); 1414 ASSERT_EQ(out.rv, ERR_IO_PENDING);
1385 out.rv = callback3.WaitForResult(); 1415 out.rv = callback3.WaitForResult();
1386 ASSERT_EQ(ERR_ABORTED, out.rv); 1416 ASSERT_EQ(ERR_ABORTED, out.rv);
1387 1417
1388 EXPECT_EQ(6U, data->read_index()); 1418 EXPECT_EQ(6U, data->read_index());
1389 1419
1390 const HttpResponseInfo* response1 = trans1.GetResponseInfo(); 1420 const HttpResponseInfo* response1 = trans1.GetResponseInfo();
1391 ASSERT_TRUE(response1 != NULL); 1421 ASSERT_TRUE(response1 != NULL);
1392 EXPECT_TRUE(response1->headers != NULL); 1422 EXPECT_TRUE(response1->headers != NULL);
1393 EXPECT_TRUE(response1->was_fetched_via_spdy); 1423 EXPECT_TRUE(response1->was_fetched_via_spdy);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 scoped_refptr<DeterministicSocketData> data( 1780 scoped_refptr<DeterministicSocketData> data(
1751 new DeterministicSocketData(reads, arraysize(reads), 1781 new DeterministicSocketData(reads, arraysize(reads),
1752 writes, arraysize(writes))); 1782 writes, arraysize(writes)));
1753 NormalSpdyTransactionHelper helper(CreateGetRequest(), 1783 NormalSpdyTransactionHelper helper(CreateGetRequest(),
1754 BoundNetLog(), GetParam()); 1784 BoundNetLog(), GetParam());
1755 helper.SetDeterministic(); 1785 helper.SetDeterministic();
1756 helper.RunPreTestSetup(); 1786 helper.RunPreTestSetup();
1757 helper.AddDeterministicData(data.get()); 1787 helper.AddDeterministicData(data.get());
1758 HttpNetworkTransaction* trans = helper.trans(); 1788 HttpNetworkTransaction* trans = helper.trans();
1759 1789
1760 TestOldCompletionCallback callback; 1790 TestCompletionCallback callback;
1761 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 1791 int rv = trans->Start(
1792 &CreateGetRequest(), callback.callback(), BoundNetLog());
1762 EXPECT_EQ(ERR_IO_PENDING, rv); 1793 EXPECT_EQ(ERR_IO_PENDING, rv);
1763 1794
1764 data->SetStop(2); 1795 data->SetStop(2);
1765 data->Run(); 1796 data->Run();
1766 helper.ResetTrans(); 1797 helper.ResetTrans();
1767 data->SetStop(20); 1798 data->SetStop(20);
1768 data->Run(); 1799 data->Run();
1769 1800
1770 helper.VerifyDataConsumed(); 1801 helper.VerifyDataConsumed();
1771 } 1802 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 new DelayedSocketData(1, reads, arraysize(reads), 1837 new DelayedSocketData(1, reads, arraysize(reads),
1807 writes, arraysize(writes))); 1838 writes, arraysize(writes)));
1808 1839
1809 NormalSpdyTransactionHelper helper(CreateGetRequest(), 1840 NormalSpdyTransactionHelper helper(CreateGetRequest(),
1810 BoundNetLog(), GetParam()); 1841 BoundNetLog(), GetParam());
1811 helper.RunPreTestSetup(); 1842 helper.RunPreTestSetup();
1812 helper.AddData(data.get()); 1843 helper.AddData(data.get());
1813 1844
1814 HttpNetworkTransaction* trans = helper.trans(); 1845 HttpNetworkTransaction* trans = helper.trans();
1815 1846
1816 TestOldCompletionCallback callback; 1847 TestCompletionCallback callback;
1817 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 1848 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
1818 EXPECT_EQ(ERR_IO_PENDING, rv); 1849 EXPECT_EQ(ERR_IO_PENDING, rv);
1819 rv = callback.WaitForResult(); 1850 rv = callback.WaitForResult();
1820 EXPECT_EQ(OK, rv); 1851 EXPECT_EQ(OK, rv);
1821 1852
1822 const HttpResponseInfo* response = trans->GetResponseInfo(); 1853 const HttpResponseInfo* response = trans->GetResponseInfo();
1823 ASSERT_TRUE(response != NULL); 1854 ASSERT_TRUE(response != NULL);
1824 EXPECT_TRUE(response->headers != NULL); 1855 EXPECT_TRUE(response->headers != NULL);
1825 EXPECT_TRUE(response->was_fetched_via_spdy); 1856 EXPECT_TRUE(response->was_fetched_via_spdy);
1826 std::string response_data; 1857 std::string response_data;
1827 rv = ReadTransaction(trans, &response_data); 1858 rv = ReadTransaction(trans, &response_data);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 request.upload_data = new UploadData(); 1932 request.upload_data = new UploadData();
1902 for (int i = 0; i < kFrameCount; ++i) 1933 for (int i = 0; i < kFrameCount; ++i)
1903 request.upload_data->AppendBytes(content->c_str(), content->size()); 1934 request.upload_data->AppendBytes(content->c_str(), content->size());
1904 1935
1905 NormalSpdyTransactionHelper helper(request, BoundNetLog(), GetParam()); 1936 NormalSpdyTransactionHelper helper(request, BoundNetLog(), GetParam());
1906 helper.AddData(data.get()); 1937 helper.AddData(data.get());
1907 helper.RunPreTestSetup(); 1938 helper.RunPreTestSetup();
1908 1939
1909 HttpNetworkTransaction* trans = helper.trans(); 1940 HttpNetworkTransaction* trans = helper.trans();
1910 1941
1911 TestOldCompletionCallback callback; 1942 TestCompletionCallback callback;
1912 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 1943 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
1913 1944
1914 EXPECT_EQ(ERR_IO_PENDING, rv); 1945 EXPECT_EQ(ERR_IO_PENDING, rv);
1915 rv = callback.WaitForResult(); 1946 rv = callback.WaitForResult();
1916 EXPECT_EQ(OK, rv); 1947 EXPECT_EQ(OK, rv);
1917 1948
1918 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); 1949 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get());
1919 ASSERT_TRUE(stream != NULL); 1950 ASSERT_TRUE(stream != NULL);
1920 ASSERT_TRUE(stream->stream() != NULL); 1951 ASSERT_TRUE(stream->stream() != NULL);
1921 EXPECT_EQ(static_cast<int>(spdy::kSpdyStreamInitialWindowSize) + 1952 EXPECT_EQ(static_cast<int>(spdy::kSpdyStreamInitialWindowSize) +
1922 kDeltaWindowSize * kDeltaCount - 1953 kDeltaWindowSize * kDeltaCount -
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 scoped_refptr<DelayedSocketData> data( 1989 scoped_refptr<DelayedSocketData> data(
1959 new DelayedSocketData(1, reads, arraysize(reads), 1990 new DelayedSocketData(1, reads, arraysize(reads),
1960 writes, arraysize(writes))); 1991 writes, arraysize(writes)));
1961 1992
1962 NormalSpdyTransactionHelper helper(CreateGetRequest(), 1993 NormalSpdyTransactionHelper helper(CreateGetRequest(),
1963 BoundNetLog(), GetParam()); 1994 BoundNetLog(), GetParam());
1964 helper.AddData(data.get()); 1995 helper.AddData(data.get());
1965 helper.RunPreTestSetup(); 1996 helper.RunPreTestSetup();
1966 HttpNetworkTransaction* trans = helper.trans(); 1997 HttpNetworkTransaction* trans = helper.trans();
1967 1998
1968 TestOldCompletionCallback callback; 1999 TestCompletionCallback callback;
1969 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 2000 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
1970 2001
1971 EXPECT_EQ(ERR_IO_PENDING, rv); 2002 EXPECT_EQ(ERR_IO_PENDING, rv);
1972 rv = callback.WaitForResult(); 2003 rv = callback.WaitForResult();
1973 EXPECT_EQ(OK, rv); 2004 EXPECT_EQ(OK, rv);
1974 2005
1975 SpdyHttpStream* stream = 2006 SpdyHttpStream* stream =
1976 static_cast<SpdyHttpStream*>(trans->stream_.get()); 2007 static_cast<SpdyHttpStream*>(trans->stream_.get());
1977 ASSERT_TRUE(stream != NULL); 2008 ASSERT_TRUE(stream != NULL);
1978 ASSERT_TRUE(stream->stream() != NULL); 2009 ASSERT_TRUE(stream->stream() != NULL);
1979 2010
1980 EXPECT_EQ( 2011 EXPECT_EQ(
1981 static_cast<int>(spdy::kSpdyStreamInitialWindowSize) - kUploadDataSize, 2012 static_cast<int>(spdy::kSpdyStreamInitialWindowSize) - kUploadDataSize,
1982 stream->stream()->recv_window_size()); 2013 stream->stream()->recv_window_size());
1983 2014
1984 const HttpResponseInfo* response = trans->GetResponseInfo(); 2015 const HttpResponseInfo* response = trans->GetResponseInfo();
1985 ASSERT_TRUE(response != NULL); 2016 ASSERT_TRUE(response != NULL);
1986 ASSERT_TRUE(response->headers != NULL); 2017 ASSERT_TRUE(response->headers != NULL);
1987 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 2018 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
1988 EXPECT_TRUE(response->was_fetched_via_spdy); 2019 EXPECT_TRUE(response->was_fetched_via_spdy);
1989 2020
1990 // Issue a read which will cause a WINDOW_UPDATE to be sent and window 2021 // Issue a read which will cause a WINDOW_UPDATE to be sent and window
1991 // size increased to default. 2022 // size increased to default.
1992 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kUploadDataSize)); 2023 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kUploadDataSize));
1993 rv = trans->Read(buf, kUploadDataSize, NULL); 2024 rv = trans->Read(buf, kUploadDataSize, CompletionCallback());
1994 EXPECT_EQ(kUploadDataSize, rv); 2025 EXPECT_EQ(kUploadDataSize, rv);
1995 std::string content(buf->data(), buf->data()+kUploadDataSize); 2026 std::string content(buf->data(), buf->data()+kUploadDataSize);
1996 EXPECT_STREQ(kUploadData, content.c_str()); 2027 EXPECT_STREQ(kUploadData, content.c_str());
1997 2028
1998 // Schedule the reading of empty data frame with FIN 2029 // Schedule the reading of empty data frame with FIN
1999 data->CompleteRead(); 2030 data->CompleteRead();
2000 2031
2001 // Force write of WINDOW_UPDATE which was scheduled during the above 2032 // Force write of WINDOW_UPDATE which was scheduled during the above
2002 // read. 2033 // read.
2003 MessageLoop::current()->RunAllPending(); 2034 MessageLoop::current()->RunAllPending();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 for (int i = 0; i < kFrameCount; ++i) 2095 for (int i = 0; i < kFrameCount; ++i)
2065 request.upload_data->AppendBytes(content->c_str(), content->size()); 2096 request.upload_data->AppendBytes(content->c_str(), content->size());
2066 2097
2067 NormalSpdyTransactionHelper helper(request, 2098 NormalSpdyTransactionHelper helper(request,
2068 BoundNetLog(), GetParam()); 2099 BoundNetLog(), GetParam());
2069 helper.AddData(data.get()); 2100 helper.AddData(data.get());
2070 helper.RunPreTestSetup(); 2101 helper.RunPreTestSetup();
2071 2102
2072 HttpNetworkTransaction* trans = helper.trans(); 2103 HttpNetworkTransaction* trans = helper.trans();
2073 2104
2074 TestOldCompletionCallback callback; 2105 TestCompletionCallback callback;
2075 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 2106 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
2076 2107
2077 EXPECT_EQ(ERR_IO_PENDING, rv); 2108 EXPECT_EQ(ERR_IO_PENDING, rv);
2078 rv = callback.WaitForResult(); 2109 rv = callback.WaitForResult();
2079 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv); 2110 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, rv);
2080 2111
2081 data->CompleteRead(); 2112 data->CompleteRead();
2082 2113
2083 ASSERT_TRUE(helper.session() != NULL); 2114 ASSERT_TRUE(helper.session() != NULL);
2084 ASSERT_TRUE(helper.session()->spdy_session_pool() != NULL); 2115 ASSERT_TRUE(helper.session()->spdy_session_pool() != NULL);
2085 helper.session()->spdy_session_pool()->CloseAllSessions(); 2116 helper.session()->spdy_session_pool()->CloseAllSessions();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 new std::string(spdy::kSpdyStreamInitialWindowSize, 'a')); 2203 new std::string(spdy::kSpdyStreamInitialWindowSize, 'a'));
2173 upload_data->append(kUploadData, kUploadDataSize); 2204 upload_data->append(kUploadData, kUploadDataSize);
2174 request.upload_data->AppendBytes(upload_data->c_str(), upload_data->size()); 2205 request.upload_data->AppendBytes(upload_data->c_str(), upload_data->size());
2175 NormalSpdyTransactionHelper helper(request, 2206 NormalSpdyTransactionHelper helper(request,
2176 BoundNetLog(), GetParam()); 2207 BoundNetLog(), GetParam());
2177 helper.AddData(data.get()); 2208 helper.AddData(data.get());
2178 helper.RunPreTestSetup(); 2209 helper.RunPreTestSetup();
2179 2210
2180 HttpNetworkTransaction* trans = helper.trans(); 2211 HttpNetworkTransaction* trans = helper.trans();
2181 2212
2182 TestOldCompletionCallback callback; 2213 TestCompletionCallback callback;
2183 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 2214 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
2184 EXPECT_EQ(ERR_IO_PENDING, rv); 2215 EXPECT_EQ(ERR_IO_PENDING, rv);
2185 2216
2186 MessageLoop::current()->RunAllPending(); // Write as much as we can. 2217 MessageLoop::current()->RunAllPending(); // Write as much as we can.
2187 2218
2188 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get()); 2219 SpdyHttpStream* stream = static_cast<SpdyHttpStream*>(trans->stream_.get());
2189 ASSERT_TRUE(stream != NULL); 2220 ASSERT_TRUE(stream != NULL);
2190 ASSERT_TRUE(stream->stream() != NULL); 2221 ASSERT_TRUE(stream->stream() != NULL);
2191 EXPECT_EQ(0, stream->stream()->send_window_size()); 2222 EXPECT_EQ(0, stream->stream()->send_window_size());
2192 EXPECT_FALSE(stream->request_body_stream_->eof()); 2223 EXPECT_FALSE(stream->request_body_stream_->eof());
2193 2224
(...skipping 23 matching lines...) Expand all
2217 2248
2218 StaticSocketDataProvider data(reads, arraysize(reads), 2249 StaticSocketDataProvider data(reads, arraysize(reads),
2219 writes, arraysize(writes)); 2250 writes, arraysize(writes));
2220 2251
2221 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2252 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2222 BoundNetLog(), GetParam()); 2253 BoundNetLog(), GetParam());
2223 helper.RunPreTestSetup(); 2254 helper.RunPreTestSetup();
2224 helper.AddData(&data); 2255 helper.AddData(&data);
2225 HttpNetworkTransaction* trans = helper.trans(); 2256 HttpNetworkTransaction* trans = helper.trans();
2226 2257
2227 TestOldCompletionCallback callback; 2258 TestCompletionCallback callback;
2228 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 2259 int rv = trans->Start(
2260 &CreateGetRequest(), callback.callback(), BoundNetLog());
2229 EXPECT_EQ(ERR_IO_PENDING, rv); 2261 EXPECT_EQ(ERR_IO_PENDING, rv);
2230 helper.ResetTrans(); // Cancel the transaction. 2262 helper.ResetTrans(); // Cancel the transaction.
2231 2263
2232 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the 2264 // Flush the MessageLoop while the SpdySessionDependencies (in particular, the
2233 // MockClientSocketFactory) are still alive. 2265 // MockClientSocketFactory) are still alive.
2234 MessageLoop::current()->RunAllPending(); 2266 MessageLoop::current()->RunAllPending();
2235 helper.VerifyDataNotConsumed(); 2267 helper.VerifyDataNotConsumed();
2236 } 2268 }
2237 2269
2238 // Verify that the client sends a Rst Frame upon cancelling the stream. 2270 // Verify that the client sends a Rst Frame upon cancelling the stream.
(...skipping 17 matching lines...) Expand all
2256 writes, arraysize(writes))); 2288 writes, arraysize(writes)));
2257 2289
2258 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2290 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2259 BoundNetLog(), 2291 BoundNetLog(),
2260 GetParam()); 2292 GetParam());
2261 helper.SetDeterministic(); 2293 helper.SetDeterministic();
2262 helper.RunPreTestSetup(); 2294 helper.RunPreTestSetup();
2263 helper.AddDeterministicData(data.get()); 2295 helper.AddDeterministicData(data.get());
2264 HttpNetworkTransaction* trans = helper.trans(); 2296 HttpNetworkTransaction* trans = helper.trans();
2265 2297
2266 TestOldCompletionCallback callback; 2298 TestCompletionCallback callback;
2267 2299
2268 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 2300 int rv = trans->Start(
2301 &CreateGetRequest(), callback.callback(), BoundNetLog());
2269 EXPECT_EQ(ERR_IO_PENDING, rv); 2302 EXPECT_EQ(ERR_IO_PENDING, rv);
2270 2303
2271 data->SetStop(2); 2304 data->SetStop(2);
2272 data->Run(); 2305 data->Run();
2273 helper.ResetTrans(); 2306 helper.ResetTrans();
2274 data->SetStop(20); 2307 data->SetStop(20);
2275 data->Run(); 2308 data->Run();
2276 2309
2277 helper.VerifyDataConsumed(); 2310 helper.VerifyDataConsumed();
2278 } 2311 }
2279 2312
2280 class SpdyNetworkTransactionTest::StartTransactionCallback
2281 : public CallbackRunner< Tuple1<int> > {
2282 public:
2283 explicit StartTransactionCallback(
2284 const scoped_refptr<HttpNetworkSession>& session,
2285 NormalSpdyTransactionHelper& helper)
2286 : session_(session), helper_(helper) {}
2287
2288 // We try to start another transaction, which should succeed.
2289 virtual void RunWithParams(const Tuple1<int>& params) {
2290 scoped_ptr<HttpNetworkTransaction> trans(
2291 new HttpNetworkTransaction(session_));
2292 TestOldCompletionCallback callback;
2293 HttpRequestInfo request;
2294 request.method = "GET";
2295 request.url = GURL("http://www.google.com/");
2296 request.load_flags = 0;
2297 int rv = trans->Start(&request, &callback, BoundNetLog());
2298 EXPECT_EQ(ERR_IO_PENDING, rv);
2299 rv = callback.WaitForResult();
2300 }
2301
2302 private:
2303 const scoped_refptr<HttpNetworkSession>& session_;
2304 NormalSpdyTransactionHelper& helper_;
2305 };
2306
2307 // Verify that the client can correctly deal with the user callback attempting 2313 // Verify that the client can correctly deal with the user callback attempting
2308 // to start another transaction on a session that is closing down. See 2314 // to start another transaction on a session that is closing down. See
2309 // http://crbug.com/47455 2315 // http://crbug.com/47455
2310 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { 2316 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) {
2311 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2317 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2312 MockWrite writes[] = { CreateMockWrite(*req) }; 2318 MockWrite writes[] = { CreateMockWrite(*req) };
2313 MockWrite writes2[] = { CreateMockWrite(*req) }; 2319 MockWrite writes2[] = { CreateMockWrite(*req) };
2314 2320
2315 // The indicated length of this packet is longer than its actual length. When 2321 // The indicated length of this packet is longer than its actual length. When
2316 // the session receives an empty packet after this one, it shuts down the 2322 // the session receives an empty packet after this one, it shuts down the
(...skipping 26 matching lines...) Expand all
2343 writes2, arraysize(writes2))); 2349 writes2, arraysize(writes2)));
2344 2350
2345 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2351 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2346 BoundNetLog(), GetParam()); 2352 BoundNetLog(), GetParam());
2347 helper.RunPreTestSetup(); 2353 helper.RunPreTestSetup();
2348 helper.AddData(data.get()); 2354 helper.AddData(data.get());
2349 helper.AddData(data2.get()); 2355 helper.AddData(data2.get());
2350 HttpNetworkTransaction* trans = helper.trans(); 2356 HttpNetworkTransaction* trans = helper.trans();
2351 2357
2352 // Start the transaction with basic parameters. 2358 // Start the transaction with basic parameters.
2353 TestOldCompletionCallback callback; 2359 TestCompletionCallback callback;
2354 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 2360 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
2355 EXPECT_EQ(ERR_IO_PENDING, rv); 2361 EXPECT_EQ(ERR_IO_PENDING, rv);
2356 rv = callback.WaitForResult(); 2362 rv = callback.WaitForResult();
2357 2363
2358 StartTransactionCallback callback2(helper.session(), helper);
2359 const int kSize = 3000; 2364 const int kSize = 3000;
2360 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); 2365 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
2361 rv = trans->Read(buf, kSize, &callback2); 2366 rv = trans->Read(
2367 buf, kSize,
2368 base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback,
2369 helper.session()));
2362 // This forces an err_IO_pending, which sets the callback. 2370 // This forces an err_IO_pending, which sets the callback.
2363 data->CompleteRead(); 2371 data->CompleteRead();
2364 // This finishes the read. 2372 // This finishes the read.
2365 data->CompleteRead(); 2373 data->CompleteRead();
2366 helper.VerifyDataConsumed(); 2374 helper.VerifyDataConsumed();
2367 } 2375 }
2368 2376
2369 class SpdyNetworkTransactionTest::DeleteSessionCallback
2370 : public CallbackRunner< Tuple1<int> > {
2371 public:
2372 explicit DeleteSessionCallback(NormalSpdyTransactionHelper& helper) :
2373 helper_(helper) {}
2374
2375 // We kill the transaction, which deletes the session and stream.
2376 virtual void RunWithParams(const Tuple1<int>& params) {
2377 helper_.ResetTrans();
2378 }
2379
2380 private:
2381 NormalSpdyTransactionHelper& helper_;
2382 };
2383
2384 // Verify that the client can correctly deal with the user callback deleting the 2377 // Verify that the client can correctly deal with the user callback deleting the
2385 // transaction. Failures will usually be valgrind errors. See 2378 // transaction. Failures will usually be valgrind errors. See
2386 // http://crbug.com/46925 2379 // http://crbug.com/46925
2387 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { 2380 TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) {
2388 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 2381 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
2389 MockWrite writes[] = { CreateMockWrite(*req) }; 2382 MockWrite writes[] = { CreateMockWrite(*req) };
2390 2383
2391 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 2384 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
2392 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 2385 scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
2393 MockRead reads[] = { 2386 MockRead reads[] = {
2394 CreateMockRead(*resp.get(), 2), 2387 CreateMockRead(*resp.get(), 2),
2395 MockRead(true, ERR_IO_PENDING, 3), // Force a pause 2388 MockRead(true, ERR_IO_PENDING, 3), // Force a pause
2396 CreateMockRead(*body.get(), 4), 2389 CreateMockRead(*body.get(), 4),
2397 MockRead(true, 0, 0, 5), // EOF 2390 MockRead(true, 0, 0, 5), // EOF
2398 }; 2391 };
2399 2392
2400 scoped_refptr<OrderedSocketData> data( 2393 scoped_refptr<OrderedSocketData> data(
2401 new OrderedSocketData(reads, arraysize(reads), 2394 new OrderedSocketData(reads, arraysize(reads),
2402 writes, arraysize(writes))); 2395 writes, arraysize(writes)));
2403 2396
2404 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2397 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2405 BoundNetLog(), GetParam()); 2398 BoundNetLog(), GetParam());
2406 helper.RunPreTestSetup(); 2399 helper.RunPreTestSetup();
2407 helper.AddData(data.get()); 2400 helper.AddData(data.get());
2408 HttpNetworkTransaction* trans = helper.trans(); 2401 HttpNetworkTransaction* trans = helper.trans();
2409 2402
2410 // Start the transaction with basic parameters. 2403 // Start the transaction with basic parameters.
2411 TestOldCompletionCallback callback; 2404 TestCompletionCallback callback;
2412 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 2405 int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
2413 EXPECT_EQ(ERR_IO_PENDING, rv); 2406 EXPECT_EQ(ERR_IO_PENDING, rv);
2414 rv = callback.WaitForResult(); 2407 rv = callback.WaitForResult();
2415 2408
2416 // Setup a user callback which will delete the session, and clear out the 2409 // Setup a user callback which will delete the session, and clear out the
2417 // memory holding the stream object. Note that the callback deletes trans. 2410 // memory holding the stream object. Note that the callback deletes trans.
2418 DeleteSessionCallback callback2(helper);
2419 const int kSize = 3000; 2411 const int kSize = 3000;
2420 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize)); 2412 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
2421 rv = trans->Read(buf, kSize, &callback2); 2413 rv = trans->Read(
2414 buf, kSize,
2415 base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback,
2416 base::Unretained(&helper)));
2422 ASSERT_EQ(ERR_IO_PENDING, rv); 2417 ASSERT_EQ(ERR_IO_PENDING, rv);
2423 data->CompleteRead(); 2418 data->CompleteRead();
2424 2419
2425 // Finish running rest of tasks. 2420 // Finish running rest of tasks.
2426 MessageLoop::current()->RunAllPending(); 2421 MessageLoop::current()->RunAllPending();
2427 helper.VerifyDataConsumed(); 2422 helper.VerifyDataConsumed();
2428 } 2423 }
2429 2424
2430 // Send a spdy request to www.google.com that gets redirected to www.foo.com. 2425 // Send a spdy request to www.google.com that gets redirected to www.foo.com.
2431 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { 2426 TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) {
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 writes, arraysize(writes))); 2803 writes, arraysize(writes)));
2809 NormalSpdyTransactionHelper helper(CreateGetRequest(), 2804 NormalSpdyTransactionHelper helper(CreateGetRequest(),
2810 BoundNetLog(), GetParam()); 2805 BoundNetLog(), GetParam());
2811 2806
2812 helper.RunPreTestSetup(); 2807 helper.RunPreTestSetup();
2813 helper.AddData(data.get()); 2808 helper.AddData(data.get());
2814 2809
2815 HttpNetworkTransaction* trans = helper.trans(); 2810 HttpNetworkTransaction* trans = helper.trans();
2816 2811
2817 // Start the transaction with basic parameters. 2812 // Start the transaction with basic parameters.
2818 TestOldCompletionCallback callback; 2813 TestCompletionCallback callback;
2819 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 2814 int rv = trans->Start(
2815 &CreateGetRequest(), callback.callback(), BoundNetLog());
2820 EXPECT_EQ(ERR_IO_PENDING, rv); 2816 EXPECT_EQ(ERR_IO_PENDING, rv);
2821 rv = callback.WaitForResult(); 2817 rv = callback.WaitForResult();
2822 EXPECT_EQ(OK, rv); 2818 EXPECT_EQ(OK, rv);
2823 2819
2824 // Verify that we consumed all test data. 2820 // Verify that we consumed all test data.
2825 EXPECT_TRUE(data->at_read_eof()) << "Read count: " 2821 EXPECT_TRUE(data->at_read_eof()) << "Read count: "
2826 << data->read_count() 2822 << data->read_count()
2827 << " Read index: " 2823 << " Read index: "
2828 << data->read_index(); 2824 << data->read_index();
2829 EXPECT_TRUE(data->at_write_eof()) << "Write count: " 2825 EXPECT_TRUE(data->at_write_eof()) << "Write count: "
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3062 writes, arraysize(writes))); 3058 writes, arraysize(writes)));
3063 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3059 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3064 BoundNetLog(), GetParam()); 3060 BoundNetLog(), GetParam());
3065 3061
3066 helper.RunPreTestSetup(); 3062 helper.RunPreTestSetup();
3067 helper.AddData(data.get()); 3063 helper.AddData(data.get());
3068 3064
3069 HttpNetworkTransaction* trans = helper.trans(); 3065 HttpNetworkTransaction* trans = helper.trans();
3070 3066
3071 // Start the transaction with basic parameters. 3067 // Start the transaction with basic parameters.
3072 TestOldCompletionCallback callback; 3068 TestCompletionCallback callback;
3073 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 3069 int rv = trans->Start(
3070 &CreateGetRequest(), callback.callback(), BoundNetLog());
3074 EXPECT_EQ(ERR_IO_PENDING, rv); 3071 EXPECT_EQ(ERR_IO_PENDING, rv);
3075 rv = callback.WaitForResult(); 3072 rv = callback.WaitForResult();
3076 EXPECT_EQ(OK, rv); 3073 EXPECT_EQ(OK, rv);
3077 3074
3078 // Verify that we consumed all test data. 3075 // Verify that we consumed all test data.
3079 EXPECT_TRUE(data->at_read_eof()) << "Read count: " 3076 EXPECT_TRUE(data->at_read_eof()) << "Read count: "
3080 << data->read_count() 3077 << data->read_count()
3081 << " Read index: " 3078 << " Read index: "
3082 << data->read_index(); 3079 << data->read_index();
3083 EXPECT_TRUE(data->at_write_eof()) << "Write count: " 3080 EXPECT_TRUE(data->at_write_eof()) << "Write count: "
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 writes, arraysize(writes))); 3120 writes, arraysize(writes)));
3124 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3121 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3125 BoundNetLog(), GetParam()); 3122 BoundNetLog(), GetParam());
3126 3123
3127 helper.RunPreTestSetup(); 3124 helper.RunPreTestSetup();
3128 helper.AddData(data.get()); 3125 helper.AddData(data.get());
3129 3126
3130 HttpNetworkTransaction* trans = helper.trans(); 3127 HttpNetworkTransaction* trans = helper.trans();
3131 3128
3132 // Start the transaction with basic parameters. 3129 // Start the transaction with basic parameters.
3133 TestOldCompletionCallback callback; 3130 TestCompletionCallback callback;
3134 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 3131 int rv = trans->Start(
3132 &CreateGetRequest(), callback.callback(), BoundNetLog());
3135 EXPECT_EQ(ERR_IO_PENDING, rv); 3133 EXPECT_EQ(ERR_IO_PENDING, rv);
3136 rv = callback.WaitForResult(); 3134 rv = callback.WaitForResult();
3137 EXPECT_EQ(OK, rv); 3135 EXPECT_EQ(OK, rv);
3138 3136
3139 // Verify that we consumed all test data. 3137 // Verify that we consumed all test data.
3140 EXPECT_TRUE(data->at_read_eof()) << "Read count: " 3138 EXPECT_TRUE(data->at_read_eof()) << "Read count: "
3141 << data->read_count() 3139 << data->read_count()
3142 << " Read index: " 3140 << " Read index: "
3143 << data->read_index(); 3141 << data->read_index();
3144 EXPECT_TRUE(data->at_write_eof()) << "Write count: " 3142 EXPECT_TRUE(data->at_write_eof()) << "Write count: "
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3180 writes, arraysize(writes))); 3178 writes, arraysize(writes)));
3181 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3179 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3182 BoundNetLog(), GetParam()); 3180 BoundNetLog(), GetParam());
3183 3181
3184 helper.RunPreTestSetup(); 3182 helper.RunPreTestSetup();
3185 helper.AddData(data.get()); 3183 helper.AddData(data.get());
3186 3184
3187 HttpNetworkTransaction* trans = helper.trans(); 3185 HttpNetworkTransaction* trans = helper.trans();
3188 3186
3189 // Start the transaction with basic parameters. 3187 // Start the transaction with basic parameters.
3190 TestOldCompletionCallback callback; 3188 TestCompletionCallback callback;
3191 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 3189 int rv = trans->Start(
3190 &CreateGetRequest(), callback.callback(), BoundNetLog());
3192 EXPECT_EQ(ERR_IO_PENDING, rv); 3191 EXPECT_EQ(ERR_IO_PENDING, rv);
3193 rv = callback.WaitForResult(); 3192 rv = callback.WaitForResult();
3194 EXPECT_EQ(OK, rv); 3193 EXPECT_EQ(OK, rv);
3195 // Verify that we consumed all test data. 3194 // Verify that we consumed all test data.
3196 EXPECT_TRUE(data->at_read_eof()) << "Read count: " 3195 EXPECT_TRUE(data->at_read_eof()) << "Read count: "
3197 << data->read_count() 3196 << data->read_count()
3198 << " Read index: " 3197 << " Read index: "
3199 << data->read_index(); 3198 << data->read_index();
3200 EXPECT_TRUE(data->at_write_eof()) << "Write count: " 3199 EXPECT_TRUE(data->at_write_eof()) << "Write count: "
3201 << data->write_count() 3200 << data->write_count()
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
3771 MockRead(true, ERR_IO_PENDING), // Force a pause 3770 MockRead(true, ERR_IO_PENDING), // Force a pause
3772 CreateMockRead(*last_frame), 3771 CreateMockRead(*last_frame),
3773 MockRead(true, 0, 0) // EOF 3772 MockRead(true, 0, 0) // EOF
3774 }; 3773 };
3775 3774
3776 scoped_refptr<DelayedSocketData> data( 3775 scoped_refptr<DelayedSocketData> data(
3777 new DelayedSocketData(1, reads, arraysize(reads), 3776 new DelayedSocketData(1, reads, arraysize(reads),
3778 writes, arraysize(writes))); 3777 writes, arraysize(writes)));
3779 3778
3780 3779
3781 TestOldCompletionCallback callback; 3780 TestCompletionCallback callback;
3782 3781
3783 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3782 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3784 BoundNetLog(), GetParam()); 3783 BoundNetLog(), GetParam());
3785 helper.RunPreTestSetup(); 3784 helper.RunPreTestSetup();
3786 helper.AddData(data.get()); 3785 helper.AddData(data.get());
3787 HttpNetworkTransaction* trans = helper.trans(); 3786 HttpNetworkTransaction* trans = helper.trans();
3788 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 3787 int rv = trans->Start(
3788 &CreateGetRequest(), callback.callback(), BoundNetLog());
3789 EXPECT_EQ(ERR_IO_PENDING, rv); 3789 EXPECT_EQ(ERR_IO_PENDING, rv);
3790 3790
3791 TransactionHelperResult out = helper.output(); 3791 TransactionHelperResult out = helper.output();
3792 out.rv = callback.WaitForResult(); 3792 out.rv = callback.WaitForResult();
3793 EXPECT_EQ(out.rv, OK); 3793 EXPECT_EQ(out.rv, OK);
3794 3794
3795 const HttpResponseInfo* response = trans->GetResponseInfo(); 3795 const HttpResponseInfo* response = trans->GetResponseInfo();
3796 EXPECT_TRUE(response->headers != NULL); 3796 EXPECT_TRUE(response->headers != NULL);
3797 EXPECT_TRUE(response->was_fetched_via_spdy); 3797 EXPECT_TRUE(response->was_fetched_via_spdy);
3798 out.status_line = response->headers->GetStatusLine(); 3798 out.status_line = response->headers->GetStatusLine();
3799 out.response_info = *response; // Make a copy so we can verify. 3799 out.response_info = *response; // Make a copy so we can verify.
3800 3800
3801 // Read Data 3801 // Read Data
3802 TestOldCompletionCallback read_callback; 3802 TestCompletionCallback read_callback;
3803 3803
3804 std::string content; 3804 std::string content;
3805 do { 3805 do {
3806 // Read small chunks at a time. 3806 // Read small chunks at a time.
3807 const int kSmallReadSize = 3; 3807 const int kSmallReadSize = 3;
3808 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); 3808 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
3809 rv = trans->Read(buf, kSmallReadSize, &read_callback); 3809 rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
3810 if (rv == net::ERR_IO_PENDING) { 3810 if (rv == net::ERR_IO_PENDING) {
3811 data->CompleteRead(); 3811 data->CompleteRead();
3812 rv = read_callback.WaitForResult(); 3812 rv = read_callback.WaitForResult();
3813 } 3813 }
3814 if (rv > 0) { 3814 if (rv > 0) {
3815 content.append(buf->data(), rv); 3815 content.append(buf->data(), rv);
3816 } else if (rv < 0) { 3816 } else if (rv < 0) {
3817 NOTREACHED(); 3817 NOTREACHED();
3818 } 3818 }
3819 } while (rv > 0); 3819 } while (rv > 0);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3868 scoped_refptr<DelayedSocketData> data( 3868 scoped_refptr<DelayedSocketData> data(
3869 new DelayedSocketData(1, reads, arraysize(reads), 3869 new DelayedSocketData(1, reads, arraysize(reads),
3870 writes, arraysize(writes))); 3870 writes, arraysize(writes)));
3871 3871
3872 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3872 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3873 BoundNetLog(), GetParam()); 3873 BoundNetLog(), GetParam());
3874 helper.RunPreTestSetup(); 3874 helper.RunPreTestSetup();
3875 helper.AddData(data.get()); 3875 helper.AddData(data.get());
3876 HttpNetworkTransaction* trans = helper.trans(); 3876 HttpNetworkTransaction* trans = helper.trans();
3877 3877
3878 TestOldCompletionCallback callback; 3878 TestCompletionCallback callback;
3879 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 3879 int rv = trans->Start(
3880 &CreateGetRequest(), callback.callback(), BoundNetLog());
3880 EXPECT_EQ(ERR_IO_PENDING, rv); 3881 EXPECT_EQ(ERR_IO_PENDING, rv);
3881 3882
3882 TransactionHelperResult out = helper.output(); 3883 TransactionHelperResult out = helper.output();
3883 out.rv = callback.WaitForResult(); 3884 out.rv = callback.WaitForResult();
3884 EXPECT_EQ(out.rv, OK); 3885 EXPECT_EQ(out.rv, OK);
3885 3886
3886 const HttpResponseInfo* response = trans->GetResponseInfo(); 3887 const HttpResponseInfo* response = trans->GetResponseInfo();
3887 EXPECT_TRUE(response->headers != NULL); 3888 EXPECT_TRUE(response->headers != NULL);
3888 EXPECT_TRUE(response->was_fetched_via_spdy); 3889 EXPECT_TRUE(response->was_fetched_via_spdy);
3889 out.status_line = response->headers->GetStatusLine(); 3890 out.status_line = response->headers->GetStatusLine();
3890 out.response_info = *response; // Make a copy so we can verify. 3891 out.response_info = *response; // Make a copy so we can verify.
3891 3892
3892 // Read Data 3893 // Read Data
3893 TestOldCompletionCallback read_callback; 3894 TestCompletionCallback read_callback;
3894 3895
3895 std::string content; 3896 std::string content;
3896 int reads_completed = 0; 3897 int reads_completed = 0;
3897 do { 3898 do {
3898 // Read small chunks at a time. 3899 // Read small chunks at a time.
3899 const int kSmallReadSize = 14; 3900 const int kSmallReadSize = 14;
3900 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); 3901 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
3901 rv = trans->Read(buf, kSmallReadSize, &read_callback); 3902 rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
3902 if (rv == net::ERR_IO_PENDING) { 3903 if (rv == net::ERR_IO_PENDING) {
3903 data->CompleteRead(); 3904 data->CompleteRead();
3904 rv = read_callback.WaitForResult(); 3905 rv = read_callback.WaitForResult();
3905 } 3906 }
3906 if (rv > 0) { 3907 if (rv > 0) {
3907 EXPECT_EQ(kSmallReadSize, rv); 3908 EXPECT_EQ(kSmallReadSize, rv);
3908 content.append(buf->data(), rv); 3909 content.append(buf->data(), rv);
3909 } else if (rv < 0) { 3910 } else if (rv < 0) {
3910 FAIL() << "Unexpected read error: " << rv; 3911 FAIL() << "Unexpected read error: " << rv;
3911 } 3912 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3963 scoped_refptr<DelayedSocketData> data( 3964 scoped_refptr<DelayedSocketData> data(
3964 new DelayedSocketData(1, reads, arraysize(reads), 3965 new DelayedSocketData(1, reads, arraysize(reads),
3965 writes, arraysize(writes))); 3966 writes, arraysize(writes)));
3966 3967
3967 NormalSpdyTransactionHelper helper(CreateGetRequest(), 3968 NormalSpdyTransactionHelper helper(CreateGetRequest(),
3968 BoundNetLog(), GetParam()); 3969 BoundNetLog(), GetParam());
3969 helper.RunPreTestSetup(); 3970 helper.RunPreTestSetup();
3970 helper.AddData(data.get()); 3971 helper.AddData(data.get());
3971 HttpNetworkTransaction* trans = helper.trans(); 3972 HttpNetworkTransaction* trans = helper.trans();
3972 3973
3973 TestOldCompletionCallback callback; 3974 TestCompletionCallback callback;
3974 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 3975 int rv = trans->Start(
3976 &CreateGetRequest(), callback.callback(), BoundNetLog());
3975 EXPECT_EQ(ERR_IO_PENDING, rv); 3977 EXPECT_EQ(ERR_IO_PENDING, rv);
3976 3978
3977 TransactionHelperResult out = helper.output(); 3979 TransactionHelperResult out = helper.output();
3978 out.rv = callback.WaitForResult(); 3980 out.rv = callback.WaitForResult();
3979 EXPECT_EQ(out.rv, OK); 3981 EXPECT_EQ(out.rv, OK);
3980 3982
3981 const HttpResponseInfo* response = trans->GetResponseInfo(); 3983 const HttpResponseInfo* response = trans->GetResponseInfo();
3982 EXPECT_TRUE(response->headers != NULL); 3984 EXPECT_TRUE(response->headers != NULL);
3983 EXPECT_TRUE(response->was_fetched_via_spdy); 3985 EXPECT_TRUE(response->was_fetched_via_spdy);
3984 out.status_line = response->headers->GetStatusLine(); 3986 out.status_line = response->headers->GetStatusLine();
3985 out.response_info = *response; // Make a copy so we can verify. 3987 out.response_info = *response; // Make a copy so we can verify.
3986 3988
3987 // Read Data 3989 // Read Data
3988 TestOldCompletionCallback read_callback; 3990 TestCompletionCallback read_callback;
3989 3991
3990 std::string content; 3992 std::string content;
3991 int reads_completed = 0; 3993 int reads_completed = 0;
3992 do { 3994 do {
3993 // Read small chunks at a time. 3995 // Read small chunks at a time.
3994 const int kSmallReadSize = 14; 3996 const int kSmallReadSize = 14;
3995 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); 3997 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
3996 rv = trans->Read(buf, kSmallReadSize, &read_callback); 3998 rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
3997 if (rv > 0) { 3999 if (rv > 0) {
3998 EXPECT_EQ(kSmallReadSize, rv); 4000 EXPECT_EQ(kSmallReadSize, rv);
3999 content.append(buf->data(), rv); 4001 content.append(buf->data(), rv);
4000 } else if (rv < 0) { 4002 } else if (rv < 0) {
4001 FAIL() << "Unexpected read error: " << rv; 4003 FAIL() << "Unexpected read error: " << rv;
4002 } 4004 }
4003 reads_completed++; 4005 reads_completed++;
4004 } while (rv > 0); 4006 } while (rv > 0);
4005 4007
4006 EXPECT_EQ(3, reads_completed); 4008 EXPECT_EQ(3, reads_completed);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4051 scoped_refptr<DelayedSocketData> data( 4053 scoped_refptr<DelayedSocketData> data(
4052 new DelayedSocketData(1, reads, arraysize(reads), 4054 new DelayedSocketData(1, reads, arraysize(reads),
4053 writes, arraysize(writes))); 4055 writes, arraysize(writes)));
4054 4056
4055 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4057 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4056 BoundNetLog(), GetParam()); 4058 BoundNetLog(), GetParam());
4057 helper.RunPreTestSetup(); 4059 helper.RunPreTestSetup();
4058 helper.AddData(data.get()); 4060 helper.AddData(data.get());
4059 HttpNetworkTransaction* trans = helper.trans(); 4061 HttpNetworkTransaction* trans = helper.trans();
4060 4062
4061 TestOldCompletionCallback callback; 4063 TestCompletionCallback callback;
4062 4064
4063 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 4065 int rv = trans->Start(
4066 &CreateGetRequest(), callback.callback(), BoundNetLog());
4064 EXPECT_EQ(ERR_IO_PENDING, rv); 4067 EXPECT_EQ(ERR_IO_PENDING, rv);
4065 4068
4066 TransactionHelperResult out = helper.output(); 4069 TransactionHelperResult out = helper.output();
4067 out.rv = callback.WaitForResult(); 4070 out.rv = callback.WaitForResult();
4068 EXPECT_EQ(out.rv, OK); 4071 EXPECT_EQ(out.rv, OK);
4069 4072
4070 const HttpResponseInfo* response = trans->GetResponseInfo(); 4073 const HttpResponseInfo* response = trans->GetResponseInfo();
4071 EXPECT_TRUE(response->headers != NULL); 4074 EXPECT_TRUE(response->headers != NULL);
4072 EXPECT_TRUE(response->was_fetched_via_spdy); 4075 EXPECT_TRUE(response->was_fetched_via_spdy);
4073 out.status_line = response->headers->GetStatusLine(); 4076 out.status_line = response->headers->GetStatusLine();
4074 out.response_info = *response; // Make a copy so we can verify. 4077 out.response_info = *response; // Make a copy so we can verify.
4075 4078
4076 // Read Data 4079 // Read Data
4077 TestOldCompletionCallback read_callback; 4080 TestCompletionCallback read_callback;
4078 4081
4079 std::string content; 4082 std::string content;
4080 int reads_completed = 0; 4083 int reads_completed = 0;
4081 do { 4084 do {
4082 // Read small chunks at a time. 4085 // Read small chunks at a time.
4083 const int kSmallReadSize = 14; 4086 const int kSmallReadSize = 14;
4084 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize)); 4087 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
4085 rv = trans->Read(buf, kSmallReadSize, &read_callback); 4088 rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
4086 if (rv == net::ERR_IO_PENDING) { 4089 if (rv == net::ERR_IO_PENDING) {
4087 data->CompleteRead(); 4090 data->CompleteRead();
4088 rv = read_callback.WaitForResult(); 4091 rv = read_callback.WaitForResult();
4089 } 4092 }
4090 if (rv > 0) { 4093 if (rv > 0) {
4091 content.append(buf->data(), rv); 4094 content.append(buf->data(), rv);
4092 } else if (rv < 0) { 4095 } else if (rv < 0) {
4093 // This test intentionally closes the connection, and will get an error. 4096 // This test intentionally closes the connection, and will get an error.
4094 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); 4097 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv);
4095 break; 4098 break;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4130 4133
4131 scoped_refptr<DelayedSocketData> data( 4134 scoped_refptr<DelayedSocketData> data(
4132 new DelayedSocketData(1, reads, arraysize(reads), 4135 new DelayedSocketData(1, reads, arraysize(reads),
4133 writes, arraysize(writes))); 4136 writes, arraysize(writes)));
4134 4137
4135 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4138 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4136 BoundNetLog(), GetParam()); 4139 BoundNetLog(), GetParam());
4137 helper.RunPreTestSetup(); 4140 helper.RunPreTestSetup();
4138 helper.AddData(data.get()); 4141 helper.AddData(data.get());
4139 HttpNetworkTransaction* trans = helper.trans(); 4142 HttpNetworkTransaction* trans = helper.trans();
4140 TestOldCompletionCallback callback; 4143 TestCompletionCallback callback;
4141 4144
4142 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 4145 int rv = trans->Start(
4146 &CreateGetRequest(), callback.callback(), BoundNetLog());
4143 EXPECT_EQ(ERR_IO_PENDING, rv); 4147 EXPECT_EQ(ERR_IO_PENDING, rv);
4144 4148
4145 TransactionHelperResult out = helper.output(); 4149 TransactionHelperResult out = helper.output();
4146 out.rv = callback.WaitForResult(); 4150 out.rv = callback.WaitForResult();
4147 EXPECT_EQ(out.rv, OK); 4151 EXPECT_EQ(out.rv, OK);
4148 4152
4149 const HttpResponseInfo* response = trans->GetResponseInfo(); 4153 const HttpResponseInfo* response = trans->GetResponseInfo();
4150 EXPECT_TRUE(response->headers != NULL); 4154 EXPECT_TRUE(response->headers != NULL);
4151 EXPECT_TRUE(response->was_fetched_via_spdy); 4155 EXPECT_TRUE(response->was_fetched_via_spdy);
4152 out.status_line = response->headers->GetStatusLine(); 4156 out.status_line = response->headers->GetStatusLine();
4153 out.response_info = *response; // Make a copy so we can verify. 4157 out.response_info = *response; // Make a copy so we can verify.
4154 4158
4155 // Read Data 4159 // Read Data
4156 TestOldCompletionCallback read_callback; 4160 TestCompletionCallback read_callback;
4157 4161
4158 do { 4162 do {
4159 const int kReadSize = 256; 4163 const int kReadSize = 256;
4160 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kReadSize)); 4164 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kReadSize));
4161 rv = trans->Read(buf, kReadSize, &read_callback); 4165 rv = trans->Read(buf, kReadSize, read_callback.callback());
4162 if (rv == net::ERR_IO_PENDING) { 4166 if (rv == net::ERR_IO_PENDING) {
4163 // Complete the read now, which causes buffering to start. 4167 // Complete the read now, which causes buffering to start.
4164 data->CompleteRead(); 4168 data->CompleteRead();
4165 // Destroy the transaction, causing the stream to get cancelled 4169 // Destroy the transaction, causing the stream to get cancelled
4166 // and orphaning the buffered IO task. 4170 // and orphaning the buffered IO task.
4167 helper.ResetTrans(); 4171 helper.ResetTrans();
4168 break; 4172 break;
4169 } 4173 }
4170 // We shouldn't get here in this test. 4174 // We shouldn't get here in this test.
4171 FAIL() << "Unexpected read: " << rv; 4175 FAIL() << "Unexpected read: " << rv;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
4442 scoped_refptr<DelayedSocketData> data( 4446 scoped_refptr<DelayedSocketData> data(
4443 new DelayedSocketData(1, reads, arraysize(reads), 4447 new DelayedSocketData(1, reads, arraysize(reads),
4444 writes, arraysize(writes))); 4448 writes, arraysize(writes)));
4445 BoundNetLog log; 4449 BoundNetLog log;
4446 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4450 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4447 log, GetParam()); 4451 log, GetParam());
4448 helper.RunPreTestSetup(); 4452 helper.RunPreTestSetup();
4449 helper.AddData(data.get()); 4453 helper.AddData(data.get());
4450 HttpNetworkTransaction* trans = helper.trans(); 4454 HttpNetworkTransaction* trans = helper.trans();
4451 4455
4452 TestOldCompletionCallback callback; 4456 TestCompletionCallback callback;
4453 TransactionHelperResult out; 4457 TransactionHelperResult out;
4454 out.rv = trans->Start(&CreateGetRequest(), &callback, log); 4458 out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log);
4455 4459
4456 EXPECT_EQ(out.rv, ERR_IO_PENDING); 4460 EXPECT_EQ(out.rv, ERR_IO_PENDING);
4457 out.rv = callback.WaitForResult(); 4461 out.rv = callback.WaitForResult();
4458 EXPECT_EQ(out.rv, OK); 4462 EXPECT_EQ(out.rv, OK);
4459 4463
4460 const HttpResponseInfo* response = trans->GetResponseInfo(); 4464 const HttpResponseInfo* response = trans->GetResponseInfo();
4461 EXPECT_TRUE(response->headers != NULL); 4465 EXPECT_TRUE(response->headers != NULL);
4462 EXPECT_TRUE(response->was_fetched_via_spdy); 4466 EXPECT_TRUE(response->was_fetched_via_spdy);
4463 out.rv = ReadTransaction(trans, &out.response_data); 4467 out.rv = ReadTransaction(trans, &out.response_data);
4464 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); 4468 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4535 break; 4539 break;
4536 case SPDYNPN: 4540 case SPDYNPN:
4537 data = new OrderedSocketData(reads_SPDYNPN, arraysize(reads_SPDYNPN), 4541 data = new OrderedSocketData(reads_SPDYNPN, arraysize(reads_SPDYNPN),
4538 writes_SPDYNPN, arraysize(writes_SPDYNPN)); 4542 writes_SPDYNPN, arraysize(writes_SPDYNPN));
4539 break; 4543 break;
4540 default: 4544 default:
4541 NOTREACHED(); 4545 NOTREACHED();
4542 } 4546 }
4543 4547
4544 helper.AddData(data.get()); 4548 helper.AddData(data.get());
4545 TestOldCompletionCallback callback; 4549 TestCompletionCallback callback;
4546 4550
4547 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 4551 int rv = trans->Start(
4552 &CreateGetRequest(), callback.callback(), BoundNetLog());
4548 EXPECT_EQ(ERR_IO_PENDING, rv); 4553 EXPECT_EQ(ERR_IO_PENDING, rv);
4549 4554
4550 rv = callback.WaitForResult(); 4555 rv = callback.WaitForResult();
4551 EXPECT_EQ(0, rv); 4556 EXPECT_EQ(0, rv);
4552 4557
4553 // Verify the SYN_REPLY. 4558 // Verify the SYN_REPLY.
4554 HttpResponseInfo response = *trans->GetResponseInfo(); 4559 HttpResponseInfo response = *trans->GetResponseInfo();
4555 EXPECT_TRUE(response.headers != NULL); 4560 EXPECT_TRUE(response.headers != NULL);
4556 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 4561 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
4557 4562
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4595 CreateMockRead(*body, 3), 4600 CreateMockRead(*body, 3),
4596 MockRead(true, ERR_IO_PENDING, 4), // Force a pause 4601 MockRead(true, ERR_IO_PENDING, 4), // Force a pause
4597 MockRead(true, 0, 5) // EOF 4602 MockRead(true, 0, 5) // EOF
4598 }; 4603 };
4599 scoped_refptr<OrderedSocketData> data( 4604 scoped_refptr<OrderedSocketData> data(
4600 new OrderedSocketData(reads, arraysize(reads), 4605 new OrderedSocketData(reads, arraysize(reads),
4601 writes, arraysize(writes))); 4606 writes, arraysize(writes)));
4602 helper.AddData(data.get()); 4607 helper.AddData(data.get());
4603 HttpNetworkTransaction* trans = helper.trans(); 4608 HttpNetworkTransaction* trans = helper.trans();
4604 4609
4605 TestOldCompletionCallback callback; 4610 TestCompletionCallback callback;
4606 TransactionHelperResult out; 4611 TransactionHelperResult out;
4607 out.rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 4612 out.rv = trans->Start(
4613 &CreateGetRequest(), callback.callback(), BoundNetLog());
4608 4614
4609 EXPECT_EQ(out.rv, ERR_IO_PENDING); 4615 EXPECT_EQ(out.rv, ERR_IO_PENDING);
4610 out.rv = callback.WaitForResult(); 4616 out.rv = callback.WaitForResult();
4611 EXPECT_EQ(out.rv, OK); 4617 EXPECT_EQ(out.rv, OK);
4612 4618
4613 const HttpResponseInfo* response = trans->GetResponseInfo(); 4619 const HttpResponseInfo* response = trans->GetResponseInfo();
4614 EXPECT_TRUE(response->headers != NULL); 4620 EXPECT_TRUE(response->headers != NULL);
4615 EXPECT_TRUE(response->was_fetched_via_spdy); 4621 EXPECT_TRUE(response->was_fetched_via_spdy);
4616 out.rv = ReadTransaction(trans, &out.response_data); 4622 out.rv = ReadTransaction(trans, &out.response_data);
4617 EXPECT_EQ(OK, out.rv); 4623 EXPECT_EQ(OK, out.rv);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4711 HttpNetworkSessionPeer session_peer(session_proxy); 4717 HttpNetworkSessionPeer session_peer(session_proxy);
4712 scoped_ptr<net::ProxyService> proxy_service( 4718 scoped_ptr<net::ProxyService> proxy_service(
4713 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 4719 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
4714 session_peer.SetProxyService(proxy_service.get()); 4720 session_peer.SetProxyService(proxy_service.get());
4715 helper_proxy.session_deps().swap(ssd_proxy); 4721 helper_proxy.session_deps().swap(ssd_proxy);
4716 helper_proxy.SetSession(session_proxy); 4722 helper_proxy.SetSession(session_proxy);
4717 helper_proxy.RunPreTestSetup(); 4723 helper_proxy.RunPreTestSetup();
4718 helper_proxy.AddData(data_proxy.get()); 4724 helper_proxy.AddData(data_proxy.get());
4719 4725
4720 HttpNetworkTransaction* trans_proxy = helper_proxy.trans(); 4726 HttpNetworkTransaction* trans_proxy = helper_proxy.trans();
4721 TestOldCompletionCallback callback_proxy; 4727 TestCompletionCallback callback_proxy;
4722 int rv = trans_proxy->Start(&request_proxy, &callback_proxy, BoundNetLog()); 4728 int rv = trans_proxy->Start(
4729 &request_proxy, callback_proxy.callback(), BoundNetLog());
4723 EXPECT_EQ(ERR_IO_PENDING, rv); 4730 EXPECT_EQ(ERR_IO_PENDING, rv);
4724 rv = callback_proxy.WaitForResult(); 4731 rv = callback_proxy.WaitForResult();
4725 EXPECT_EQ(0, rv); 4732 EXPECT_EQ(0, rv);
4726 4733
4727 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo(); 4734 HttpResponseInfo response_proxy = *trans_proxy->GetResponseInfo();
4728 EXPECT_TRUE(response_proxy.headers != NULL); 4735 EXPECT_TRUE(response_proxy.headers != NULL);
4729 EXPECT_EQ("HTTP/1.1 200 OK", response_proxy.headers->GetStatusLine()); 4736 EXPECT_EQ("HTTP/1.1 200 OK", response_proxy.headers->GetStatusLine());
4730 4737
4731 std::string response_data; 4738 std::string response_data;
4732 ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data)); 4739 ASSERT_EQ(OK, ReadTransaction(trans_proxy, &response_data));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4779 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4786 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4780 BoundNetLog(), GetParam()); 4787 BoundNetLog(), GetParam());
4781 helper.AddData(data1.get()); 4788 helper.AddData(data1.get());
4782 helper.AddData(data2.get()); 4789 helper.AddData(data2.get());
4783 helper.RunPreTestSetup(); 4790 helper.RunPreTestSetup();
4784 4791
4785 for (int i = 0; i < 2; ++i) { 4792 for (int i = 0; i < 2; ++i) {
4786 scoped_ptr<HttpNetworkTransaction> trans( 4793 scoped_ptr<HttpNetworkTransaction> trans(
4787 new HttpNetworkTransaction(helper.session())); 4794 new HttpNetworkTransaction(helper.session()));
4788 4795
4789 TestOldCompletionCallback callback; 4796 TestCompletionCallback callback;
4790 int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); 4797 int rv = trans->Start(
4798 &helper.request(), callback.callback(), BoundNetLog());
4791 EXPECT_EQ(ERR_IO_PENDING, rv); 4799 EXPECT_EQ(ERR_IO_PENDING, rv);
4792 // On the second transaction, we trigger the RST. 4800 // On the second transaction, we trigger the RST.
4793 if (i == 1) { 4801 if (i == 1) {
4794 if (variant == VARIANT_RST_DURING_READ_COMPLETION) { 4802 if (variant == VARIANT_RST_DURING_READ_COMPLETION) {
4795 // Writes to the socket complete asynchronously on SPDY by running 4803 // Writes to the socket complete asynchronously on SPDY by running
4796 // through the message loop. Complete the write here. 4804 // through the message loop. Complete the write here.
4797 MessageLoop::current()->RunAllPending(); 4805 MessageLoop::current()->RunAllPending();
4798 } 4806 }
4799 4807
4800 // Now schedule the ERR_CONNECTION_RESET. 4808 // Now schedule the ERR_CONNECTION_RESET.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4917 scoped_refptr<OrderedSocketData> data( 4925 scoped_refptr<OrderedSocketData> data(
4918 new OrderedSocketData(spdy_reads, arraysize(spdy_reads), 4926 new OrderedSocketData(spdy_reads, arraysize(spdy_reads),
4919 spdy_writes, arraysize(spdy_writes))); 4927 spdy_writes, arraysize(spdy_writes)));
4920 HttpRequestInfo request(CreateGetRequest()); 4928 HttpRequestInfo request(CreateGetRequest());
4921 BoundNetLog net_log; 4929 BoundNetLog net_log;
4922 NormalSpdyTransactionHelper helper(request, net_log, GetParam()); 4930 NormalSpdyTransactionHelper helper(request, net_log, GetParam());
4923 4931
4924 helper.RunPreTestSetup(); 4932 helper.RunPreTestSetup();
4925 helper.AddData(data.get()); 4933 helper.AddData(data.get());
4926 HttpNetworkTransaction* trans = helper.trans(); 4934 HttpNetworkTransaction* trans = helper.trans();
4927 TestOldCompletionCallback callback_start; 4935 TestCompletionCallback callback;
4928 const int rv_start = trans->Start(&request, &callback_start, net_log); 4936 const int rv_start = trans->Start(&request, callback.callback(), net_log);
4929 EXPECT_EQ(ERR_IO_PENDING, rv_start); 4937 EXPECT_EQ(ERR_IO_PENDING, rv_start);
4930 const int rv_start_complete = callback_start.WaitForResult(); 4938 const int rv_start_complete = callback.WaitForResult();
4931 EXPECT_EQ(OK, rv_start_complete); 4939 EXPECT_EQ(OK, rv_start_complete);
4932 4940
4933 // Make sure the response has an auth challenge. 4941 // Make sure the response has an auth challenge.
4934 const HttpResponseInfo* const response_start = trans->GetResponseInfo(); 4942 const HttpResponseInfo* const response_start = trans->GetResponseInfo();
4935 ASSERT_TRUE(response_start != NULL); 4943 ASSERT_TRUE(response_start != NULL);
4936 ASSERT_TRUE(response_start->headers != NULL); 4944 ASSERT_TRUE(response_start->headers != NULL);
4937 EXPECT_EQ(401, response_start->headers->response_code()); 4945 EXPECT_EQ(401, response_start->headers->response_code());
4938 EXPECT_TRUE(response_start->was_fetched_via_spdy); 4946 EXPECT_TRUE(response_start->was_fetched_via_spdy);
4939 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get(); 4947 AuthChallengeInfo* auth_challenge = response_start->auth_challenge.get();
4940 ASSERT_TRUE(auth_challenge != NULL); 4948 ASSERT_TRUE(auth_challenge != NULL);
4941 EXPECT_FALSE(auth_challenge->is_proxy); 4949 EXPECT_FALSE(auth_challenge->is_proxy);
4942 EXPECT_EQ("basic", auth_challenge->scheme); 4950 EXPECT_EQ("basic", auth_challenge->scheme);
4943 EXPECT_EQ("MyRealm", auth_challenge->realm); 4951 EXPECT_EQ("MyRealm", auth_challenge->realm);
4944 4952
4945 // Restart with a username/password. 4953 // Restart with a username/password.
4946 AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar")); 4954 AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar"));
4947 TestOldCompletionCallback callback_restart; 4955 TestCompletionCallback callback_restart;
4948 const int rv_restart = trans->RestartWithAuth(credentials, &callback_restart); 4956 const int rv_restart = trans->RestartWithAuth(
4957 credentials, callback_restart.callback());
4949 EXPECT_EQ(ERR_IO_PENDING, rv_restart); 4958 EXPECT_EQ(ERR_IO_PENDING, rv_restart);
4950 const int rv_restart_complete = callback_restart.WaitForResult(); 4959 const int rv_restart_complete = callback_restart.WaitForResult();
4951 EXPECT_EQ(OK, rv_restart_complete); 4960 EXPECT_EQ(OK, rv_restart_complete);
4952 // TODO(cbentzel): This is actually the same response object as before, but 4961 // TODO(cbentzel): This is actually the same response object as before, but
4953 // data has changed. 4962 // data has changed.
4954 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); 4963 const HttpResponseInfo* const response_restart = trans->GetResponseInfo();
4955 ASSERT_TRUE(response_restart != NULL); 4964 ASSERT_TRUE(response_restart != NULL);
4956 ASSERT_TRUE(response_restart->headers != NULL); 4965 ASSERT_TRUE(response_restart->headers != NULL);
4957 EXPECT_EQ(200, response_restart->headers->response_code()); 4966 EXPECT_EQ(200, response_restart->headers->response_code());
4958 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL); 4967 EXPECT_TRUE(response_restart->auth_challenge.get() == NULL);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
5119 helper.RunPreTestSetup(); 5128 helper.RunPreTestSetup();
5120 5129
5121 HttpNetworkTransaction* trans = helper.trans(); 5130 HttpNetworkTransaction* trans = helper.trans();
5122 5131
5123 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, 5132 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM,
5124 // and the body of the primary stream, but before we've received the HEADERS 5133 // and the body of the primary stream, but before we've received the HEADERS
5125 // for the pushed stream. 5134 // for the pushed stream.
5126 data->SetStop(3); 5135 data->SetStop(3);
5127 5136
5128 // Start the transaction. 5137 // Start the transaction.
5129 TestOldCompletionCallback callback; 5138 TestCompletionCallback callback;
5130 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 5139 int rv = trans->Start(
5140 &CreateGetRequest(), callback.callback(), BoundNetLog());
5131 EXPECT_EQ(ERR_IO_PENDING, rv); 5141 EXPECT_EQ(ERR_IO_PENDING, rv);
5132 data->Run(); 5142 data->Run();
5133 rv = callback.WaitForResult(); 5143 rv = callback.WaitForResult();
5134 EXPECT_EQ(0, rv); 5144 EXPECT_EQ(0, rv);
5135 5145
5136 // Request the pushed path. At this point, we've received the push, but the 5146 // Request the pushed path. At this point, we've received the push, but the
5137 // headers are not yet complete. 5147 // headers are not yet complete.
5138 scoped_ptr<HttpNetworkTransaction> trans2( 5148 scoped_ptr<HttpNetworkTransaction> trans2(
5139 new HttpNetworkTransaction(helper.session())); 5149 new HttpNetworkTransaction(helper.session()));
5140 rv = trans2->Start(&CreateGetPushRequest(), &callback, BoundNetLog()); 5150 rv = trans2->Start(
5151 &CreateGetPushRequest(), callback.callback(), BoundNetLog());
5141 EXPECT_EQ(ERR_IO_PENDING, rv); 5152 EXPECT_EQ(ERR_IO_PENDING, rv);
5142 data->RunFor(3); 5153 data->RunFor(3);
5143 MessageLoop::current()->RunAllPending(); 5154 MessageLoop::current()->RunAllPending();
5144 5155
5145 // Read the server push body. 5156 // Read the server push body.
5146 std::string result2; 5157 std::string result2;
5147 ReadResult(trans2.get(), data.get(), &result2); 5158 ReadResult(trans2.get(), data.get(), &result2);
5148 // Read the response body. 5159 // Read the response body.
5149 std::string result; 5160 std::string result;
5150 ReadResult(trans, data, &result); 5161 ReadResult(trans, data, &result);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
5268 helper.RunPreTestSetup(); 5279 helper.RunPreTestSetup();
5269 5280
5270 HttpNetworkTransaction* trans = helper.trans(); 5281 HttpNetworkTransaction* trans = helper.trans();
5271 5282
5272 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, 5283 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM,
5273 // the first HEADERS frame, and the body of the primary stream, but before 5284 // the first HEADERS frame, and the body of the primary stream, but before
5274 // we've received the final HEADERS for the pushed stream. 5285 // we've received the final HEADERS for the pushed stream.
5275 data->SetStop(4); 5286 data->SetStop(4);
5276 5287
5277 // Start the transaction. 5288 // Start the transaction.
5278 TestOldCompletionCallback callback; 5289 TestCompletionCallback callback;
5279 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 5290 int rv = trans->Start(
5291 &CreateGetRequest(), callback.callback(), BoundNetLog());
5280 EXPECT_EQ(ERR_IO_PENDING, rv); 5292 EXPECT_EQ(ERR_IO_PENDING, rv);
5281 data->Run(); 5293 data->Run();
5282 rv = callback.WaitForResult(); 5294 rv = callback.WaitForResult();
5283 EXPECT_EQ(0, rv); 5295 EXPECT_EQ(0, rv);
5284 5296
5285 // Request the pushed path. At this point, we've received the push, but the 5297 // Request the pushed path. At this point, we've received the push, but the
5286 // headers are not yet complete. 5298 // headers are not yet complete.
5287 scoped_ptr<HttpNetworkTransaction> trans2( 5299 scoped_ptr<HttpNetworkTransaction> trans2(
5288 new HttpNetworkTransaction(helper.session())); 5300 new HttpNetworkTransaction(helper.session()));
5289 rv = trans2->Start(&CreateGetPushRequest(), &callback, BoundNetLog()); 5301 rv = trans2->Start(
5302 &CreateGetPushRequest(), callback.callback(), BoundNetLog());
5290 EXPECT_EQ(ERR_IO_PENDING, rv); 5303 EXPECT_EQ(ERR_IO_PENDING, rv);
5291 data->RunFor(3); 5304 data->RunFor(3);
5292 MessageLoop::current()->RunAllPending(); 5305 MessageLoop::current()->RunAllPending();
5293 5306
5294 // Read the server push body. 5307 // Read the server push body.
5295 std::string result2; 5308 std::string result2;
5296 ReadResult(trans2.get(), data, &result2); 5309 ReadResult(trans2.get(), data, &result2);
5297 // Read the response body. 5310 // Read the response body.
5298 std::string result; 5311 std::string result;
5299 ReadResult(trans, data, &result); 5312 ReadResult(trans, data, &result);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
5582 request.url = GURL(url_to_fetch); 5595 request.url = GURL(url_to_fetch);
5583 request.load_flags = 0; 5596 request.load_flags = 0;
5584 NormalSpdyTransactionHelper helper(request, 5597 NormalSpdyTransactionHelper helper(request,
5585 BoundNetLog(), GetParam()); 5598 BoundNetLog(), GetParam());
5586 helper.RunPreTestSetup(); 5599 helper.RunPreTestSetup();
5587 helper.AddData(data); 5600 helper.AddData(data);
5588 5601
5589 HttpNetworkTransaction* trans = helper.trans(); 5602 HttpNetworkTransaction* trans = helper.trans();
5590 5603
5591 // Start the transaction with basic parameters. 5604 // Start the transaction with basic parameters.
5592 TestOldCompletionCallback callback; 5605 TestCompletionCallback callback;
5593 5606
5594 int rv = trans->Start(&request, &callback, BoundNetLog()); 5607 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5595 EXPECT_EQ(ERR_IO_PENDING, rv); 5608 EXPECT_EQ(ERR_IO_PENDING, rv);
5596 rv = callback.WaitForResult(); 5609 rv = callback.WaitForResult();
5597 5610
5598 // Read the response body. 5611 // Read the response body.
5599 std::string result; 5612 std::string result;
5600 ReadResult(trans, data, &result); 5613 ReadResult(trans, data, &result);
5601 5614
5602 // Verify that we consumed all test data. 5615 // Verify that we consumed all test data.
5603 EXPECT_TRUE(data->at_read_eof()); 5616 EXPECT_TRUE(data->at_read_eof());
5604 EXPECT_TRUE(data->at_write_eof()); 5617 EXPECT_TRUE(data->at_write_eof());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5640 writes, arraysize(writes))); 5653 writes, arraysize(writes)));
5641 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5654 NormalSpdyTransactionHelper helper(CreateGetRequest(),
5642 BoundNetLog(), GetParam()); 5655 BoundNetLog(), GetParam());
5643 5656
5644 helper.RunPreTestSetup(); 5657 helper.RunPreTestSetup();
5645 helper.AddData(data.get()); 5658 helper.AddData(data.get());
5646 5659
5647 HttpNetworkTransaction* trans = helper.trans(); 5660 HttpNetworkTransaction* trans = helper.trans();
5648 5661
5649 // Start the transaction with basic parameters. 5662 // Start the transaction with basic parameters.
5650 TestOldCompletionCallback callback; 5663 TestCompletionCallback callback;
5651 int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog()); 5664 int rv = trans->Start(
5665 &CreateGetRequest(), callback.callback(), BoundNetLog());
5652 EXPECT_EQ(ERR_IO_PENDING, rv); 5666 EXPECT_EQ(ERR_IO_PENDING, rv);
5653 rv = callback.WaitForResult(); 5667 rv = callback.WaitForResult();
5654 EXPECT_EQ(OK, rv); 5668 EXPECT_EQ(OK, rv);
5655 5669
5656 // Verify that we consumed all test data. 5670 // Verify that we consumed all test data.
5657 EXPECT_TRUE(data->at_read_eof()) << "Read count: " 5671 EXPECT_TRUE(data->at_read_eof()) << "Read count: "
5658 << data->read_count() 5672 << data->read_count()
5659 << " Read index: " 5673 << " Read index: "
5660 << data->read_index(); 5674 << data->read_index();
5661 EXPECT_TRUE(data->at_write_eof()) << "Write count: " 5675 EXPECT_TRUE(data->at_write_eof()) << "Write count: "
5662 << data->write_count() 5676 << data->write_count()
5663 << " Write index: " 5677 << " Write index: "
5664 << data->write_index(); 5678 << data->write_index();
5665 5679
5666 // Verify the SYN_REPLY. 5680 // Verify the SYN_REPLY.
5667 HttpResponseInfo response = *trans->GetResponseInfo(); 5681 HttpResponseInfo response = *trans->GetResponseInfo();
5668 EXPECT_TRUE(response.headers != NULL); 5682 EXPECT_TRUE(response.headers != NULL);
5669 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5683 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5670 } 5684 }
5671 5685
5672 } // namespace net 5686 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698