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

Unified Diff: base/time/time_mac.cc

Issue 1121463005: Fixit: Split base::TimeTicks --> TimeTicks + ThreadTicks + TraceTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Windows compile fixes. Created 5 years, 7 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/time.cc ('k') | base/time/time_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time_mac.cc
diff --git a/base/time/time_mac.cc b/base/time/time_mac.cc
index e263d07945917f8acf2eb192c9b131c5366e5384..dcad44433589b1e2d63d70496ebdb9811f17bb59 100644
--- a/base/time/time_mac.cc
+++ b/base/time/time_mac.cc
@@ -13,6 +13,8 @@
#include <sys/types.h>
#include <time.h>
+#include <limits>
+
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/mac/mach_logging.h"
@@ -21,7 +23,7 @@
namespace {
-uint64_t ComputeCurrentTicks() {
+int64 ComputeCurrentTicks() {
#if defined(OS_IOS)
// On iOS mach_absolute_time stops while the device is sleeping. Instead use
// now - KERN_BOOTTIME to get a time difference that is not impacted by clock
@@ -59,15 +61,17 @@ uint64_t ComputeCurrentTicks() {
absolute_micro =
mach_absolute_time() / base::Time::kNanosecondsPerMicrosecond *
timebase_info.numer / timebase_info.denom;
+ DCHECK_LE(absolute_micro,
+ static_cast<uint64_t>(std::numeric_limits<int64>::max()));
// Don't bother with the rollover handling that the Windows version does.
// With numer and denom = 1 (the expected case), the 64-bit absolute time
// reported in nanoseconds is enough to last nearly 585 years.
- return absolute_micro;
+ return static_cast<int64>(absolute_micro);
#endif // defined(OS_IOS)
}
-uint64_t ComputeThreadTicks() {
+int64 ComputeThreadTicks() {
#if defined(OS_IOS)
NOTREACHED();
return 0;
@@ -224,13 +228,13 @@ bool TimeTicks::IsHighResolution() {
}
// static
-TimeTicks TimeTicks::ThreadNow() {
- return TimeTicks(ComputeThreadTicks());
+ThreadTicks ThreadTicks::Now() {
+ return ThreadTicks(ComputeThreadTicks());
}
// static
-TimeTicks TimeTicks::NowFromSystemTraceTime() {
- return Now();
+TraceTicks TraceTicks::Now() {
+ return TraceTicks(ComputeCurrentTicks());
}
} // namespace base
« no previous file with comments | « base/time/time.cc ('k') | base/time/time_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698