| Index: base/time_posix.cc
|
| diff --git a/base/time_posix.cc b/base/time_posix.cc
|
| index c74cae5d15230377a01eabb7f5d85d05dbe58e73..c79781c3cf58d07c3d7ed4a6fc6094d59fae4fe2 100644
|
| --- a/base/time_posix.cc
|
| +++ b/base/time_posix.cc
|
| @@ -266,6 +266,11 @@ TimeTicks TimeTicks::NowFromSystemTraceTime() {
|
| Time Time::FromTimeVal(struct timeval t) {
|
| DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond));
|
| DCHECK_GE(t.tv_usec, 0);
|
| + if (t.tv_usec == 0 && t.tv_sec == 0)
|
| + return Time();
|
| + if (t.tv_usec == static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1 &&
|
| + t.tv_sec == std::numeric_limits<time_t>::max())
|
| + return Max();
|
| return Time(
|
| (static_cast<int64>(t.tv_sec) * Time::kMicrosecondsPerSecond) +
|
| t.tv_usec +
|
| @@ -274,6 +279,16 @@ Time Time::FromTimeVal(struct timeval t) {
|
|
|
| struct timeval Time::ToTimeVal() const {
|
| struct timeval result;
|
| + if (is_null()) {
|
| + result.tv_sec = 0;
|
| + result.tv_usec = 0;
|
| + return result;
|
| + }
|
| + if (is_max()) {
|
| + result.tv_sec = std::numeric_limits<time_t>::max();
|
| + result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
|
| + return result;
|
| + }
|
| int64 us = us_ - kTimeTToMicrosecondsOffset;
|
| result.tv_sec = us / Time::kMicrosecondsPerSecond;
|
| result.tv_usec = us % Time::kMicrosecondsPerSecond;
|
|
|