OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_BASE_TIME_UTIL_H_ | |
6 #define CC_BASE_TIME_UTIL_H_ | |
7 | |
8 #include <limits> | |
9 #include "base/time/time.h" | |
10 | |
11 namespace cc { | |
12 | |
13 class CC_EXPORT TimeUtil { | |
14 public: | |
15 static double TicksInSecondsF(base::TimeTicks time) { | |
ajuma
2014/05/05 15:13:32
A previous CL that added similar functions was rej
Sikugu_
2014/05/07 14:49:07
Done.
| |
16 if (time.ToInternalValue() == std::numeric_limits<int64>::max()) { | |
17 // Preserve max to prevent overflow. | |
18 return std::numeric_limits<int>::max(); | |
19 } | |
20 return static_cast<double>(time.ToInternalValue()) / | |
21 base::Time::kMicrosecondsPerSecond; | |
22 } | |
23 | |
24 static base::TimeTicks TicksFromSecondsF(double seconds) { | |
25 return base::TimeTicks::FromInternalValue( | |
26 seconds * base::Time::kMicrosecondsPerSecond); | |
27 } | |
28 }; | |
29 | |
30 } // namespace cc | |
31 | |
32 #endif // CC_BASE_TIME_UTIL_H_ | |
OLD | NEW |