Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: base/time/time.h

Issue 1782053004: Change how the quota system computes the total poolsize for temporary storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 // Converts an integer value representing TimeDelta to a class. This is used 127 // Converts an integer value representing TimeDelta to a class. This is used
128 // when deserializing a |TimeDelta| structure, using a value known to be 128 // when deserializing a |TimeDelta| structure, using a value known to be
129 // compatible. It is not provided as a constructor because the integer type 129 // compatible. It is not provided as a constructor because the integer type
130 // may be unclear from the perspective of a caller. 130 // may be unclear from the perspective of a caller.
131 static TimeDelta FromInternalValue(int64_t delta) { return TimeDelta(delta); } 131 static TimeDelta FromInternalValue(int64_t delta) { return TimeDelta(delta); }
132 132
133 // Returns the maximum time delta, which should be greater than any reasonable 133 // Returns the maximum time delta, which should be greater than any reasonable
134 // time delta we might compare it to. Adding or subtracting the maximum time 134 // time delta we might compare it to. Adding or subtracting the maximum time
135 // delta to a time or another time delta has an undefined result. 135 // delta to a time or another time delta has an undefined result.
136 static TimeDelta Max(); 136 static constexpr TimeDelta Max();
137 137
138 // Returns the internal numeric value of the TimeDelta object. Please don't 138 // Returns the internal numeric value of the TimeDelta object. Please don't
139 // use this and do arithmetic on it, as it is more error prone than using the 139 // use this and do arithmetic on it, as it is more error prone than using the
140 // provided operators. 140 // provided operators.
141 // For serializing, use FromInternalValue to reconstitute. 141 // For serializing, use FromInternalValue to reconstitute.
142 int64_t ToInternalValue() const { return delta_; } 142 int64_t ToInternalValue() const { return delta_; }
143 143
144 // Returns the magnitude (absolute value) of this TimeDelta. 144 // Returns the magnitude (absolute value) of this TimeDelta.
145 TimeDelta magnitude() const { 145 TimeDelta magnitude() const {
146 // Some toolchains provide an incomplete C++11 implementation and lack an 146 // Some toolchains provide an incomplete C++11 implementation and lack an
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 constexpr TimeDelta TimeDelta::FromMillisecondsD(double ms) { 655 constexpr TimeDelta TimeDelta::FromMillisecondsD(double ms) {
656 return FromDouble(ms * Time::kMicrosecondsPerMillisecond); 656 return FromDouble(ms * Time::kMicrosecondsPerMillisecond);
657 } 657 }
658 658
659 // static 659 // static
660 constexpr TimeDelta TimeDelta::FromMicroseconds(int64_t us) { 660 constexpr TimeDelta TimeDelta::FromMicroseconds(int64_t us) {
661 return TimeDelta(us); 661 return TimeDelta(us);
662 } 662 }
663 663
664 // static 664 // static
665 constexpr TimeDelta TimeDelta::Max() {
666 return TimeDelta(std::numeric_limits<int64_t>::max());
667 }
668
669 // static
665 constexpr TimeDelta TimeDelta::FromDouble(double value) { 670 constexpr TimeDelta TimeDelta::FromDouble(double value) {
666 // TODO(crbug.com/612601): Use saturated_cast<int64_t>(value) once we sort out 671 // TODO(crbug.com/612601): Use saturated_cast<int64_t>(value) once we sort out
667 // the Min() behavior. 672 // the Min() behavior.
668 return value > std::numeric_limits<int64_t>::max() 673 return value > std::numeric_limits<int64_t>::max()
669 ? Max() 674 ? Max()
670 : value < -std::numeric_limits<int64_t>::max() 675 : value < -std::numeric_limits<int64_t>::max()
671 ? -Max() 676 ? -Max()
672 : TimeDelta(static_cast<int64_t>(value)); 677 : TimeDelta(static_cast<int64_t>(value));
673 } 678 }
674 679
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 static void WaitUntilInitializedWin(); 847 static void WaitUntilInitializedWin();
843 #endif 848 #endif
844 }; 849 };
845 850
846 // For logging use only. 851 // For logging use only.
847 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); 852 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks);
848 853
849 } // namespace base 854 } // namespace base
850 855
851 #endif // BASE_TIME_TIME_H_ 856 #endif // BASE_TIME_TIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698