Apply a default timeout to RunLoop::Run() calls on test main threads.

Sheriffs: This change is intended to expose tests which Run() for
an excessive amount of time. Please consider disabling tests which
hit the new Run() timeouts, rather than reverting this CL.

We add RunLoop::ScopedRunTimeoutForTest, which configures the calling
thread with a timeout, and optional callback, to apply to all Run()
calls made while it is in-scope. If a Run() is not Quit() by the caller
within the specified timeout then the loop is implicitly quit, and the
optional callback is run, if provided.

ScopedTaskEnvironment now applies a default ScopedRunTimeoutForTest set
to invoke LOG(FATAL) if any Run() on the test's main thread runs for
more than TestTimeouts::action_max_timeout().

Bug: 918724
Change-Id: I080b78e193202da0c9e3deee3a201ef1619cfd37
Reviewed-on: https://chromium-review.googlesource.com/c/1319344
Commit-Queue: Wez <[email protected]>
Reviewed-by: Albert J. Wong <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/master@{#621022}
7 files changed