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

Unified Diff: base/time/time_posix.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_posix.cc
diff --git a/base/time/time_posix.cc b/base/time/time_posix.cc
index 4aadee618a0fb3a452edf945ab4b7e9fc3ac8a14..22e304320f8ae4510a56bb05d27cc8b232c220f9 100644
--- a/base/time/time_posix.cc
+++ b/base/time/time_posix.cc
@@ -93,6 +93,9 @@ int64_t ConvertTimespecToMicros(const struct timespec& ts) {
#if (defined(OS_POSIX) && \
defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \
defined(OS_BSD) || defined(OS_ANDROID)
+
+const char* kLinuxMonotonicClockId = "LINUX_CLOCK_MONOTONIC_MICROS";
+
int64_t ClockNow(clockid_t clk_id) {
struct timespec ts;
if (clock_gettime(clk_id, &ts) != 0) {
@@ -312,6 +315,11 @@ TimeTicks TimeTicks::Now() {
}
// static
+std::string TimeTicks::ClockId() {
+ return kLinuxMonotonicClockId;
+}
+
+// static
bool TimeTicks::IsHighResolution() {
return true;
}

Powered by Google App Engine
This is Rietveld 408576698