Index: base/time_posix.cc |
diff --git a/base/time_posix.cc b/base/time_posix.cc |
index 829c000315a5bd093e72fa2936cae05af4d51f78..b8f138511486701de9b427e007d2d1ca1b543bdd 100644 |
--- a/base/time_posix.cc |
+++ b/base/time_posix.cc |
@@ -228,6 +228,34 @@ TimeTicks TimeTicks::HighResNow() { |
return Now(); |
} |
+#if defined(OS_POSIX) && defined(CLOCK_SYSTEM_TRACE) |
+ |
+// static |
+TimeTicks TimeTicks::NowFromSystemTraceTime() { |
+ uint64_t absolute_micro; |
+ |
+ struct timespec ts; |
+ if (clock_gettime(CLOCK_SYSTEM_TRACE, &ts) != 0) { |
+ NOTREACHED() << "clock_gettime(CLOCK_SYSTEM_TRACE) failed."; |
+ return HighResNow(); |
+ } |
+ |
+ absolute_micro = |
+ (static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) + |
+ (static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond); |
+ |
+ return TimeTicks(absolute_micro); |
+} |
+ |
+#else // !(defined(OS_POSIX) && defined(CLOCK_SYSTEM_TRACE)) |
+ |
+// static |
+TimeTicks TimeTicks::NowFromSystemTraceTime() { |
+ return HighResNow(); |
+} |
+ |
+#endif // defined(OS_POSIX) && defined(CLOCK_SYSTEM_TRACE) |
+ |
#endif // !OS_MACOSX |
struct timeval Time::ToTimeVal() const { |