Index: base/time/time.h |
diff --git a/base/time/time.h b/base/time/time.h |
index 69a132431d6597514e44191a04db8bf461fb2c40..546920b2e92cac257663e7256da8cfa662f803f2 100644 |
--- a/base/time/time.h |
+++ b/base/time/time.h |
@@ -66,6 +66,8 @@ class BASE_EXPORT TimeDelta { |
static TimeDelta FromMinutes(int minutes); |
static TimeDelta FromSeconds(int64 secs); |
static TimeDelta FromMilliseconds(int64 ms); |
+ static TimeDelta FromSecondsD(double secs); |
+ static TimeDelta FromMillisecondsD(double ms); |
static TimeDelta FromMicroseconds(int64 us); |
#if defined(OS_WIN) |
static TimeDelta FromQPCValue(LONGLONG qpc_value); |
@@ -543,6 +545,22 @@ inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) { |
} |
// static |
+inline TimeDelta TimeDelta::FromSecondsD(double secs) { |
+ // Preserve max to prevent overflow. |
+ if (secs == std::numeric_limits<double>::infinity()) |
+ return Max(); |
+ return TimeDelta(secs * Time::kMicrosecondsPerSecond); |
+} |
+ |
+// static |
+inline TimeDelta TimeDelta::FromMillisecondsD(double ms) { |
+ // Preserve max to prevent overflow. |
+ if (ms == std::numeric_limits<double>::infinity()) |
+ return Max(); |
+ return TimeDelta(ms * Time::kMicrosecondsPerMillisecond); |
+} |
+ |
+// static |
inline TimeDelta TimeDelta::FromMicroseconds(int64 us) { |
// Preserve max to prevent overflow. |
if (us == std::numeric_limits<int64>::max()) |