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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 virtual ~SpdySessionTest() { | 115 virtual ~SpdySessionTest() { |
116 // Important to restore the per-pool limit first, since the pool limit must | 116 // Important to restore the per-pool limit first, since the pool limit must |
117 // always be greater than group limit, and the tests reduce both limits. | 117 // always be greater than group limit, and the tests reduce both limits. |
118 ClientSocketPoolManager::set_max_sockets_per_pool( | 118 ClientSocketPoolManager::set_max_sockets_per_pool( |
119 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_); | 119 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_); |
120 ClientSocketPoolManager::set_max_sockets_per_group( | 120 ClientSocketPoolManager::set_max_sockets_per_group( |
121 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_group_sockets_); | 121 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_group_sockets_); |
122 } | 122 } |
123 | 123 |
124 virtual void SetUp() OVERRIDE { | 124 virtual void SetUp() override { |
125 g_time_delta = base::TimeDelta(); | 125 g_time_delta = base::TimeDelta(); |
126 } | 126 } |
127 | 127 |
128 void CreateDeterministicNetworkSession() { | 128 void CreateDeterministicNetworkSession() { |
129 http_session_ = | 129 http_session_ = |
130 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_); | 130 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_); |
131 spdy_session_pool_ = http_session_->spdy_session_pool(); | 131 spdy_session_pool_ = http_session_->spdy_session_pool(); |
132 } | 132 } |
133 | 133 |
134 void CreateNetworkSession() { | 134 void CreateNetworkSession() { |
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 // Delegate that closes a given session when the stream is closed. | 2298 // Delegate that closes a given session when the stream is closed. |
2299 class SessionClosingDelegate : public test::StreamDelegateDoNothing { | 2299 class SessionClosingDelegate : public test::StreamDelegateDoNothing { |
2300 public: | 2300 public: |
2301 SessionClosingDelegate(const base::WeakPtr<SpdyStream>& stream, | 2301 SessionClosingDelegate(const base::WeakPtr<SpdyStream>& stream, |
2302 const base::WeakPtr<SpdySession>& session_to_close) | 2302 const base::WeakPtr<SpdySession>& session_to_close) |
2303 : StreamDelegateDoNothing(stream), | 2303 : StreamDelegateDoNothing(stream), |
2304 session_to_close_(session_to_close) {} | 2304 session_to_close_(session_to_close) {} |
2305 | 2305 |
2306 virtual ~SessionClosingDelegate() {} | 2306 virtual ~SessionClosingDelegate() {} |
2307 | 2307 |
2308 virtual void OnClose(int status) OVERRIDE { | 2308 virtual void OnClose(int status) override { |
2309 session_to_close_->CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Error"); | 2309 session_to_close_->CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Error"); |
2310 } | 2310 } |
2311 | 2311 |
2312 private: | 2312 private: |
2313 base::WeakPtr<SpdySession> session_to_close_; | 2313 base::WeakPtr<SpdySession> session_to_close_; |
2314 }; | 2314 }; |
2315 | 2315 |
2316 // Close an activated stream that closes its session. Nothing should | 2316 // Close an activated stream that closes its session. Nothing should |
2317 // blow up. This is a regression test for http://crbug.com/263691 . | 2317 // blow up. This is a regression test for http://crbug.com/263691 . |
2318 TEST_P(SpdySessionTest, CloseActivatedStreamThatClosesSession) { | 2318 TEST_P(SpdySessionTest, CloseActivatedStreamThatClosesSession) { |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3374 // Delegate that creates another stream when its stream is closed. | 3374 // Delegate that creates another stream when its stream is closed. |
3375 class StreamCreatingDelegate : public test::StreamDelegateDoNothing { | 3375 class StreamCreatingDelegate : public test::StreamDelegateDoNothing { |
3376 public: | 3376 public: |
3377 StreamCreatingDelegate(const base::WeakPtr<SpdyStream>& stream, | 3377 StreamCreatingDelegate(const base::WeakPtr<SpdyStream>& stream, |
3378 const base::WeakPtr<SpdySession>& session) | 3378 const base::WeakPtr<SpdySession>& session) |
3379 : StreamDelegateDoNothing(stream), | 3379 : StreamDelegateDoNothing(stream), |
3380 session_(session) {} | 3380 session_(session) {} |
3381 | 3381 |
3382 virtual ~StreamCreatingDelegate() {} | 3382 virtual ~StreamCreatingDelegate() {} |
3383 | 3383 |
3384 virtual void OnClose(int status) OVERRIDE { | 3384 virtual void OnClose(int status) override { |
3385 GURL url(kDefaultURL); | 3385 GURL url(kDefaultURL); |
3386 ignore_result( | 3386 ignore_result( |
3387 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM, | 3387 CreateStreamSynchronously(SPDY_REQUEST_RESPONSE_STREAM, |
3388 session_, url, MEDIUM, BoundNetLog())); | 3388 session_, url, MEDIUM, BoundNetLog())); |
3389 } | 3389 } |
3390 | 3390 |
3391 private: | 3391 private: |
3392 const base::WeakPtr<SpdySession> session_; | 3392 const base::WeakPtr<SpdySession> session_; |
3393 }; | 3393 }; |
3394 | 3394 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3654 // A delegate that drops any received data. | 3654 // A delegate that drops any received data. |
3655 class DropReceivedDataDelegate : public test::StreamDelegateSendImmediate { | 3655 class DropReceivedDataDelegate : public test::StreamDelegateSendImmediate { |
3656 public: | 3656 public: |
3657 DropReceivedDataDelegate(const base::WeakPtr<SpdyStream>& stream, | 3657 DropReceivedDataDelegate(const base::WeakPtr<SpdyStream>& stream, |
3658 base::StringPiece data) | 3658 base::StringPiece data) |
3659 : StreamDelegateSendImmediate(stream, data) {} | 3659 : StreamDelegateSendImmediate(stream, data) {} |
3660 | 3660 |
3661 virtual ~DropReceivedDataDelegate() {} | 3661 virtual ~DropReceivedDataDelegate() {} |
3662 | 3662 |
3663 // Drop any received data. | 3663 // Drop any received data. |
3664 virtual void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE {} | 3664 virtual void OnDataReceived(scoped_ptr<SpdyBuffer> buffer) override {} |
3665 }; | 3665 }; |
3666 | 3666 |
3667 // Send data back and forth but use a delegate that drops its received | 3667 // Send data back and forth but use a delegate that drops its received |
3668 // data. The receive window should still increase to its original | 3668 // data. The receive window should still increase to its original |
3669 // value, i.e. we shouldn't "leak" receive window bytes. | 3669 // value, i.e. we shouldn't "leak" receive window bytes. |
3670 TEST_P(SpdySessionTest, SessionFlowControlNoReceiveLeaks) { | 3670 TEST_P(SpdySessionTest, SessionFlowControlNoReceiveLeaks) { |
3671 if (GetParam() < kProtoSPDY31) | 3671 if (GetParam() < kProtoSPDY31) |
3672 return; | 3672 return; |
3673 | 3673 |
3674 const char kStreamUrl[] = "http://www.google.com/"; | 3674 const char kStreamUrl[] = "http://www.google.com/"; |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4242 StreamClosingDelegate(const base::WeakPtr<SpdyStream>& stream, | 4242 StreamClosingDelegate(const base::WeakPtr<SpdyStream>& stream, |
4243 base::StringPiece data) | 4243 base::StringPiece data) |
4244 : StreamDelegateWithBody(stream, data) {} | 4244 : StreamDelegateWithBody(stream, data) {} |
4245 | 4245 |
4246 virtual ~StreamClosingDelegate() {} | 4246 virtual ~StreamClosingDelegate() {} |
4247 | 4247 |
4248 void set_stream_to_close(const base::WeakPtr<SpdyStream>& stream_to_close) { | 4248 void set_stream_to_close(const base::WeakPtr<SpdyStream>& stream_to_close) { |
4249 stream_to_close_ = stream_to_close; | 4249 stream_to_close_ = stream_to_close; |
4250 } | 4250 } |
4251 | 4251 |
4252 virtual void OnDataSent() OVERRIDE { | 4252 virtual void OnDataSent() override { |
4253 test::StreamDelegateWithBody::OnDataSent(); | 4253 test::StreamDelegateWithBody::OnDataSent(); |
4254 if (stream_to_close_.get()) { | 4254 if (stream_to_close_.get()) { |
4255 stream_to_close_->Close(); | 4255 stream_to_close_->Close(); |
4256 EXPECT_EQ(NULL, stream_to_close_.get()); | 4256 EXPECT_EQ(NULL, stream_to_close_.get()); |
4257 } | 4257 } |
4258 } | 4258 } |
4259 | 4259 |
4260 private: | 4260 private: |
4261 base::WeakPtr<SpdyStream> stream_to_close_; | 4261 base::WeakPtr<SpdyStream> stream_to_close_; |
4262 }; | 4262 }; |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5135 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5135 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
5136 "spdy_pooling.pem"); | 5136 "spdy_pooling.pem"); |
5137 ssl_info.is_issued_by_known_root = true; | 5137 ssl_info.is_issued_by_known_root = true; |
5138 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5138 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
5139 | 5139 |
5140 EXPECT_TRUE(SpdySession::CanPool( | 5140 EXPECT_TRUE(SpdySession::CanPool( |
5141 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5141 &tss, ssl_info, "www.example.org", "mail.example.org")); |
5142 } | 5142 } |
5143 | 5143 |
5144 } // namespace net | 5144 } // namespace net |
OLD | NEW |