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/time.h" | 5 #include "base/time/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.h> | 9 #include <mach/mach.h> |
10 #include <mach/mach_time.h> | 10 #include <mach/mach_time.h> |
| 11 #include <stdint.h> |
11 #include <sys/sysctl.h> | 12 #include <sys/sysctl.h> |
12 #include <sys/time.h> | 13 #include <sys/time.h> |
13 #include <sys/types.h> | 14 #include <sys/types.h> |
14 #include <time.h> | 15 #include <time.h> |
15 | 16 |
16 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/mac/mach_logging.h" | 19 #include "base/mac/mach_logging.h" |
19 #include "base/mac/scoped_cftyperef.h" | 20 #include "base/mac/scoped_cftyperef.h" |
20 #include "base/mac/scoped_mach_port.h" | 21 #include "base/mac/scoped_mach_port.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Time ----------------------------------------------------------------------- | 108 // Time ----------------------------------------------------------------------- |
108 | 109 |
109 // Core Foundation uses a double second count since 2001-01-01 00:00:00 UTC. | 110 // Core Foundation uses a double second count since 2001-01-01 00:00:00 UTC. |
110 // The UNIX epoch is 1970-01-01 00:00:00 UTC. | 111 // The UNIX epoch is 1970-01-01 00:00:00 UTC. |
111 // Windows uses a Gregorian epoch of 1601. We need to match this internally | 112 // Windows uses a Gregorian epoch of 1601. We need to match this internally |
112 // so that our time representations match across all platforms. See bug 14734. | 113 // so that our time representations match across all platforms. See bug 14734. |
113 // irb(main):010:0> Time.at(0).getutc() | 114 // irb(main):010:0> Time.at(0).getutc() |
114 // => Thu Jan 01 00:00:00 UTC 1970 | 115 // => Thu Jan 01 00:00:00 UTC 1970 |
115 // irb(main):011:0> Time.at(-11644473600).getutc() | 116 // irb(main):011:0> Time.at(-11644473600).getutc() |
116 // => Mon Jan 01 00:00:00 UTC 1601 | 117 // => Mon Jan 01 00:00:00 UTC 1601 |
117 static const int64 kWindowsEpochDeltaSeconds = GG_INT64_C(11644473600); | 118 static const int64 kWindowsEpochDeltaSeconds = INT64_C(11644473600); |
118 | 119 |
119 // static | 120 // static |
120 const int64 Time::kWindowsEpochDeltaMicroseconds = | 121 const int64 Time::kWindowsEpochDeltaMicroseconds = |
121 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; | 122 kWindowsEpochDeltaSeconds * Time::kMicrosecondsPerSecond; |
122 | 123 |
123 // Some functions in time.cc use time_t directly, so we provide an offset | 124 // Some functions in time.cc use time_t directly, so we provide an offset |
124 // to convert from time_t (Unix epoch) and internal (Windows epoch). | 125 // to convert from time_t (Unix epoch) and internal (Windows epoch). |
125 // static | 126 // static |
126 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; | 127 const int64 Time::kTimeTToMicrosecondsOffset = kWindowsEpochDeltaMicroseconds; |
127 | 128 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 TimeTicks TimeTicks::ThreadNow() { | 228 TimeTicks TimeTicks::ThreadNow() { |
228 return TimeTicks(ComputeThreadTicks()); | 229 return TimeTicks(ComputeThreadTicks()); |
229 } | 230 } |
230 | 231 |
231 // static | 232 // static |
232 TimeTicks TimeTicks::NowFromSystemTraceTime() { | 233 TimeTicks TimeTicks::NowFromSystemTraceTime() { |
233 return Now(); | 234 return Now(); |
234 } | 235 } |
235 | 236 |
236 } // namespace base | 237 } // namespace base |
OLD | NEW |