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

Side by Side Diff: net/socket/transport_client_socket_pool_unittest.cc

Issue 1006643002: Plumb connection attempts from (non-proxy) ConnectJobs to HttpNetworkTransaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, resolve conflict Created 5 years, 8 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
« no previous file with comments | « net/socket/transport_client_socket_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/socket/transport_client_socket_pool.h" 5 #include "net/socket/transport_client_socket_pool.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 int rv = handle.Init("a", params_, LOW, callback.callback(), &pool_, 178 int rv = handle.Init("a", params_, LOW, callback.callback(), &pool_,
179 BoundNetLog()); 179 BoundNetLog());
180 EXPECT_EQ(ERR_IO_PENDING, rv); 180 EXPECT_EQ(ERR_IO_PENDING, rv);
181 EXPECT_FALSE(handle.is_initialized()); 181 EXPECT_FALSE(handle.is_initialized());
182 EXPECT_FALSE(handle.socket()); 182 EXPECT_FALSE(handle.socket());
183 183
184 EXPECT_EQ(OK, callback.WaitForResult()); 184 EXPECT_EQ(OK, callback.WaitForResult());
185 EXPECT_TRUE(handle.is_initialized()); 185 EXPECT_TRUE(handle.is_initialized());
186 EXPECT_TRUE(handle.socket()); 186 EXPECT_TRUE(handle.socket());
187 TestLoadTimingInfoConnectedNotReused(handle); 187 TestLoadTimingInfoConnectedNotReused(handle);
188 EXPECT_EQ(0u, handle.connection_attempts().size());
188 } 189 }
189 190
190 // Make sure that TransportConnectJob passes on its priority to its 191 // Make sure that TransportConnectJob passes on its priority to its
191 // HostResolver request on Init. 192 // HostResolver request on Init.
192 TEST_F(TransportClientSocketPoolTest, SetResolvePriorityOnInit) { 193 TEST_F(TransportClientSocketPoolTest, SetResolvePriorityOnInit) {
193 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { 194 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) {
194 RequestPriority priority = static_cast<RequestPriority>(i); 195 RequestPriority priority = static_cast<RequestPriority>(i);
195 TestCompletionCallback callback; 196 TestCompletionCallback callback;
196 ClientSocketHandle handle; 197 ClientSocketHandle handle;
197 EXPECT_EQ(ERR_IO_PENDING, 198 EXPECT_EQ(ERR_IO_PENDING,
198 handle.Init("a", params_, priority, callback.callback(), &pool_, 199 handle.Init("a", params_, priority, callback.callback(), &pool_,
199 BoundNetLog())); 200 BoundNetLog()));
200 EXPECT_EQ(priority, host_resolver_->last_request_priority()); 201 EXPECT_EQ(priority, host_resolver_->last_request_priority());
201 } 202 }
202 } 203 }
203 204
204 TEST_F(TransportClientSocketPoolTest, InitHostResolutionFailure) { 205 TEST_F(TransportClientSocketPoolTest, InitHostResolutionFailure) {
205 host_resolver_->rules()->AddSimulatedFailure("unresolvable.host.name"); 206 host_resolver_->rules()->AddSimulatedFailure("unresolvable.host.name");
206 TestCompletionCallback callback; 207 TestCompletionCallback callback;
207 ClientSocketHandle handle; 208 ClientSocketHandle handle;
208 HostPortPair host_port_pair("unresolvable.host.name", 80); 209 HostPortPair host_port_pair("unresolvable.host.name", 80);
209 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( 210 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
210 host_port_pair, false, false, OnHostResolutionCallback(), 211 host_port_pair, false, false, OnHostResolutionCallback(),
211 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); 212 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT));
212 EXPECT_EQ(ERR_IO_PENDING, 213 EXPECT_EQ(ERR_IO_PENDING,
213 handle.Init("a", dest, kDefaultPriority, callback.callback(), 214 handle.Init("a", dest, kDefaultPriority, callback.callback(),
214 &pool_, BoundNetLog())); 215 &pool_, BoundNetLog()));
215 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback.WaitForResult()); 216 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback.WaitForResult());
217 ASSERT_EQ(1u, handle.connection_attempts().size());
218 EXPECT_TRUE(handle.connection_attempts()[0].endpoint.address().empty());
219 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, handle.connection_attempts()[0].result);
216 } 220 }
217 221
218 TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) { 222 TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) {
219 client_socket_factory_.set_default_client_socket_type( 223 client_socket_factory_.set_default_client_socket_type(
220 MockTransportClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET); 224 MockTransportClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET);
221 TestCompletionCallback callback; 225 TestCompletionCallback callback;
222 ClientSocketHandle handle; 226 ClientSocketHandle handle;
223 EXPECT_EQ(ERR_IO_PENDING, 227 EXPECT_EQ(ERR_IO_PENDING,
224 handle.Init("a", params_, kDefaultPriority, callback.callback(), 228 handle.Init("a", params_, kDefaultPriority, callback.callback(),
225 &pool_, BoundNetLog())); 229 &pool_, BoundNetLog()));
226 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult()); 230 EXPECT_EQ(ERR_CONNECTION_FAILED, callback.WaitForResult());
231 ASSERT_EQ(1u, handle.connection_attempts().size());
232 EXPECT_EQ("127.0.0.1:80",
233 handle.connection_attempts()[0].endpoint.ToString());
234 EXPECT_EQ(ERR_CONNECTION_FAILED, handle.connection_attempts()[0].result);
227 235
228 // Make the host resolutions complete synchronously this time. 236 // Make the host resolutions complete synchronously this time.
229 host_resolver_->set_synchronous_mode(true); 237 host_resolver_->set_synchronous_mode(true);
230 EXPECT_EQ(ERR_CONNECTION_FAILED, 238 EXPECT_EQ(ERR_CONNECTION_FAILED,
231 handle.Init("a", params_, kDefaultPriority, callback.callback(), 239 handle.Init("a", params_, kDefaultPriority, callback.callback(),
232 &pool_, BoundNetLog())); 240 &pool_, BoundNetLog()));
241 ASSERT_EQ(1u, handle.connection_attempts().size());
242 EXPECT_EQ("127.0.0.1:80",
243 handle.connection_attempts()[0].endpoint.ToString());
244 EXPECT_EQ(ERR_CONNECTION_FAILED, handle.connection_attempts()[0].result);
233 } 245 }
234 246
235 TEST_F(TransportClientSocketPoolTest, PendingRequests) { 247 TEST_F(TransportClientSocketPoolTest, PendingRequests) {
236 // First request finishes asynchronously. 248 // First request finishes asynchronously.
237 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); 249 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority));
238 EXPECT_EQ(OK, (*requests())[0]->WaitForResult()); 250 EXPECT_EQ(OK, (*requests())[0]->WaitForResult());
239 251
240 // Make all subsequent host resolutions complete synchronously. 252 // Make all subsequent host resolutions complete synchronously.
241 host_resolver_->set_synchronous_mode(true); 253 host_resolver_->set_synchronous_mode(true);
242 254
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 handle.socket()->GetLocalAddress(&endpoint); 1103 handle.socket()->GetLocalAddress(&endpoint);
1092 EXPECT_EQ(kIPv6AddressSize, endpoint.address().size()); 1104 EXPECT_EQ(kIPv6AddressSize, endpoint.address().size());
1093 EXPECT_EQ(1, client_socket_factory_.allocation_count()); 1105 EXPECT_EQ(1, client_socket_factory_.allocation_count());
1094 // Verify that TCP FastOpen was not turned on for the socket. 1106 // Verify that TCP FastOpen was not turned on for the socket.
1095 EXPECT_FALSE(handle.socket()->UsingTCPFastOpen()); 1107 EXPECT_FALSE(handle.socket()->UsingTCPFastOpen());
1096 } 1108 }
1097 1109
1098 } // namespace 1110 } // namespace
1099 1111
1100 } // namespace net 1112 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/transport_client_socket_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698