summaryrefslogtreecommitdiffstats
path: root/base/time_posix.cc
diff options
context:
space:
mode:
authoramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 19:36:59 +0000
committeramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 19:36:59 +0000
commit8822d9730d5f30a5863d6fa5da36d967b25b8c68 (patch)
tree173c012ad6152774e807bc5648d51c3925ad1b37 /base/time_posix.cc
parentec565e6000dc1304dd92f4c5c9c0bd525fc194ea (diff)
downloadchromium_src-8822d9730d5f30a5863d6fa5da36d967b25b8c68.zip
chromium_src-8822d9730d5f30a5863d6fa5da36d967b25b8c68.tar.gz
chromium_src-8822d9730d5f30a5863d6fa5da36d967b25b8c68.tar.bz2
Update Mac implemention of Time to prevent problems with
times later than the UNIX epoch 32 bit rollover in 2038 (such as cookie expirations). time_t is only 32 bits in MacOS X, so we can't just use time_posix.cc Review URL: http://codereview.chromium.org/9249 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time_posix.cc')
-rw-r--r--base/time_posix.cc31
1 files changed, 1 insertions, 30 deletions
diff --git a/base/time_posix.cc b/base/time_posix.cc
index 901b65c..81f9bad 100644
--- a/base/time_posix.cc
+++ b/base/time_posix.cc
@@ -4,9 +4,6 @@
#include "base/time.h"
-#ifdef OS_MACOSX
-#include <mach/mach_time.h>
-#endif
#include <sys/time.h>
#include <time.h>
@@ -92,33 +89,7 @@ void Time::Explode(bool is_local, Exploded* exploded) const {
TimeTicks TimeTicks::Now() {
uint64_t absolute_micro;
-#if defined(OS_MACOSX)
-
- static mach_timebase_info_data_t timebase_info;
- if (timebase_info.denom == 0) {
- // Zero-initialization of statics guarantees that denom will be 0 before
- // calling mach_timebase_info. mach_timebase_info will never set denom to
- // 0 as that would be invalid, so the zero-check can be used to determine
- // whether mach_timebase_info has already been called. This is
- // recommended by Apple's QA1398.
- kern_return_t kr = mach_timebase_info(&timebase_info);
- DCHECK(kr == KERN_SUCCESS);
- }
-
- // mach_absolute_time is it when it comes to ticks on the Mac. Other calls
- // with less precision (such as TickCount) just call through to
- // mach_absolute_time.
-
- // timebase_info converts absolute time tick units into nanoseconds. Convert
- // to microseconds up front to stave off overflows.
- absolute_micro = mach_absolute_time() / Time::kNanosecondsPerMicrosecond *
- timebase_info.numer / timebase_info.denom;
-
- // 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.
-
-#elif defined(OS_POSIX) && \
+#if defined(OS_POSIX) && \
defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0
struct timespec ts;