Fixit: Fork base::TimeTicks --> TimeTicks + ThreadTicks + TraceTicks

TimeTicks was being overused for time values from three different clock
sources.  This change splits the class into three separate classes: The
general-purpose monotonic time (TimeTicks), the thread-local run time
(ThreadTicks), and the global system trace time (TraceTicks).  With this
change, the compiler is now able to use type-checking to guarantee
values from different clocks are not being mixed when doing time math.

This is the 2nd in a two-part change.  Part 1 factored-out the
comparison and math operator overloads common to base::Time and
base::TimeTicks into a templated base class.  The new ThreadTicks and
TraceTicks time classes also inherit from that base class.

Updated base/trace_event/* and a handful of outside-of-base uses of
ThreadNow() and NowFromSystemTraceTime() to use the new classes.  A bug
was identified and fixed, in src/ui/gl/angle_platform_impl.cc, where
values from TimeTicks::Now() were being erroneously provided to
base::TraceEvent instead of values from NowFromSystemTraceTime().

BUG=467417
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
NOTRY=true

Review URL: https://codereview.chromium.org/1122153002

Cr-Commit-Position: refs/heads/master@{#332080}
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 1ee3269e..b7e05b78 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -690,15 +690,15 @@
 #else
 #define MAYBE_ThreadNow ThreadNow
 #endif
-TEST(TimeTicks, MAYBE_ThreadNow) {
-  if (TimeTicks::IsThreadNowSupported()) {
+TEST(ThreadTicks, MAYBE_ThreadNow) {
+  if (ThreadTicks::IsSupported()) {
     TimeTicks begin = TimeTicks::Now();
-    TimeTicks begin_thread = TimeTicks::ThreadNow();
+    ThreadTicks begin_thread = ThreadTicks::Now();
     // Make sure that ThreadNow value is non-zero.
-    EXPECT_GT(begin_thread, TimeTicks());
+    EXPECT_GT(begin_thread, ThreadTicks());
     // Sleep for 10 milliseconds to get the thread de-scheduled.
     base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
-    TimeTicks end_thread = TimeTicks::ThreadNow();
+    ThreadTicks end_thread = ThreadTicks::Now();
     TimeTicks end = TimeTicks::Now();
     TimeDelta delta = end - begin;
     TimeDelta delta_thread = end_thread - begin_thread;
@@ -710,9 +710,10 @@
   }
 }
 
-TEST(TimeTicks, NowFromSystemTraceTime) {
+TEST(TraceTicks, NowFromSystemTraceTime) {
   // Re-use HighRes test for now since clock properties are identical.
-  HighResClockTest(&TimeTicks::NowFromSystemTraceTime);
+  using NowFunction = TimeTicks (*)(void);
+  HighResClockTest(reinterpret_cast<NowFunction>(&TraceTicks::Now));
 }
 
 TEST(TimeTicks, SnappedToNextTickBasic) {