Make ScopedTaskEnvironment the first member of QuicHttpProxyBackendStreamTest.
The documentation for ScopedTaskEnvironment recommends making it the
first member of the test fixture:
https://cs.chromium.org/chromium/src/base/test/scoped_task_environment.h?l=54-59&rcl=376db7a96e0287f0d010acd18e7a379d190cac71
We are chaning this particular case because we want to make the
constructor of ScopedTaskEnvironment set a global variable that is
read by PlatformThread::SetCurrentThreadPriority(). If
ScopedTaskEnvironment is initialized late in the test execution,
setting this global variable races with a call to
PlatfromThread::SetCurrentThreadPriority() on the thread created
from this stack:
base::(anonymous namespace)::CreateThread
base::PlatformThread::CreateWithPriority
base::Thread::StartWithOptions
net::test::QuicHttpProxyBackendStreamTest::CreateTestBackendProxy
net::test::QuicHttpProxyBackendStreamTest::SetUp
Bug: 902441
Change-Id: I4869410f43383bd7f94f68fc7790e3305f3d1b4a
Reviewed-on: https://chromium-review.googlesource.com/c/1320654
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Ryan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606259}
diff --git a/net/tools/quic/quic_http_proxy_backend_stream_test.cc b/net/tools/quic/quic_http_proxy_backend_stream_test.cc
index ef2d507f..9d966fe 100644
--- a/net/tools/quic/quic_http_proxy_backend_stream_test.cc
+++ b/net/tools/quic/quic_http_proxy_backend_stream_test.cc
@@ -136,7 +136,6 @@
bool send_success_;
bool did_complete_;
std::unique_ptr<QuicHttpProxyBackendStream> quic_backend_stream_;
- base::test::ScopedTaskEnvironment scoped_task_environment;
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_ =
base::ThreadTaskRunnerHandle::Get();
base::RunLoop run_loop_;
@@ -185,6 +184,7 @@
}
protected:
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
std::string backend_url_;
std::unique_ptr<QuicHttpProxyBackend> proxy_backend_;
std::unique_ptr<QuicHttpProxyBackend> proxy_backend_fail_;
@@ -479,4 +479,4 @@
}
} // namespace test
-} // namespace net
\ No newline at end of file
+} // namespace net