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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return us_ >= other.us_; | 403 return us_ >= other.us_; |
404 } | 404 } |
405 | 405 |
406 // Converts an integer value representing TimeClass to a class. This is used | 406 // Converts an integer value representing TimeClass to a class. This is used |
407 // when deserializing a |TimeClass| structure, using a value known to be | 407 // when deserializing a |TimeClass| structure, using a value known to be |
408 // compatible. It is not provided as a constructor because the integer type | 408 // compatible. It is not provided as a constructor because the integer type |
409 // may be unclear from the perspective of a caller. | 409 // may be unclear from the perspective of a caller. |
410 static TimeClass FromInternalValue(int64_t us) { return TimeClass(us); } | 410 static TimeClass FromInternalValue(int64_t us) { return TimeClass(us); } |
411 | 411 |
412 protected: | 412 protected: |
413 explicit TimeBase(int64_t us) : us_(us) {} | 413 constexpr explicit TimeBase(int64_t us) : us_(us) {} |
414 | 414 |
415 // Time value in a microsecond timebase. | 415 // Time value in a microsecond timebase. |
416 int64_t us_; | 416 int64_t us_; |
417 }; | 417 }; |
418 | 418 |
419 } // namespace time_internal | 419 } // namespace time_internal |
420 | 420 |
421 template<class TimeClass> | 421 template<class TimeClass> |
422 inline TimeClass operator+(TimeDelta delta, TimeClass t) { | 422 inline TimeClass operator+(TimeDelta delta, TimeClass t) { |
423 return t + delta; | 423 return t + delta; |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 // The underlying clock used to generate new TimeTicks. | 733 // The underlying clock used to generate new TimeTicks. |
734 enum class Clock { | 734 enum class Clock { |
735 FUCHSIA_MX_CLOCK_MONOTONIC, | 735 FUCHSIA_MX_CLOCK_MONOTONIC, |
736 LINUX_CLOCK_MONOTONIC, | 736 LINUX_CLOCK_MONOTONIC, |
737 IOS_CF_ABSOLUTE_TIME_MINUS_KERN_BOOTTIME, | 737 IOS_CF_ABSOLUTE_TIME_MINUS_KERN_BOOTTIME, |
738 MAC_MACH_ABSOLUTE_TIME, | 738 MAC_MACH_ABSOLUTE_TIME, |
739 WIN_QPC, | 739 WIN_QPC, |
740 WIN_ROLLOVER_PROTECTED_TIME_GET_TIME | 740 WIN_ROLLOVER_PROTECTED_TIME_GET_TIME |
741 }; | 741 }; |
742 | 742 |
743 TimeTicks() : TimeBase(0) { | 743 constexpr TimeTicks() : TimeBase(0) {} |
744 } | |
745 | 744 |
746 // Platform-dependent tick count representing "right now." When | 745 // Platform-dependent tick count representing "right now." When |
747 // IsHighResolution() returns false, the resolution of the clock could be | 746 // IsHighResolution() returns false, the resolution of the clock could be |
748 // as coarse as ~15.6ms. Otherwise, the resolution should be no worse than one | 747 // as coarse as ~15.6ms. Otherwise, the resolution should be no worse than one |
749 // microsecond. | 748 // microsecond. |
750 static TimeTicks Now(); | 749 static TimeTicks Now(); |
751 | 750 |
752 // Returns true if the high resolution clock is working on this system and | 751 // Returns true if the high resolution clock is working on this system and |
753 // Now() will return high resolution values. Note that, on systems where the | 752 // Now() will return high resolution values. Note that, on systems where the |
754 // high resolution clock works but is deemed inefficient, the low resolution | 753 // high resolution clock works but is deemed inefficient, the low resolution |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 static void WaitUntilInitializedWin(); | 882 static void WaitUntilInitializedWin(); |
884 #endif | 883 #endif |
885 }; | 884 }; |
886 | 885 |
887 // For logging use only. | 886 // For logging use only. |
888 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); | 887 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); |
889 | 888 |
890 } // namespace base | 889 } // namespace base |
891 | 890 |
892 #endif // BASE_TIME_TIME_H_ | 891 #endif // BASE_TIME_TIME_H_ |
OLD | NEW |