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

Unified Diff: base/time_posix.cc

Issue 10257020: Add interface to system trace clock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: consolidate high res clock unit test code Created 8 years, 8 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
« no previous file with comments | « base/time_mac.cc ('k') | base/time_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « base/time_mac.cc ('k') | base/time_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698