OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 3168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3179 HttpNetworkSession::NORMAL_SOCKET_POOL); | 3179 HttpNetworkSession::NORMAL_SOCKET_POOL); |
3180 | 3180 |
3181 // Create an idle SPDY session. | 3181 // Create an idle SPDY session. |
3182 CreateInsecureSpdySession(); | 3182 CreateInsecureSpdySession(); |
3183 EXPECT_FALSE(pool->IsStalled()); | 3183 EXPECT_FALSE(pool->IsStalled()); |
3184 | 3184 |
3185 // Trying to create a new connection should cause the pool to be stalled, and | 3185 // Trying to create a new connection should cause the pool to be stalled, and |
3186 // post a task asynchronously to try and close the session. | 3186 // post a task asynchronously to try and close the session. |
3187 TestCompletionCallback callback2; | 3187 TestCompletionCallback callback2; |
3188 HostPortPair host_port2("2.com", 80); | 3188 HostPortPair host_port2("2.com", 80); |
3189 scoped_refptr<TransportSocketParams> params2( | 3189 scoped_refptr<TransportSocketParams> params2(new TransportSocketParams( |
3190 new TransportSocketParams( | 3190 host_port2, false, OnHostResolutionCallback(), |
3191 host_port2, false, false, OnHostResolutionCallback(), | 3191 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); |
3192 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); | |
3193 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); | 3192 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); |
3194 EXPECT_EQ(ERR_IO_PENDING, | 3193 EXPECT_EQ(ERR_IO_PENDING, |
3195 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, | 3194 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, |
| 3195 ClientSocketPool::RespectLimits::ENABLED, |
3196 callback2.callback(), pool, BoundNetLog())); | 3196 callback2.callback(), pool, BoundNetLog())); |
3197 EXPECT_TRUE(pool->IsStalled()); | 3197 EXPECT_TRUE(pool->IsStalled()); |
3198 | 3198 |
3199 // The socket pool should close the connection asynchronously and establish a | 3199 // The socket pool should close the connection asynchronously and establish a |
3200 // new connection. | 3200 // new connection. |
3201 EXPECT_EQ(OK, callback2.WaitForResult()); | 3201 EXPECT_EQ(OK, callback2.WaitForResult()); |
3202 EXPECT_FALSE(pool->IsStalled()); | 3202 EXPECT_FALSE(pool->IsStalled()); |
3203 EXPECT_FALSE(session_); | 3203 EXPECT_FALSE(session_); |
3204 } | 3204 } |
3205 | 3205 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 // Get a session for |key2|, which should return the session created earlier. | 3254 // Get a session for |key2|, which should return the session created earlier. |
3255 base::WeakPtr<SpdySession> session2 = | 3255 base::WeakPtr<SpdySession> session2 = |
3256 spdy_session_pool_->FindAvailableSession(key2, BoundNetLog()); | 3256 spdy_session_pool_->FindAvailableSession(key2, BoundNetLog()); |
3257 ASSERT_EQ(session1.get(), session2.get()); | 3257 ASSERT_EQ(session1.get(), session2.get()); |
3258 EXPECT_FALSE(pool->IsStalled()); | 3258 EXPECT_FALSE(pool->IsStalled()); |
3259 | 3259 |
3260 // Trying to create a new connection should cause the pool to be stalled, and | 3260 // Trying to create a new connection should cause the pool to be stalled, and |
3261 // post a task asynchronously to try and close the session. | 3261 // post a task asynchronously to try and close the session. |
3262 TestCompletionCallback callback3; | 3262 TestCompletionCallback callback3; |
3263 HostPortPair host_port3("3.com", 80); | 3263 HostPortPair host_port3("3.com", 80); |
3264 scoped_refptr<TransportSocketParams> params3( | 3264 scoped_refptr<TransportSocketParams> params3(new TransportSocketParams( |
3265 new TransportSocketParams( | 3265 host_port3, false, OnHostResolutionCallback(), |
3266 host_port3, false, false, OnHostResolutionCallback(), | 3266 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); |
3267 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); | |
3268 scoped_ptr<ClientSocketHandle> connection3(new ClientSocketHandle); | 3267 scoped_ptr<ClientSocketHandle> connection3(new ClientSocketHandle); |
3269 EXPECT_EQ(ERR_IO_PENDING, | 3268 EXPECT_EQ(ERR_IO_PENDING, |
3270 connection3->Init(host_port3.ToString(), params3, DEFAULT_PRIORITY, | 3269 connection3->Init(host_port3.ToString(), params3, DEFAULT_PRIORITY, |
| 3270 ClientSocketPool::RespectLimits::ENABLED, |
3271 callback3.callback(), pool, BoundNetLog())); | 3271 callback3.callback(), pool, BoundNetLog())); |
3272 EXPECT_TRUE(pool->IsStalled()); | 3272 EXPECT_TRUE(pool->IsStalled()); |
3273 | 3273 |
3274 // The socket pool should close the connection asynchronously and establish a | 3274 // The socket pool should close the connection asynchronously and establish a |
3275 // new connection. | 3275 // new connection. |
3276 EXPECT_EQ(OK, callback3.WaitForResult()); | 3276 EXPECT_EQ(OK, callback3.WaitForResult()); |
3277 EXPECT_FALSE(pool->IsStalled()); | 3277 EXPECT_FALSE(pool->IsStalled()); |
3278 EXPECT_FALSE(session1); | 3278 EXPECT_FALSE(session1); |
3279 EXPECT_FALSE(session2); | 3279 EXPECT_FALSE(session2); |
3280 } | 3280 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3335 EXPECT_EQ(ERR_IO_PENDING, spdy_stream1->SendRequestHeaders( | 3335 EXPECT_EQ(ERR_IO_PENDING, spdy_stream1->SendRequestHeaders( |
3336 std::move(headers1), NO_MORE_DATA_TO_SEND)); | 3336 std::move(headers1), NO_MORE_DATA_TO_SEND)); |
3337 EXPECT_TRUE(spdy_stream1->HasUrlFromHeaders()); | 3337 EXPECT_TRUE(spdy_stream1->HasUrlFromHeaders()); |
3338 | 3338 |
3339 base::RunLoop().RunUntilIdle(); | 3339 base::RunLoop().RunUntilIdle(); |
3340 | 3340 |
3341 // Trying to create a new connection should cause the pool to be stalled, and | 3341 // Trying to create a new connection should cause the pool to be stalled, and |
3342 // post a task asynchronously to try and close the session. | 3342 // post a task asynchronously to try and close the session. |
3343 TestCompletionCallback callback2; | 3343 TestCompletionCallback callback2; |
3344 HostPortPair host_port2("2.com", 80); | 3344 HostPortPair host_port2("2.com", 80); |
3345 scoped_refptr<TransportSocketParams> params2( | 3345 scoped_refptr<TransportSocketParams> params2(new TransportSocketParams( |
3346 new TransportSocketParams( | 3346 host_port2, false, OnHostResolutionCallback(), |
3347 host_port2, false, false, OnHostResolutionCallback(), | 3347 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); |
3348 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); | |
3349 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); | 3348 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); |
3350 EXPECT_EQ(ERR_IO_PENDING, | 3349 EXPECT_EQ(ERR_IO_PENDING, |
3351 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, | 3350 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, |
| 3351 ClientSocketPool::RespectLimits::ENABLED, |
3352 callback2.callback(), pool, BoundNetLog())); | 3352 callback2.callback(), pool, BoundNetLog())); |
3353 EXPECT_TRUE(pool->IsStalled()); | 3353 EXPECT_TRUE(pool->IsStalled()); |
3354 | 3354 |
3355 // Running the message loop should cause the socket pool to ask the SPDY | 3355 // Running the message loop should cause the socket pool to ask the SPDY |
3356 // session to close an idle socket, but since the socket is in use, nothing | 3356 // session to close an idle socket, but since the socket is in use, nothing |
3357 // happens. | 3357 // happens. |
3358 base::RunLoop().RunUntilIdle(); | 3358 base::RunLoop().RunUntilIdle(); |
3359 EXPECT_TRUE(pool->IsStalled()); | 3359 EXPECT_TRUE(pool->IsStalled()); |
3360 EXPECT_FALSE(callback2.have_result()); | 3360 EXPECT_FALSE(callback2.have_result()); |
3361 | 3361 |
(...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5440 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5440 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
5441 "spdy_pooling.pem"); | 5441 "spdy_pooling.pem"); |
5442 ssl_info.is_issued_by_known_root = true; | 5442 ssl_info.is_issued_by_known_root = true; |
5443 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5443 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
5444 | 5444 |
5445 EXPECT_TRUE(SpdySession::CanPool( | 5445 EXPECT_TRUE(SpdySession::CanPool( |
5446 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5446 &tss, ssl_info, "www.example.org", "mail.example.org")); |
5447 } | 5447 } |
5448 | 5448 |
5449 } // namespace net | 5449 } // namespace net |
OLD | NEW |