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

Unified Diff: base/time/time.h

Issue 949613002: [Android] Add animation frame time histogram class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: base/time/time.h
diff --git a/base/time/time.h b/base/time/time.h
index 18de085e341714b85efe6e10a988835601bf998e..0cb729aaceb20e46ed9b4f27c687e3bb825fe0bf 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -75,6 +75,7 @@ class BASE_EXPORT TimeDelta {
static TimeDelta FromSecondsD(double secs);
static TimeDelta FromMillisecondsD(double ms);
static TimeDelta FromMicroseconds(int64 us);
+ static TimeDelta FromNanoseconds(int64 ns);
#if defined(OS_WIN)
static TimeDelta FromQPCValue(LONGLONG qpc_value);
#endif
@@ -575,6 +576,14 @@ inline TimeDelta TimeDelta::FromMicroseconds(int64 us) {
return TimeDelta(us);
}
+// static
+inline TimeDelta TimeDelta::FromNanoseconds(int64 ns) {
+ // Preserve max to prevent overflow.
+ if (ns == std::numeric_limits<int64>::max())
+ return Max();
+ return TimeDelta(ns / Time::kNanosecondsPerMicrosecond);
+}
+
inline Time TimeDelta::operator+(Time t) const {
return Time(t.us_ + delta_);
}

Powered by Google App Engine
This is Rietveld 408576698