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

Unified Diff: net/http/http_stream_factory_impl_unittest.cc

Issue 1898133002: Add reprioritization to socket pools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated comments. Created 3 years, 10 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 | « net/http/http_stream_factory_impl_job.cc ('k') | net/socket/client_socket_handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9ad4a27b6a089b103bc5236d9763b30442e80f06..4af0225298c8434feb328aa5838e2dc133bff83d 100644
--- a/net/http/http_stream_factory_impl_unittest.cc
+++ b/net/http/http_stream_factory_impl_unittest.cc
@@ -1596,6 +1596,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, ERR_IO_PENDING);
+ 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());
« no previous file with comments | « net/http/http_stream_factory_impl_job.cc ('k') | net/socket/client_socket_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698