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

Unified Diff: net/http/http_stream_factory_unittest.cc

Issue 6340016: Prevent over-preconnecting when we already have a SpdySession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/http_stream_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_unittest.cc
diff --git a/net/http/http_stream_factory_unittest.cc b/net/http/http_stream_factory_unittest.cc
index 646f79cae2880d044a28c8a6033b2460710e5305..5c5e200fc39363b097ec366bd356eeea5c9472a5 100644
--- a/net/http/http_stream_factory_unittest.cc
+++ b/net/http/http_stream_factory_unittest.cc
@@ -17,6 +17,7 @@
#include "net/http/http_network_session_peer.h"
#include "net/http/http_request_info.h"
#include "net/socket/socket_test_util.h"
+#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -163,20 +164,23 @@ CapturePreconnectsSSLSocketPool;
template<typename ParentPool>
CapturePreconnectsSocketPool<ParentPool>::CapturePreconnectsSocketPool(
HttpNetworkSession* session)
- : ParentPool(0, 0, NULL, session->host_resolver(), NULL, NULL) {}
+ : ParentPool(0, 0, NULL, session->host_resolver(), NULL, NULL),
+ last_num_streams_(-1) {}
template<>
CapturePreconnectsHttpProxySocketPool::CapturePreconnectsSocketPool(
HttpNetworkSession* session)
: HttpProxyClientSocketPool(0, 0, NULL, session->host_resolver(), NULL,
- NULL, NULL) {}
+ NULL, NULL),
+ last_num_streams_(-1) {}
template<>
CapturePreconnectsSSLSocketPool::CapturePreconnectsSocketPool(
HttpNetworkSession* session)
: SSLClientSocketPool(0, 0, NULL, session->host_resolver(),
session->cert_verifier(), NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL) {}
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ last_num_streams_(-1) {}
TEST(HttpStreamFactoryTest, PreconnectDirect) {
for (size_t i = 0; i < arraysize(kTests); ++i) {
@@ -238,6 +242,35 @@ TEST(HttpStreamFactoryTest, PreconnectSocksProxy) {
}
}
+TEST(HttpStreamFactoryTest, PreconnectDirectWithExistingSpdySession) {
+ for (size_t i = 0; i < arraysize(kTests); ++i) {
+ SessionDependencies session_deps(ProxyService::CreateDirect());
+ scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
+ HttpNetworkSessionPeer peer(session);
+
+ // Set an existing SpdySession in the pool.
+ HostPortPair host_port_pair("www.google.com", 443);
+ HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
+ scoped_refptr<SpdySession> spdy_session =
+ session->spdy_session_pool()->Get(
+ pair, session->mutable_spdy_settings(), BoundNetLog());
+
+ CapturePreconnectsTCPSocketPool* tcp_conn_pool =
+ new CapturePreconnectsTCPSocketPool(session);
+ peer.SetTCPSocketPool(tcp_conn_pool);
+ CapturePreconnectsSSLSocketPool* ssl_conn_pool =
+ new CapturePreconnectsSSLSocketPool(session.get());
+ peer.SetSSLSocketPool(ssl_conn_pool);
+ EXPECT_EQ(OK, PreconnectHelper(kTests[i], session));
+ // We shouldn't be preconnecting if we have an existing session, which is
+ // the case for https://www.google.com.
+ if (kTests[i].ssl)
+ EXPECT_EQ(-1, ssl_conn_pool->last_num_streams());
+ else
+ EXPECT_EQ(kTests[i].num_streams, tcp_conn_pool->last_num_streams());
+ }
+}
+
} // namespace
} // namespace net
« no previous file with comments | « no previous file | net/http/http_stream_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698