Chromium Code Reviews| Index: net/http/http_stream_factory_impl_unittest.cc |
| diff --git a/net/http/http_stream_factory_impl_unittest.cc b/net/http/http_stream_factory_impl_unittest.cc |
| index a33649090be28b3467eada923cb91343779cb0e5..9dc29505ae9f3b1f73283ed78c1942daac076631 100644 |
| --- a/net/http/http_stream_factory_impl_unittest.cc |
| +++ b/net/http/http_stream_factory_impl_unittest.cc |
| @@ -1514,6 +1514,54 @@ TEST_F(HttpStreamFactoryTest, RequestHttpStream) { |
| EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
| } |
| +// Test the race of SetPriority versus stream completion where SetPriority |
| +// may be called on an HttpStreamFactoryImpl::Job after the stream |
| +// has been created by the job. |
| +TEST_F(HttpStreamFactoryTest, ReprioritizeAfterStreamReceived) { |
| + SpdySessionDependencies session_deps(ProxyService::CreateDirect()); |
| + |
| + MockRead mock_read(SYNCHRONOUS, OK); |
|
mmenke
2017/01/24 17:30:34
OK -> ERR_IO_PENDING? I don't think we want to re
Randy Smith (Not in Mondays)
2017/02/16 23:22:18
Oh, that makes some sense of some of my debugging
|
| + StaticSocketDataProvider socket_data(&mock_read, 1, nullptr, 0); |
| + socket_data.set_connect_data(MockConnect(SYNCHRONOUS, OK)); |
| + session_deps.socket_factory->AddSocketDataProvider(&socket_data); |
| + |
| + SSLSocketDataProvider ssl_socket_data(SYNCHRONOUS, OK); |
| + ssl_socket_data.next_proto = kProtoHTTP2; |
| + session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); |
| + |
| + std::unique_ptr<HttpNetworkSession> session( |
| + SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| + |
| + // Now request a stream. |
| + HttpRequestInfo request_info; |
| + request_info.method = "GET"; |
| + request_info.url = GURL("https://www.google.com"); |
| + request_info.load_flags = 0; |
| + |
| + SSLConfig ssl_config; |
| + StreamRequestWaiter waiter; |
| + EXPECT_EQ(0, GetSpdySessionCount(session.get())); |
| + std::unique_ptr<HttpStreamRequest> request( |
| + session->http_stream_factory()->RequestStream( |
| + request_info, LOWEST, ssl_config, ssl_config, &waiter, |
| + NetLogWithSource())); |
| + EXPECT_FALSE(waiter.stream_done()); |
| + |
| + // Confirm a stream has been created by asserting that a new session |
| + // has been created. (The stream is only created at the SPDY level on |
| + // first write, which happens after the request has returned a stream). |
| + ASSERT_EQ(1, GetSpdySessionCount(session.get())); |
| + |
| + // Test to confirm that a SetPriority received after the stream is created |
| + // but before the request returns it does not crash. |
| + request->SetPriority(HIGHEST); |
| + |
| + waiter.WaitForStream(); |
| + EXPECT_TRUE(waiter.stream_done()); |
| + ASSERT_TRUE(waiter.stream()); |
| + EXPECT_FALSE(waiter.websocket_stream()); |
| +} |
| + |
| TEST_F(HttpStreamFactoryTest, RequestHttpStreamOverSSL) { |
| SpdySessionDependencies session_deps(ProxyService::CreateDirect()); |