| 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3132 PRIVACY_MODE_DISABLED); | 3132 PRIVACY_MODE_DISABLED); |
| 3133 base::WeakPtr<SpdySession> session1 = | 3133 base::WeakPtr<SpdySession> session1 = |
| 3134 CreateInsecureSpdySession(http_session_, key1, BoundNetLog()); | 3134 CreateInsecureSpdySession(http_session_, key1, BoundNetLog()); |
| 3135 EXPECT_FALSE(pool->IsStalled()); | 3135 EXPECT_FALSE(pool->IsStalled()); |
| 3136 | 3136 |
| 3137 // Trying to create a new connection should cause the pool to be stalled, and | 3137 // Trying to create a new connection should cause the pool to be stalled, and |
| 3138 // post a task asynchronously to try and close the session. | 3138 // post a task asynchronously to try and close the session. |
| 3139 TestCompletionCallback callback2; | 3139 TestCompletionCallback callback2; |
| 3140 HostPortPair host_port2("2.com", 80); | 3140 HostPortPair host_port2("2.com", 80); |
| 3141 scoped_refptr<TransportSocketParams> params2( | 3141 scoped_refptr<TransportSocketParams> params2( |
| 3142 new TransportSocketParams(host_port2, false, false, | 3142 new TransportSocketParams( |
| 3143 OnHostResolutionCallback())); | 3143 host_port2, false, false, OnHostResolutionCallback(), |
| 3144 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); |
| 3144 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); | 3145 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); |
| 3145 EXPECT_EQ(ERR_IO_PENDING, | 3146 EXPECT_EQ(ERR_IO_PENDING, |
| 3146 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, | 3147 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, |
| 3147 callback2.callback(), pool, BoundNetLog())); | 3148 callback2.callback(), pool, BoundNetLog())); |
| 3148 EXPECT_TRUE(pool->IsStalled()); | 3149 EXPECT_TRUE(pool->IsStalled()); |
| 3149 | 3150 |
| 3150 // The socket pool should close the connection asynchronously and establish a | 3151 // The socket pool should close the connection asynchronously and establish a |
| 3151 // new connection. | 3152 // new connection. |
| 3152 EXPECT_EQ(OK, callback2.WaitForResult()); | 3153 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 3153 EXPECT_FALSE(pool->IsStalled()); | 3154 EXPECT_FALSE(pool->IsStalled()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3211 base::WeakPtr<SpdySession> session2 = | 3212 base::WeakPtr<SpdySession> session2 = |
| 3212 spdy_session_pool_->FindAvailableSession(key2, BoundNetLog()); | 3213 spdy_session_pool_->FindAvailableSession(key2, BoundNetLog()); |
| 3213 ASSERT_EQ(session1.get(), session2.get()); | 3214 ASSERT_EQ(session1.get(), session2.get()); |
| 3214 EXPECT_FALSE(pool->IsStalled()); | 3215 EXPECT_FALSE(pool->IsStalled()); |
| 3215 | 3216 |
| 3216 // Trying to create a new connection should cause the pool to be stalled, and | 3217 // Trying to create a new connection should cause the pool to be stalled, and |
| 3217 // post a task asynchronously to try and close the session. | 3218 // post a task asynchronously to try and close the session. |
| 3218 TestCompletionCallback callback3; | 3219 TestCompletionCallback callback3; |
| 3219 HostPortPair host_port3("3.com", 80); | 3220 HostPortPair host_port3("3.com", 80); |
| 3220 scoped_refptr<TransportSocketParams> params3( | 3221 scoped_refptr<TransportSocketParams> params3( |
| 3221 new TransportSocketParams(host_port3, false, false, | 3222 new TransportSocketParams( |
| 3222 OnHostResolutionCallback())); | 3223 host_port3, false, false, OnHostResolutionCallback(), |
| 3224 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); |
| 3223 scoped_ptr<ClientSocketHandle> connection3(new ClientSocketHandle); | 3225 scoped_ptr<ClientSocketHandle> connection3(new ClientSocketHandle); |
| 3224 EXPECT_EQ(ERR_IO_PENDING, | 3226 EXPECT_EQ(ERR_IO_PENDING, |
| 3225 connection3->Init(host_port3.ToString(), params3, DEFAULT_PRIORITY, | 3227 connection3->Init(host_port3.ToString(), params3, DEFAULT_PRIORITY, |
| 3226 callback3.callback(), pool, BoundNetLog())); | 3228 callback3.callback(), pool, BoundNetLog())); |
| 3227 EXPECT_TRUE(pool->IsStalled()); | 3229 EXPECT_TRUE(pool->IsStalled()); |
| 3228 | 3230 |
| 3229 // The socket pool should close the connection asynchronously and establish a | 3231 // The socket pool should close the connection asynchronously and establish a |
| 3230 // new connection. | 3232 // new connection. |
| 3231 EXPECT_EQ(OK, callback3.WaitForResult()); | 3233 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 3232 EXPECT_FALSE(pool->IsStalled()); | 3234 EXPECT_FALSE(pool->IsStalled()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3300 headers1.Pass(), NO_MORE_DATA_TO_SEND)); | 3302 headers1.Pass(), NO_MORE_DATA_TO_SEND)); |
| 3301 EXPECT_TRUE(spdy_stream1->HasUrlFromHeaders()); | 3303 EXPECT_TRUE(spdy_stream1->HasUrlFromHeaders()); |
| 3302 | 3304 |
| 3303 base::MessageLoop::current()->RunUntilIdle(); | 3305 base::MessageLoop::current()->RunUntilIdle(); |
| 3304 | 3306 |
| 3305 // Trying to create a new connection should cause the pool to be stalled, and | 3307 // Trying to create a new connection should cause the pool to be stalled, and |
| 3306 // post a task asynchronously to try and close the session. | 3308 // post a task asynchronously to try and close the session. |
| 3307 TestCompletionCallback callback2; | 3309 TestCompletionCallback callback2; |
| 3308 HostPortPair host_port2("2.com", 80); | 3310 HostPortPair host_port2("2.com", 80); |
| 3309 scoped_refptr<TransportSocketParams> params2( | 3311 scoped_refptr<TransportSocketParams> params2( |
| 3310 new TransportSocketParams(host_port2, false, false, | 3312 new TransportSocketParams( |
| 3311 OnHostResolutionCallback())); | 3313 host_port2, false, false, OnHostResolutionCallback(), |
| 3314 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); |
| 3312 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); | 3315 scoped_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); |
| 3313 EXPECT_EQ(ERR_IO_PENDING, | 3316 EXPECT_EQ(ERR_IO_PENDING, |
| 3314 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, | 3317 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, |
| 3315 callback2.callback(), pool, BoundNetLog())); | 3318 callback2.callback(), pool, BoundNetLog())); |
| 3316 EXPECT_TRUE(pool->IsStalled()); | 3319 EXPECT_TRUE(pool->IsStalled()); |
| 3317 | 3320 |
| 3318 // Running the message loop should cause the socket pool to ask the SPDY | 3321 // Running the message loop should cause the socket pool to ask the SPDY |
| 3319 // session to close an idle socket, but since the socket is in use, nothing | 3322 // session to close an idle socket, but since the socket is in use, nothing |
| 3320 // happens. | 3323 // happens. |
| 3321 base::RunLoop().RunUntilIdle(); | 3324 base::RunLoop().RunUntilIdle(); |
| (...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5132 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5135 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
| 5133 "spdy_pooling.pem"); | 5136 "spdy_pooling.pem"); |
| 5134 ssl_info.is_issued_by_known_root = true; | 5137 ssl_info.is_issued_by_known_root = true; |
| 5135 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5138 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
| 5136 | 5139 |
| 5137 EXPECT_TRUE(SpdySession::CanPool( | 5140 EXPECT_TRUE(SpdySession::CanPool( |
| 5138 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5141 &tss, ssl_info, "www.example.org", "mail.example.org")); |
| 5139 } | 5142 } |
| 5140 | 5143 |
| 5141 } // namespace net | 5144 } // namespace net |
| OLD | NEW |