Chromium Code Reviews| Index: cc/base/time_util.h | 
| diff --git a/cc/base/time_util.h b/cc/base/time_util.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..ed3203db54255655a6f24984fb40f686c5ae3a83 | 
| --- /dev/null | 
| +++ b/cc/base/time_util.h | 
| @@ -0,0 +1,32 @@ | 
| +// Copyright 2014 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef CC_BASE_TIME_UTIL_H_ | 
| +#define CC_BASE_TIME_UTIL_H_ | 
| + | 
| +#include <limits> | 
| +#include "base/time/time.h" | 
| + | 
| +namespace cc { | 
| + | 
| +class CC_EXPORT TimeUtil { | 
| + public: | 
| + 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.
 
 | 
| + if (time.ToInternalValue() == std::numeric_limits<int64>::max()) { | 
| + // Preserve max to prevent overflow. | 
| + return std::numeric_limits<int>::max(); | 
| + } | 
| + return static_cast<double>(time.ToInternalValue()) / | 
| + base::Time::kMicrosecondsPerSecond; | 
| + } | 
| + | 
| + static base::TimeTicks TicksFromSecondsF(double seconds) { | 
| + return base::TimeTicks::FromInternalValue( | 
| + seconds * base::Time::kMicrosecondsPerSecond); | 
| + } | 
| +}; | 
| + | 
| +} // namespace cc | 
| + | 
| +#endif // CC_BASE_TIME_UTIL_H_ |