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

Side by Side Diff: chrome/browser/net/connection_tester_unittest.cc

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize to NULL Created 8 years, 7 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 "chrome/browser/net/connection_tester.h" 5 #include "chrome/browser/net/connection_tester.h"
6 6
7 #include "chrome/test/base/testing_pref_service.h" 7 #include "chrome/test/base/testing_pref_service.h"
8 #include "content/test/test_browser_thread.h" 8 #include "content/test/test_browser_thread.h"
9 #include "net/base/mock_cert_verifier.h" 9 #include "net/base/mock_cert_verifier.h"
10 #include "net/base/mock_host_resolver.h" 10 #include "net/base/mock_host_resolver.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 MessageLoop message_loop_; 106 MessageLoop message_loop_;
107 content::TestBrowserThread io_thread_; 107 content::TestBrowserThread io_thread_;
108 net::TestServer test_server_; 108 net::TestServer test_server_;
109 ConnectionTesterDelegate test_delegate_; 109 ConnectionTesterDelegate test_delegate_;
110 net::MockHostResolver host_resolver_; 110 net::MockHostResolver host_resolver_;
111 scoped_ptr<net::CertVerifier> cert_verifier_; 111 scoped_ptr<net::CertVerifier> cert_verifier_;
112 scoped_ptr<net::ProxyService> proxy_service_; 112 scoped_ptr<net::ProxyService> proxy_service_;
113 scoped_refptr<net::SSLConfigService> ssl_config_service_; 113 scoped_refptr<net::SSLConfigService> ssl_config_service_;
114 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; 114 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_;
115 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; 115 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_;
116 scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context_;
117 net::HttpServerPropertiesImpl http_server_properties_impl_; 116 net::HttpServerPropertiesImpl http_server_properties_impl_;
117 scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context_;
118 118
119 private: 119 private:
120 void InitializeRequestContext() { 120 void InitializeRequestContext() {
121 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_); 121 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_);
122 cert_verifier_.reset(new net::MockCertVerifier); 122 cert_verifier_.reset(new net::MockCertVerifier);
123 proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get()); 123 proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get());
124 proxy_script_fetcher_context_->set_http_auth_handler_factory( 124 proxy_script_fetcher_context_->set_http_auth_handler_factory(
125 &http_auth_handler_factory_); 125 &http_auth_handler_factory_);
126 proxy_service_.reset(net::ProxyService::CreateDirect()); 126 proxy_service_.reset(net::ProxyService::CreateDirect());
127 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get()); 127 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get());
(...skipping 13 matching lines...) Expand all
141 http_transaction_factory_.get()); 141 http_transaction_factory_.get());
142 // In-memory cookie store. 142 // In-memory cookie store.
143 proxy_script_fetcher_context_->set_cookie_store( 143 proxy_script_fetcher_context_->set_cookie_store(
144 new net::CookieMonster(NULL, NULL)); 144 new net::CookieMonster(NULL, NULL));
145 } 145 }
146 }; 146 };
147 147
148 TEST_F(ConnectionTesterTest, RunAllTests) { 148 TEST_F(ConnectionTesterTest, RunAllTests) {
149 ASSERT_TRUE(test_server_.Start()); 149 ASSERT_TRUE(test_server_.Start());
150 150
151 ConnectionTester tester(&test_delegate_, proxy_script_fetcher_context_); 151 ConnectionTester tester(&test_delegate_, proxy_script_fetcher_context_.get());
152 152
153 // Start the test suite on URL "echoall". 153 // Start the test suite on URL "echoall".
154 // TODO(eroman): Is this URL right? 154 // TODO(eroman): Is this URL right?
155 tester.RunAllTests(test_server_.GetURL("echoall")); 155 tester.RunAllTests(test_server_.GetURL("echoall"));
156 156
157 // Wait for all the tests to complete. 157 // Wait for all the tests to complete.
158 MessageLoop::current()->Run(); 158 MessageLoop::current()->Run();
159 159
160 const int kNumExperiments = 160 const int kNumExperiments =
161 ConnectionTester::PROXY_EXPERIMENT_COUNT * 161 ConnectionTester::PROXY_EXPERIMENT_COUNT *
162 ConnectionTester::HOST_RESOLVER_EXPERIMENT_COUNT; 162 ConnectionTester::HOST_RESOLVER_EXPERIMENT_COUNT;
163 163
164 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count()); 164 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count());
165 EXPECT_EQ(kNumExperiments, 165 EXPECT_EQ(kNumExperiments,
166 test_delegate_.start_connection_test_experiment_count()); 166 test_delegate_.start_connection_test_experiment_count());
167 EXPECT_EQ(kNumExperiments, 167 EXPECT_EQ(kNumExperiments,
168 test_delegate_.completed_connection_test_experiment_count()); 168 test_delegate_.completed_connection_test_experiment_count());
169 EXPECT_EQ(1, test_delegate_.completed_connection_test_suite_count()); 169 EXPECT_EQ(1, test_delegate_.completed_connection_test_suite_count());
170 } 170 }
171 171
172 TEST_F(ConnectionTesterTest, DeleteWhileInProgress) { 172 TEST_F(ConnectionTesterTest, DeleteWhileInProgress) {
173 ASSERT_TRUE(test_server_.Start()); 173 ASSERT_TRUE(test_server_.Start());
174 174
175 scoped_ptr<ConnectionTester> tester( 175 scoped_ptr<ConnectionTester> tester(
176 new ConnectionTester(&test_delegate_, proxy_script_fetcher_context_)); 176 new ConnectionTester(&test_delegate_,
177 proxy_script_fetcher_context_.get()));
177 178
178 // Start the test suite on URL "echoall". 179 // Start the test suite on URL "echoall".
179 // TODO(eroman): Is this URL right? 180 // TODO(eroman): Is this URL right?
180 tester->RunAllTests(test_server_.GetURL("echoall")); 181 tester->RunAllTests(test_server_.GetURL("echoall"));
181 182
182 // Don't run the message loop at all. Otherwise the experiment's request may 183 // Don't run the message loop at all. Otherwise the experiment's request may
183 // complete and post a task to run the next experiment before we quit the 184 // complete and post a task to run the next experiment before we quit the
184 // message loop. 185 // message loop.
185 186
186 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count()); 187 EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count());
(...skipping 10 matching lines...) Expand all
197 // any pending tasks instead of running them. This causes a problem with 198 // any pending tasks instead of running them. This causes a problem with
198 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer 199 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer
199 // |backup_task| that it will try to deref during the destructor, but 200 // |backup_task| that it will try to deref during the destructor, but
200 // depending on the order that pending tasks were deleted in, it might 201 // depending on the order that pending tasks were deleted in, it might
201 // already be invalid! See http://crbug.com/43291. 202 // already be invalid! See http://crbug.com/43291.
202 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 203 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
203 MessageLoop::current()->Run(); 204 MessageLoop::current()->Run();
204 } 205 }
205 206
206 } // namespace 207 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/connection_tester.cc ('k') | chrome/browser/net/http_pipelining_compatibility_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698