Introduce base::MessageLoopCurrent

It extracts the statically accessible interface of MessageLoop (through
MessageLoop::current()) from its core interface.

See message_loop_current.h for more details.

Note: At first it seemed like the easiest approach would have been to
introduce MessageLoopInterface as the public interface which MessageLoop
implements (and only return an interface pointer from current()). But
that doesn't work once we get in MessageLoopForUI (and ForIO) territory
as it would need to both be a MessageLoop (MessageLoop is-a
MessageLoopInterface) and a MessageLoopInterfaceForUI
(MessageLoopInterfaceForUI is-a MessageLoopInterface) and we have
diamond inheritance... This thus enforces the current approach of
MessageLoopCurrent being a separate class that merely represents a
MessageLoop*. I think this is cleaner overall as well because it will
allow must callers to include solely message_loop_current.h and
ultimately have very few files including the message_loop.h impl (I'll
also move MessageLoop::current() to MessageLoopCurrent::Get() in a
follow-up).

This CL adds many temporary implicit back-and-forth casts. After landing
this, I plan to script migrations of the actual usage to the proper
types with the goal of eventually disconnecting the two APIs (so that
few callers actually need message_loop.h anymore and it's obvious what a
replacement of MessageLoop needs to provide statically and/or what we
need to deprecate before making such a move).

This CL is a contract with the reviewer that I will follow-up with many
TBRed CLs for trivial mass renames.

Even though the implicit casts might not seem like this CL does much
overall, it still required 25 precursor CLs (ref. crbug.com/825327) and
landing this CL locks in those gains.

Removed the two TestWatchingFromBadThread tests which are irrelevant now
that going through MessageLoopForIOCurrent enforces usage on same thread
via a ThreadChecker.

NOPRESUBMIT=True (calls to deprecated MessageLoop methods)

Bug: 825327
Change-Id: Ie66a394d02a162289aabe155436a583bfb024e8d
Reviewed-on: https://chromium-review.googlesource.com/957760
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: kylechar <kylechar@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550745}

CrOS-Libchrome-Original-Commit: 01b8301844e2f1f6b282298f893b3a490e0828f4
7 files changed
tree: 6eddc64cf07379cc619a621af01dd20ca2e9a877
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/