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 // Time represents an absolute point in coordinated universal time (UTC), | 5 // Time represents an absolute point in coordinated universal time (UTC), |
6 // internally represented as microseconds (s/1,000,000) since the Windows epoch | 6 // internally represented as microseconds (s/1,000,000) since the Windows epoch |
7 // (1601-01-01 00:00:00 UTC). System-dependent clock interface routines are | 7 // (1601-01-01 00:00:00 UTC). System-dependent clock interface routines are |
8 // defined in time_PLATFORM.cc. Note that values for Time may skew and jump | 8 // defined in time_PLATFORM.cc. Note that values for Time may skew and jump |
9 // around as the operating system makes adjustments to synchronize (e.g., with | 9 // around as the operating system makes adjustments to synchronize (e.g., with |
10 // NTP servers). Thus, client code that uses the Time class must account for | 10 // NTP servers). Thus, client code that uses the Time class must account for |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 | 108 |
109 // Converts units of time to TimeDeltas. | 109 // Converts units of time to TimeDeltas. |
110 static constexpr TimeDelta FromDays(int days); | 110 static constexpr TimeDelta FromDays(int days); |
111 static constexpr TimeDelta FromHours(int hours); | 111 static constexpr TimeDelta FromHours(int hours); |
112 static constexpr TimeDelta FromMinutes(int minutes); | 112 static constexpr TimeDelta FromMinutes(int minutes); |
113 static constexpr TimeDelta FromSeconds(int64_t secs); | 113 static constexpr TimeDelta FromSeconds(int64_t secs); |
114 static constexpr TimeDelta FromMilliseconds(int64_t ms); | 114 static constexpr TimeDelta FromMilliseconds(int64_t ms); |
115 static constexpr TimeDelta FromSecondsD(double secs); | 115 static constexpr TimeDelta FromSecondsD(double secs); |
116 static constexpr TimeDelta FromMillisecondsD(double ms); | 116 static constexpr TimeDelta FromMillisecondsD(double ms); |
117 static constexpr TimeDelta FromMicroseconds(int64_t us); | 117 static constexpr TimeDelta FromMicroseconds(int64_t us); |
118 #if defined(OS_POSIX) | |
119 static TimeDelta FromTimeSpec(const timespec& ts); | |
120 #endif | |
118 #if defined(OS_WIN) | 121 #if defined(OS_WIN) |
119 static TimeDelta FromQPCValue(LONGLONG qpc_value); | 122 static TimeDelta FromQPCValue(LONGLONG qpc_value); |
120 #endif | 123 #endif |
121 | 124 |
122 // Converts an integer value representing TimeDelta to a class. This is used | 125 // Converts an integer value representing TimeDelta to a class. This is used |
123 // when deserializing a |TimeDelta| structure, using a value known to be | 126 // when deserializing a |TimeDelta| structure, using a value known to be |
124 // compatible. It is not provided as a constructor because the integer type | 127 // compatible. It is not provided as a constructor because the integer type |
125 // may be unclear from the perspective of a caller. | 128 // may be unclear from the perspective of a caller. |
126 static TimeDelta FromInternalValue(int64_t delta) { return TimeDelta(delta); } | 129 static TimeDelta FromInternalValue(int64_t delta) { return TimeDelta(delta); } |
127 | 130 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 // considered to have an ambiguous ordering.) | 728 // considered to have an ambiguous ordering.) |
726 static bool IsConsistentAcrossProcesses(); | 729 static bool IsConsistentAcrossProcesses(); |
727 | 730 |
728 #if defined(OS_WIN) | 731 #if defined(OS_WIN) |
729 // Translates an absolute QPC timestamp into a TimeTicks value. The returned | 732 // Translates an absolute QPC timestamp into a TimeTicks value. The returned |
730 // value has the same origin as Now(). Do NOT attempt to use this if | 733 // value has the same origin as Now(). Do NOT attempt to use this if |
731 // IsHighResolution() returns false. | 734 // IsHighResolution() returns false. |
732 static TimeTicks FromQPCValue(LONGLONG qpc_value); | 735 static TimeTicks FromQPCValue(LONGLONG qpc_value); |
733 #endif | 736 #endif |
734 | 737 |
738 #if defined(OS_MACOSX) | |
miu
2016/09/16 18:35:58
To prevent accidental use of this function on IOS:
jameswest
2016/09/19 23:32:36
Done.
| |
739 static TimeTicks FromMachAbsoluteTime(uint64_t mach_absolute_time); | |
740 #endif | |
741 | |
735 // Get an estimate of the TimeTick value at the time of the UnixEpoch. Because | 742 // Get an estimate of the TimeTick value at the time of the UnixEpoch. Because |
736 // Time and TimeTicks respond differently to user-set time and NTP | 743 // Time and TimeTicks respond differently to user-set time and NTP |
737 // adjustments, this number is only an estimate. Nevertheless, this can be | 744 // adjustments, this number is only an estimate. Nevertheless, this can be |
738 // useful when you need to relate the value of TimeTicks to a real time and | 745 // useful when you need to relate the value of TimeTicks to a real time and |
739 // date. Note: Upon first invocation, this function takes a snapshot of the | 746 // date. Note: Upon first invocation, this function takes a snapshot of the |
740 // realtime clock to establish a reference point. This function will return | 747 // realtime clock to establish a reference point. This function will return |
741 // the same value for the duration of the application, but will be different | 748 // the same value for the duration of the application, but will be different |
742 // in future application runs. | 749 // in future application runs. |
743 static TimeTicks UnixEpoch(); | 750 static TimeTicks UnixEpoch(); |
744 | 751 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 static void WaitUntilInitializedWin(); | 842 static void WaitUntilInitializedWin(); |
836 #endif | 843 #endif |
837 }; | 844 }; |
838 | 845 |
839 // For logging use only. | 846 // For logging use only. |
840 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); | 847 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); |
841 | 848 |
842 } // namespace base | 849 } // namespace base |
843 | 850 |
844 #endif // BASE_TIME_TIME_H_ | 851 #endif // BASE_TIME_TIME_H_ |
OLD | NEW |