| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef WTF_Time_h | 5 #ifndef WTF_Time_h |
| 6 #define WTF_Time_h | 6 #define WTF_Time_h |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "wtf/CurrentTime.h" | 9 #include "wtf/CurrentTime.h" |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 double seconds = (WTF::getTimeFunctionForTesting())(); | 36 double seconds = (WTF::getTimeFunctionForTesting())(); |
| 37 return TimeWrapper() + TimeDelta::FromSecondsD(seconds); | 37 return TimeWrapper() + TimeDelta::FromSecondsD(seconds); |
| 38 } | 38 } |
| 39 return TimeWrapper(WrappedTimeType::Now()); | 39 return TimeWrapper(WrappedTimeType::Now()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 int64_t ToInternalValueForTesting() const { | 42 int64_t ToInternalValueForTesting() const { |
| 43 return m_value.ToInternalValue(); | 43 return m_value.ToInternalValue(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Only use this conversion when interfacing with legacy code that represents |
| 47 // time in double. Converting to double can lead to losing information for |
| 48 // large time values. |
| 49 double InSeconds() const { |
| 50 return (m_value - WrappedTimeType()).InSecondsF(); |
| 51 } |
| 52 |
| 53 static TimeWrapper FromSeconds(double seconds) { |
| 54 return WrappedTimeType() + TimeDelta::FromSecondsD(seconds); |
| 55 } |
| 56 |
| 46 TimeWrapper& operator=(TimeWrapper other) { | 57 TimeWrapper& operator=(TimeWrapper other) { |
| 47 m_value = other.m_value; | 58 m_value = other.m_value; |
| 48 return *this; | 59 return *this; |
| 49 } | 60 } |
| 50 | 61 |
| 51 TimeDelta operator-(TimeWrapper other) const { | 62 TimeDelta operator-(TimeWrapper other) const { |
| 52 return m_value - other.m_value; | 63 return m_value - other.m_value; |
| 53 } | 64 } |
| 54 | 65 |
| 55 TimeWrapper operator+(TimeDelta delta) const { | 66 TimeWrapper operator+(TimeDelta delta) const { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 85 using Time = internal::TimeWrapper<base::Time>; | 96 using Time = internal::TimeWrapper<base::Time>; |
| 86 using TimeTicks = internal::TimeWrapper<base::TimeTicks>; | 97 using TimeTicks = internal::TimeWrapper<base::TimeTicks>; |
| 87 | 98 |
| 88 } // namespace WTF | 99 } // namespace WTF |
| 89 | 100 |
| 90 using WTF::Time; | 101 using WTF::Time; |
| 91 using WTF::TimeDelta; | 102 using WTF::TimeDelta; |
| 92 using WTF::TimeTicks; | 103 using WTF::TimeTicks; |
| 93 | 104 |
| 94 #endif // Time_h | 105 #endif // Time_h |
| OLD | NEW |