Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3022)

Unified Diff: base/time/time_mac.cc

Issue 1824673002: time: Add a static TimeTicks method that returns the underlying clock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/time/time_mac.cc
diff --git a/base/time/time_mac.cc b/base/time/time_mac.cc
index f0c780449b7b23ae89fbd1cad7d86b3905f88a18..5d7a703d67db11199b01a0f92a9c382e44dbd1aa 100644
--- a/base/time/time_mac.cc
+++ b/base/time/time_mac.cc
@@ -25,6 +25,13 @@
namespace {
+#if defined(OS_IOS)
+const char* kIOSKernBoottimeClockId =
+ "IOS_CF_ABSOLUTE_TIME_MINUS_KERN_BOOTTIME_MICROS";
+#else
+const char* kMacMachClockId = "MAC_MACH_ABSOLUTE_TIME_MICROS";
+#endif // defined(OS_IOS)
+
int64_t ComputeCurrentTicks() {
#if defined(OS_IOS)
// On iOS mach_absolute_time stops while the device is sleeping. Instead use
@@ -237,6 +244,15 @@ bool TimeTicks::IsHighResolution() {
}
// static
+std::string TimeTicks::ClockId() {
+#if defined(OS_IOS)
+ return kIOSKernBoottimeClockId;
+#else
+ return kMacMachClockId;
+#endif // defined(OS_IOS)
+}
+
+// static
ThreadTicks ThreadTicks::Now() {
return ThreadTicks(ComputeThreadTicks());
}

Powered by Google App Engine
This is Rietveld 408576698