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

Unified Diff: cc/base/time_util.h

Issue 231133002: CC::Animations should use TimeTicks & TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review changes. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698