Reland "Proper MessageLoop::IsIdleForTesting() that corresponds to the actual idleness criteria for MessageLoop."

This is a reland of f9c93846970ae6ddd7b9cca352571bdd718ca43d
Reverted because of https://crbug.com/799081

Original change's description:
> Proper MessageLoop::IsIdleForTesting() that corresponds to the actual idleness criteria for MessageLoop.
>
> A pre-requirement for a simpler ScopedTaskEnvironment::RunUntilIdle()
> implementation.

In patchset 2 I initially considered still testing delayed_tasks() but without
using TimeTicks::Now().

But that doesn't work either because MessagePump round robs between DoWork() and
DoDelayedWork() and a condition met by the last task meant to be processed by
DoWork() could technically occur before all ready delayed tasks are processed
(regardless of flaky timing issues).

Patch set 3 explicitly ignores delayed_tasks(). Still much better than the previous check
which didn't even properly check the main work queue (ignored tasks already moved to
triage_task()..!).

ScopedTaskEnvironment::RunUntilIdle() could use the check in patch set 2 but it can't go in
without at least fixing base::Timer (which doesn't cancel its tasks when deleted and cause
delayed tasks to outlive their scope). In the meantime, we can add an explicit
MessageLoop::HasReadyDelayedTasks() check.

> R=fdoray@chromium.org
>
> Bug: 708584
> Change-Id: I6c35d72868ab313788c166c76e179c8cd3ace438
> Reviewed-on: https://chromium-review.googlesource.com/847752
> Reviewed-by: Fran├žois Doray <fdoray@chromium.org>
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#526750}

Bug: 708584
Change-Id: I72e0543578f0d6e4c8218d9eaebd33ca3d2f8e4a
Reviewed-on: https://chromium-review.googlesource.com/856982
Reviewed-by: Fran├žois Doray <fdoray@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528163}
4 files changed