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

Side by Side Diff: net/http/http_stream_factory_impl_unittest.cc

Issue 2930323002: Remove Request from Map in OnNewSpdySessionReady(). (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | net/spdy/chromium/spdy_session_pool.cc » ('j') | 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/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 ASSERT_NE(nullptr, waiter1.stream()); 2094 ASSERT_NE(nullptr, waiter1.stream());
2095 ASSERT_NE(nullptr, waiter2.stream()); 2095 ASSERT_NE(nullptr, waiter2.stream());
2096 ASSERT_NE(waiter1.stream(), waiter2.stream()); 2096 ASSERT_NE(waiter1.stream(), waiter2.stream());
2097 2097
2098 // Establishing the SpdySession will close idle H2 sockets. 2098 // Establishing the SpdySession will close idle H2 sockets.
2099 EXPECT_EQ(0, session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) 2099 EXPECT_EQ(0, session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL)
2100 ->IdleSocketCount()); 2100 ->IdleSocketCount());
2101 EXPECT_EQ(1, GetSpdySessionCount(session.get())); 2101 EXPECT_EQ(1, GetSpdySessionCount(session.get()));
2102 } 2102 }
2103 2103
2104 // Regression test for https://crbug.com/706974.
2105 TEST_F(HttpStreamFactoryTest, TwoSpdyConnects) {
2106 SpdySessionDependencies session_deps(ProxyService::CreateDirect());
2107
2108 SSLSocketDataProvider ssl_socket_data0(ASYNC, OK);
2109 ssl_socket_data0.next_proto = kProtoHTTP2;
2110 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data0);
2111
2112 MockRead reads0[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING)};
2113 SequencedSocketData data0(reads0, arraysize(reads0), nullptr, 0);
2114 data0.set_connect_data(MockConnect(ASYNC, OK));
2115 session_deps.socket_factory->AddSocketDataProvider(&data0);
2116
2117 SSLSocketDataProvider ssl_socket_data1(ASYNC, OK);
2118 ssl_socket_data1.next_proto = kProtoHTTP2;
2119 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data1);
2120
2121 MockRead reads1[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING)};
2122 SequencedSocketData data1(reads1, arraysize(reads1), nullptr, 0);
2123 data1.set_connect_data(MockConnect(ASYNC, OK));
2124 session_deps.socket_factory->AddSocketDataProvider(&data1);
2125
2126 std::unique_ptr<HttpNetworkSession> session =
2127 SpdySessionDependencies::SpdyCreateSession(&session_deps);
2128 HttpRequestInfo request_info;
2129 request_info.method = "GET";
2130 request_info.url = GURL("https://www.google.com");
2131 request_info.load_flags = 0;
2132 SSLConfig ssl_config;
2133
2134 // Request two streams at once and make sure they use the same connection.
2135 StreamRequestWaiter waiter1;
2136 std::unique_ptr<HttpStreamRequest> request1 =
2137 session->http_stream_factory()->RequestStream(
2138 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter1,
2139 /* enable_ip_based_pooling = */ true,
2140 /* enable_alternative_services = */ true, NetLogWithSource());
2141
2142 StreamRequestWaiter waiter2;
2143 std::unique_ptr<HttpStreamRequest> request2 =
2144 session->http_stream_factory()->RequestStream(
2145 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter2,
2146 /* enable_ip_based_pooling = */ true,
2147 /* enable_alternative_services = */ true, NetLogWithSource());
2148
2149 waiter1.WaitForStream();
2150 waiter2.WaitForStream();
2151
2152 EXPECT_TRUE(waiter1.stream_done());
2153 EXPECT_TRUE(waiter2.stream_done());
2154 ASSERT_NE(nullptr, waiter1.stream());
2155 ASSERT_NE(nullptr, waiter2.stream());
2156 ASSERT_NE(waiter1.stream(), waiter2.stream());
2157
2158 // Establishing the SpdySession will close the extra H2 socket.
2159 EXPECT_EQ(0, session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL)
2160 ->IdleSocketCount());
2161 EXPECT_EQ(1, GetSpdySessionCount(session.get()));
xunjieli 2017/06/12 17:09:07 Could you add the following to make sure the read
Bence 2017/06/12 18:56:35 It seems like data1 is needed (otherwise the DCHEC
2162 }
2163
2104 TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImpl) { 2164 TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImpl) {
2105 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); 2165 SpdySessionDependencies session_deps(ProxyService::CreateDirect());
2106 2166
2107 MockRead mock_read(ASYNC, OK); 2167 MockRead mock_read(ASYNC, OK);
2108 SequencedSocketData socket_data(&mock_read, 1, nullptr, 0); 2168 SequencedSocketData socket_data(&mock_read, 1, nullptr, 0);
2109 socket_data.set_connect_data(MockConnect(ASYNC, OK)); 2169 socket_data.set_connect_data(MockConnect(ASYNC, OK));
2110 session_deps.socket_factory->AddSocketDataProvider(&socket_data); 2170 session_deps.socket_factory->AddSocketDataProvider(&socket_data);
2111 2171
2112 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); 2172 SSLSocketDataProvider ssl_socket_data(ASYNC, OK);
2113 ssl_socket_data.next_proto = kProtoHTTP2; 2173 ssl_socket_data.next_proto = kProtoHTTP2;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 HttpNetworkSession::NORMAL_SOCKET_POOL))); 2573 HttpNetworkSession::NORMAL_SOCKET_POOL)));
2514 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetTransportSocketPool( 2574 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetTransportSocketPool(
2515 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 2575 HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
2516 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetSSLSocketPool( 2576 EXPECT_EQ(0, GetSocketPoolGroupCount(session->GetSSLSocketPool(
2517 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); 2577 HttpNetworkSession::WEBSOCKET_SOCKET_POOL)));
2518 } 2578 }
2519 2579
2520 } // namespace 2580 } // namespace
2521 2581
2522 } // namespace net 2582 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/chromium/spdy_session_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698