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 time, internally represented as | 5 // Time represents an absolute point in time, internally represented as |
6 // microseconds (s/1,000,000) since the Windows epoch (1601-01-01 00:00:00 UTC) | 6 // microseconds (s/1,000,000) since the Windows epoch (1601-01-01 00:00:00 UTC) |
7 // (See http://crbug.com/14734). System-dependent clock interface routines are | 7 // (See http://crbug.com/14734). System-dependent clock interface routines are |
8 // defined in time_PLATFORM.cc. | 8 // defined in time_PLATFORM.cc. |
9 // | 9 // |
10 // TimeDelta represents a duration of time, internally represented in | 10 // TimeDelta represents a duration of time, internally represented in |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 } | 597 } |
598 | 598 |
599 // Converts an integer value representing TimeTicks to a class. This is used | 599 // Converts an integer value representing TimeTicks to a class. This is used |
600 // when deserializing a |TimeTicks| structure, using a value known to be | 600 // when deserializing a |TimeTicks| structure, using a value known to be |
601 // compatible. It is not provided as a constructor because the integer type | 601 // compatible. It is not provided as a constructor because the integer type |
602 // may be unclear from the perspective of a caller. | 602 // may be unclear from the perspective of a caller. |
603 static TimeTicks FromInternalValue(int64 ticks) { | 603 static TimeTicks FromInternalValue(int64 ticks) { |
604 return TimeTicks(ticks); | 604 return TimeTicks(ticks); |
605 } | 605 } |
606 | 606 |
| 607 // Get the TimeTick value at the time of the UnixEpoch. This is useful when |
| 608 // you need to relate the value of TimeTicks to a real time and date. |
| 609 // Note: Upon first invocation, this function takes a snapshot of the realtime |
| 610 // clock to establish a reference point. This function will return the same |
| 611 // value for the duration of the application, but will be different in future |
| 612 // application runs. |
| 613 static TimeTicks UnixEpoch(); |
| 614 |
607 // Returns the internal numeric value of the TimeTicks object. | 615 // Returns the internal numeric value of the TimeTicks object. |
608 // For serializing, use FromInternalValue to reconstitute. | 616 // For serializing, use FromInternalValue to reconstitute. |
609 int64 ToInternalValue() const { | 617 int64 ToInternalValue() const { |
610 return ticks_; | 618 return ticks_; |
611 } | 619 } |
612 | 620 |
613 TimeTicks& operator=(TimeTicks other) { | 621 TimeTicks& operator=(TimeTicks other) { |
614 ticks_ = other.ticks_; | 622 ticks_ = other.ticks_; |
615 return *this; | 623 return *this; |
616 } | 624 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 #endif | 683 #endif |
676 }; | 684 }; |
677 | 685 |
678 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 686 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
679 return TimeTicks(t.ticks_ + delta_); | 687 return TimeTicks(t.ticks_ + delta_); |
680 } | 688 } |
681 | 689 |
682 } // namespace base | 690 } // namespace base |
683 | 691 |
684 #endif // BASE_TIME_TIME_H_ | 692 #endif // BASE_TIME_TIME_H_ |
OLD | NEW |