-
Justin Gallagher authored
Command line flags, field trials, and feature flags must be initialized before BrowserTaskEnvironment to avoid a potential race condition, where the browser is reading from the trial state at the same time that it is being written to. This isn't done in SearchProviderTest, which causes potential races in two tests: SearchProviderTest.CommandLineOverrides SearchProviderTest.SendsWarmUpRequestOnFocus To resolve, a new class SearchProviderFeatureTestComponent was created to handle field trial state. It's initialized before the BrowserTaskEnvironment member. BrowserTaskEnvironment is responsible for spinning up the thread pool, so everything before that point is synchronous. That's adding a thread which is reading the field trial state, causing the race. C++ initializes it's member variables in order of declaration, so adding the FeatureTestComponent before BrowserTaskEnvironment ensures that the command line and field tests are set before any other threads are added. This change is heavily based on mpearson's prior fix, which was reverted. http://crrev.com/c/1263562 Bug: 891959 Change-Id: I5590579ad9aef73d2d055dec5712dfd5dc567ce9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902786 Commit-Queue: Justin Gallagher <jugallag@microsoft.com> Reviewed-by:
Kevin Bailey <krb@chromium.org> Cr-Commit-Position: refs/heads/master@{#714824}
e699a7c5