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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 } | 635 } |
636 | 636 |
637 // For logging use only. | 637 // For logging use only. |
638 BASE_EXPORT std::ostream& operator<<(std::ostream& os, Time time); | 638 BASE_EXPORT std::ostream& operator<<(std::ostream& os, Time time); |
639 | 639 |
640 // TimeTicks ------------------------------------------------------------------ | 640 // TimeTicks ------------------------------------------------------------------ |
641 | 641 |
642 // Represents monotonically non-decreasing clock time. | 642 // Represents monotonically non-decreasing clock time. |
643 class BASE_EXPORT TimeTicks : public time_internal::TimeBase<TimeTicks> { | 643 class BASE_EXPORT TimeTicks : public time_internal::TimeBase<TimeTicks> { |
644 public: | 644 public: |
645 // The underlying clock used to generate new TimeTicks. | |
646 enum class Clock { | |
647 UNKNOWN, | |
danakj
2016/03/30 19:51:58
Not sure that you really need the UNKNOWN here. It
charliea (OOO until 10-5)
2016/03/30 20:07:44
Done.
| |
648 LINUX_CLOCK_MONOTONIC, | |
649 IOS_CF_ABSOLUTE_TIME_MINUS_KERN_BOOTTIME, | |
650 MAC_MACH_ABSOLUTE_TIME, | |
651 WIN_QPC, | |
652 WIN_ROLLOVER_PROTECTED_TIME_GET_TIME | |
653 }; | |
654 | |
645 TimeTicks() : TimeBase(0) { | 655 TimeTicks() : TimeBase(0) { |
646 } | 656 } |
647 | 657 |
648 // Platform-dependent tick count representing "right now." When | 658 // Platform-dependent tick count representing "right now." When |
649 // IsHighResolution() returns false, the resolution of the clock could be | 659 // IsHighResolution() returns false, the resolution of the clock could be |
650 // as coarse as ~15.6ms. Otherwise, the resolution should be no worse than one | 660 // as coarse as ~15.6ms. Otherwise, the resolution should be no worse than one |
651 // microsecond. | 661 // microsecond. |
652 static TimeTicks Now(); | 662 static TimeTicks Now(); |
653 | 663 |
654 // Returns true if the high resolution clock is working on this system and | 664 // Returns true if the high resolution clock is working on this system and |
(...skipping 18 matching lines...) Expand all Loading... | |
673 // the same value for the duration of the application, but will be different | 683 // the same value for the duration of the application, but will be different |
674 // in future application runs. | 684 // in future application runs. |
675 static TimeTicks UnixEpoch(); | 685 static TimeTicks UnixEpoch(); |
676 | 686 |
677 // Returns |this| snapped to the next tick, given a |tick_phase| and | 687 // Returns |this| snapped to the next tick, given a |tick_phase| and |
678 // repeating |tick_interval| in both directions. |this| may be before, | 688 // repeating |tick_interval| in both directions. |this| may be before, |
679 // after, or equal to the |tick_phase|. | 689 // after, or equal to the |tick_phase|. |
680 TimeTicks SnappedToNextTick(TimeTicks tick_phase, | 690 TimeTicks SnappedToNextTick(TimeTicks tick_phase, |
681 TimeDelta tick_interval) const; | 691 TimeDelta tick_interval) const; |
682 | 692 |
693 // Returns an enum indicating the underlying clock being used to generate | |
694 // TimeTicks timestamps. This function should only be used for debugging and | |
695 // logging purposes. | |
696 static Clock GetClock(); | |
697 | |
683 #if defined(OS_WIN) | 698 #if defined(OS_WIN) |
684 protected: | 699 protected: |
685 typedef DWORD (*TickFunctionType)(void); | 700 typedef DWORD (*TickFunctionType)(void); |
686 static TickFunctionType SetMockTickFunction(TickFunctionType ticker); | 701 static TickFunctionType SetMockTickFunction(TickFunctionType ticker); |
687 #endif | 702 #endif |
688 | 703 |
689 private: | 704 private: |
690 friend class time_internal::TimeBase<TimeTicks>; | 705 friend class time_internal::TimeBase<TimeTicks>; |
691 | 706 |
692 // Please use Now() to create a new object. This is for internal use | 707 // Please use Now() to create a new object. This is for internal use |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 static void WaitUntilInitializedWin(); | 770 static void WaitUntilInitializedWin(); |
756 #endif | 771 #endif |
757 }; | 772 }; |
758 | 773 |
759 // For logging use only. | 774 // For logging use only. |
760 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); | 775 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); |
761 | 776 |
762 } // namespace base | 777 } // namespace base |
763 | 778 |
764 #endif // BASE_TIME_TIME_H_ | 779 #endif // BASE_TIME_TIME_H_ |
OLD | NEW |