| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "base/time.h" | 5 #include "base/time.h" | 
| 6 | 6 | 
| 7 #include <CoreFoundation/CFDate.h> | 7 #include <CoreFoundation/CFDate.h> | 
| 8 #include <CoreFoundation/CFTimeZone.h> | 8 #include <CoreFoundation/CFTimeZone.h> | 
| 9 #include <mach/mach_time.h> | 9 #include <mach/mach_time.h> | 
| 10 #include <sys/time.h> | 10 #include <sys/time.h> | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 47 | 47 | 
| 48 // static | 48 // static | 
| 49 Time Time::Now() { | 49 Time Time::Now() { | 
| 50   return FromCFAbsoluteTime(CFAbsoluteTimeGetCurrent()); | 50   return FromCFAbsoluteTime(CFAbsoluteTimeGetCurrent()); | 
| 51 } | 51 } | 
| 52 | 52 | 
| 53 // static | 53 // static | 
| 54 Time Time::FromCFAbsoluteTime(CFAbsoluteTime t) { | 54 Time Time::FromCFAbsoluteTime(CFAbsoluteTime t) { | 
| 55   if (t == 0) | 55   if (t == 0) | 
| 56     return Time();  // Consider 0 as a null Time. | 56     return Time();  // Consider 0 as a null Time. | 
|  | 57   if (t == std::numeric_limits<CFAbsoluteTime>::max()) | 
|  | 58     return Max(); | 
| 57   return Time(static_cast<int64>( | 59   return Time(static_cast<int64>( | 
| 58       (t + kCFAbsoluteTimeIntervalSince1970) * kMicrosecondsPerSecond) + | 60       (t + kCFAbsoluteTimeIntervalSince1970) * kMicrosecondsPerSecond) + | 
| 59       kWindowsEpochDeltaMicroseconds); | 61       kWindowsEpochDeltaMicroseconds); | 
| 60 } | 62 } | 
| 61 | 63 | 
| 62 CFAbsoluteTime Time::ToCFAbsoluteTime() const { | 64 CFAbsoluteTime Time::ToCFAbsoluteTime() const { | 
| 63   if (is_null()) | 65   if (is_null()) | 
| 64     return 0;  // Consider 0 as a null Time. | 66     return 0;  // Consider 0 as a null Time. | 
|  | 67   if (is_max()) | 
|  | 68     return std::numeric_limits<CFAbsoluteTime>::max(); | 
| 65   return (static_cast<CFAbsoluteTime>(us_ - kWindowsEpochDeltaMicroseconds) / | 69   return (static_cast<CFAbsoluteTime>(us_ - kWindowsEpochDeltaMicroseconds) / | 
| 66       kMicrosecondsPerSecond) - kCFAbsoluteTimeIntervalSince1970; | 70       kMicrosecondsPerSecond) - kCFAbsoluteTimeIntervalSince1970; | 
| 67 } | 71 } | 
| 68 | 72 | 
| 69 // static | 73 // static | 
| 70 Time Time::NowFromSystemTime() { | 74 Time Time::NowFromSystemTime() { | 
| 71   // Just use Now() because Now() returns the system time. | 75   // Just use Now() because Now() returns the system time. | 
| 72   return Now(); | 76   return Now(); | 
| 73 } | 77 } | 
| 74 | 78 | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 160 TimeTicks TimeTicks::HighResNow() { | 164 TimeTicks TimeTicks::HighResNow() { | 
| 161   return Now(); | 165   return Now(); | 
| 162 } | 166 } | 
| 163 | 167 | 
| 164 // static | 168 // static | 
| 165 TimeTicks TimeTicks::NowFromSystemTraceTime() { | 169 TimeTicks TimeTicks::NowFromSystemTraceTime() { | 
| 166   return HighResNow(); | 170   return HighResNow(); | 
| 167 } | 171 } | 
| 168 | 172 | 
| 169 }  // namespace base | 173 }  // namespace base | 
| OLD | NEW | 
|---|