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

Side by Side Diff: net/http/http_pipelined_network_transaction_unittest.cc

Issue 10690104: DeterministicSocketDataProvider should not be RefCounted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 ExpectResponse("three.html", three_transaction, SYNCHRONOUS); 220 ExpectResponse("three.html", three_transaction, SYNCHRONOUS);
221 221
222 one_transaction.reset(); 222 one_transaction.reset();
223 EXPECT_EQ(OK, four_callback.WaitForResult()); 223 EXPECT_EQ(OK, four_callback.WaitForResult());
224 ExpectResponse("four.html", four_transaction, SYNCHRONOUS); 224 ExpectResponse("four.html", four_transaction, SYNCHRONOUS);
225 } 225 }
226 226
227 DeterministicMockClientSocketFactory factory_; 227 DeterministicMockClientSocketFactory factory_;
228 ClientSocketPoolHistograms histograms_; 228 ClientSocketPoolHistograms histograms_;
229 MockTransportClientSocketPool pool_; 229 MockTransportClientSocketPool pool_;
230 std::vector<scoped_refptr<DeterministicSocketData> > data_vector_; 230 ScopedVector<DeterministicSocketData> data_vector_;
231 TestCompletionCallback callback_; 231 TestCompletionCallback callback_;
232 ScopedVector<HttpRequestInfo> request_info_vector_; 232 ScopedVector<HttpRequestInfo> request_info_vector_;
233 bool default_pipelining_enabled_; 233 bool default_pipelining_enabled_;
234 234
235 SimpleProxyConfigService* proxy_config_service_; 235 SimpleProxyConfigService* proxy_config_service_;
236 scoped_ptr<ProxyService> proxy_service_; 236 scoped_ptr<ProxyService> proxy_service_;
237 MockHostResolver mock_resolver_; 237 MockHostResolver mock_resolver_;
238 scoped_refptr<SSLConfigService> ssl_config_; 238 scoped_refptr<SSLConfigService> ssl_config_;
239 scoped_ptr<HttpAuthHandlerMock::Factory> auth_handler_factory_; 239 scoped_ptr<HttpAuthHandlerMock::Factory> auth_handler_factory_;
240 HttpServerPropertiesImpl http_server_properties_; 240 HttpServerPropertiesImpl http_server_properties_;
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 two_transaction.Start(GetRequestInfo("two.html"), 825 two_transaction.Start(GetRequestInfo("two.html"),
826 two_callback.callback(), BoundNetLog())); 826 two_callback.callback(), BoundNetLog()));
827 // Posted tasks should be: 827 // Posted tasks should be:
828 // 1. MockHostResolverBase::ResolveNow 828 // 1. MockHostResolverBase::ResolveNow
829 // 2. HttpStreamFactoryImpl::Job::OnStreamReadyCallback for job 1 829 // 2. HttpStreamFactoryImpl::Job::OnStreamReadyCallback for job 1
830 // 3. HttpStreamFactoryImpl::Job::OnStreamReadyCallback for job 2 830 // 3. HttpStreamFactoryImpl::Job::OnStreamReadyCallback for job 2
831 // 831 //
832 // We need to make sure that the response that triggers OnPipelineFeedback(OK) 832 // We need to make sure that the response that triggers OnPipelineFeedback(OK)
833 // is called in between when task #3 is scheduled and when it runs. The 833 // is called in between when task #3 is scheduled and when it runs. The
834 // DataRunnerObserver does that. 834 // DataRunnerObserver does that.
835 DataRunnerObserver observer(data_vector_[0].get(), 3); 835 DataRunnerObserver observer(data_vector_[0], 3);
836 MessageLoop::current()->AddTaskObserver(&observer); 836 MessageLoop::current()->AddTaskObserver(&observer);
837 data_vector_[0]->SetStop(4); 837 data_vector_[0]->SetStop(4);
838 MessageLoop::current()->RunAllPending(); 838 MessageLoop::current()->RunAllPending();
839 data_vector_[0]->SetStop(10); 839 data_vector_[0]->SetStop(10);
840 840
841 EXPECT_EQ(OK, one_callback.WaitForResult()); 841 EXPECT_EQ(OK, one_callback.WaitForResult());
842 ExpectResponse("one.html", one_transaction, SYNCHRONOUS); 842 ExpectResponse("one.html", one_transaction, SYNCHRONOUS);
843 EXPECT_EQ(OK, two_callback.WaitForResult()); 843 EXPECT_EQ(OK, two_callback.WaitForResult());
844 ExpectResponse("two.html", two_transaction, SYNCHRONOUS); 844 ExpectResponse("two.html", two_transaction, SYNCHRONOUS);
845 } 845 }
846 846
847 TEST_F(HttpPipelinedNetworkTransactionTest, ProxyChangesWhileConnecting) { 847 TEST_F(HttpPipelinedNetworkTransactionTest, ProxyChangesWhileConnecting) {
848 Initialize(false); 848 Initialize(false);
849 849
850 scoped_refptr<DeterministicSocketData> data( 850 DeterministicSocketData* data =
Ryan Hamilton 2012/07/09 17:35:47 Is this a memory leak? (Or does AddSocketDataProv
851 new DeterministicSocketData(NULL, 0, NULL, 0)); 851 new DeterministicSocketData(NULL, 0, NULL, 0);
852 data->set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED)); 852 data->set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_REFUSED));
853 factory_.AddSocketDataProvider(data); 853 factory_.AddSocketDataProvider(data);
854 854
855 scoped_refptr<DeterministicSocketData> data2( 855 DeterministicSocketData* data2 =
856 new DeterministicSocketData(NULL, 0, NULL, 0)); 856 new DeterministicSocketData(NULL, 0, NULL, 0);
857 data2->set_connect_data(MockConnect(ASYNC, ERR_FAILED)); 857 data2->set_connect_data(MockConnect(ASYNC, ERR_FAILED));
858 factory_.AddSocketDataProvider(data2); 858 factory_.AddSocketDataProvider(data2);
859 859
860 HttpNetworkTransaction transaction(session_.get()); 860 HttpNetworkTransaction transaction(session_.get());
861 EXPECT_EQ(ERR_IO_PENDING, 861 EXPECT_EQ(ERR_IO_PENDING,
862 transaction.Start(GetRequestInfo("test.html"), callback_.callback(), 862 transaction.Start(GetRequestInfo("test.html"), callback_.callback(),
863 BoundNetLog())); 863 BoundNetLog()));
864 864
865 proxy_config_service_->IncrementConfigId(); 865 proxy_config_service_->IncrementConfigId();
866 866
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 908
909 data_vector_[0]->RunFor(2); // 2 lines of headers. 909 data_vector_[0]->RunFor(2); // 2 lines of headers.
910 EXPECT_EQ(OK, two_callback.WaitForResult()); 910 EXPECT_EQ(OK, two_callback.WaitForResult());
911 ExpectResponse("two.html", two_transaction, ASYNC); 911 ExpectResponse("two.html", two_transaction, ASYNC);
912 } 912 }
913 913
914 TEST_F(HttpPipelinedNetworkTransactionTest, 914 TEST_F(HttpPipelinedNetworkTransactionTest,
915 ForcedPipelineConnectionErrorFailsBoth) { 915 ForcedPipelineConnectionErrorFailsBoth) {
916 Initialize(true); 916 Initialize(true);
917 917
918 scoped_refptr<DeterministicSocketData> data( 918 DeterministicSocketData* data =
919 new DeterministicSocketData(NULL, 0, NULL, 0)); 919 new DeterministicSocketData(NULL, 0, NULL, 0);
920 data->set_connect_data(MockConnect(ASYNC, ERR_FAILED)); 920 data->set_connect_data(MockConnect(ASYNC, ERR_FAILED));
921 factory_.AddSocketDataProvider(data); 921 factory_.AddSocketDataProvider(data);
922 922
923 scoped_ptr<HttpNetworkTransaction> one_transaction( 923 scoped_ptr<HttpNetworkTransaction> one_transaction(
924 new HttpNetworkTransaction(session_.get())); 924 new HttpNetworkTransaction(session_.get()));
925 TestCompletionCallback one_callback; 925 TestCompletionCallback one_callback;
926 EXPECT_EQ(ERR_IO_PENDING, 926 EXPECT_EQ(ERR_IO_PENDING,
927 one_transaction->Start(GetRequestInfo("one.html"), 927 one_transaction->Start(GetRequestInfo("one.html"),
928 one_callback.callback(), BoundNetLog())); 928 one_callback.callback(), BoundNetLog()));
929 929
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 "Host: localhost\r\n" 988 "Host: localhost\r\n"
989 "Connection: keep-alive\r\n\r\n" 989 "Connection: keep-alive\r\n\r\n"
990 "GET /four.html HTTP/1.1\r\n" 990 "GET /four.html HTTP/1.1\r\n"
991 "Host: localhost\r\n" 991 "Host: localhost\r\n"
992 "Connection: keep-alive\r\n\r\n" 992 "Connection: keep-alive\r\n\r\n"
993 ), 993 ),
994 }; 994 };
995 MockRead reads[] = { 995 MockRead reads[] = {
996 MockRead(ASYNC, ERR_FAILED, 1), 996 MockRead(ASYNC, ERR_FAILED, 1),
997 }; 997 };
998 scoped_refptr<DeterministicSocketData> data(new DeterministicSocketData( 998 DeterministicSocketData* data = new DeterministicSocketData(
999 reads, arraysize(reads), writes, arraysize(writes))); 999 reads, arraysize(reads), writes, arraysize(writes));
1000 data->set_connect_data(MockConnect(ASYNC, OK)); 1000 data->set_connect_data(MockConnect(ASYNC, OK));
1001 factory_.AddSocketDataProvider(data); 1001 factory_.AddSocketDataProvider(data);
1002 1002
1003 scoped_ptr<HttpNetworkTransaction> one_transaction( 1003 scoped_ptr<HttpNetworkTransaction> one_transaction(
1004 new HttpNetworkTransaction(session_.get())); 1004 new HttpNetworkTransaction(session_.get()));
1005 TestCompletionCallback one_callback; 1005 TestCompletionCallback one_callback;
1006 EXPECT_EQ(ERR_IO_PENDING, 1006 EXPECT_EQ(ERR_IO_PENDING,
1007 one_transaction->Start(GetRequestInfo("one.html"), 1007 one_transaction->Start(GetRequestInfo("one.html"),
1008 one_callback.callback(), BoundNetLog())); 1008 one_callback.callback(), BoundNetLog()));
1009 1009
(...skipping 24 matching lines...) Expand all
1034 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult()); 1034 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult());
1035 two_transaction.reset(); 1035 two_transaction.reset();
1036 EXPECT_EQ(ERR_PIPELINE_EVICTION, three_callback.WaitForResult()); 1036 EXPECT_EQ(ERR_PIPELINE_EVICTION, three_callback.WaitForResult());
1037 three_transaction.reset(); 1037 three_transaction.reset();
1038 EXPECT_EQ(ERR_PIPELINE_EVICTION, four_callback.WaitForResult()); 1038 EXPECT_EQ(ERR_PIPELINE_EVICTION, four_callback.WaitForResult());
1039 } 1039 }
1040 1040
1041 } // anonymous namespace 1041 } // anonymous namespace
1042 1042
1043 } // namespace net 1043 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_connection_impl_unittest.cc ('k') | net/http/http_proxy_client_socket_pool_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698