| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 using TimeDelta = base::TimeDelta; | 23 using TimeDelta = base::TimeDelta; |
| 24 | 24 |
| 25 namespace internal { | 25 namespace internal { |
| 26 | 26 |
| 27 template <class WrappedTimeType> | 27 template <class WrappedTimeType> |
| 28 class TimeWrapper { | 28 class TimeWrapper { |
| 29 public: | 29 public: |
| 30 TimeWrapper() {} | 30 TimeWrapper() {} |
| 31 | 31 |
| 32 bool isNull() const { return m_value.is_null(); } | |
| 33 | |
| 34 static TimeWrapper Now() { | 32 static TimeWrapper Now() { |
| 35 if (WTF::getTimeFunctionForTesting()) { | 33 if (WTF::getTimeFunctionForTesting()) { |
| 36 double seconds = (WTF::getTimeFunctionForTesting())(); | 34 double seconds = (WTF::getTimeFunctionForTesting())(); |
| 37 return TimeWrapper() + TimeDelta::FromSecondsD(seconds); | 35 return TimeWrapper() + TimeDelta::FromSecondsD(seconds); |
| 38 } | 36 } |
| 39 return TimeWrapper(WrappedTimeType::Now()); | 37 return TimeWrapper(WrappedTimeType::Now()); |
| 40 } | 38 } |
| 41 | 39 |
| 42 int64_t ToInternalValueForTesting() const { | 40 int64_t ToInternalValueForTesting() const { |
| 43 return m_value.ToInternalValue(); | 41 return m_value.ToInternalValue(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 using Time = internal::TimeWrapper<base::Time>; | 94 using Time = internal::TimeWrapper<base::Time>; |
| 97 using TimeTicks = internal::TimeWrapper<base::TimeTicks>; | 95 using TimeTicks = internal::TimeWrapper<base::TimeTicks>; |
| 98 | 96 |
| 99 } // namespace WTF | 97 } // namespace WTF |
| 100 | 98 |
| 101 using WTF::Time; | 99 using WTF::Time; |
| 102 using WTF::TimeDelta; | 100 using WTF::TimeDelta; |
| 103 using WTF::TimeTicks; | 101 using WTF::TimeTicks; |
| 104 | 102 |
| 105 #endif // Time_h | 103 #endif // Time_h |
| OLD | NEW |