| Index: base/time/time.cc
|
| diff --git a/base/time/time.cc b/base/time/time.cc
|
| index 53851fb18c5bc371080d8f074730a701ba57a5e5..76ffeb744112d1909afa9b488bcfa277950225bb 100644
|
| --- a/base/time/time.cc
|
| +++ b/base/time/time.cc
|
| @@ -12,8 +12,10 @@
|
|
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| +#include "base/macros.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/third_party/nspr/prtime.h"
|
| +#include "build/build_config.h"
|
|
|
| namespace base {
|
|
|
| @@ -21,7 +23,7 @@ namespace base {
|
|
|
| // static
|
| TimeDelta TimeDelta::Max() {
|
| - return TimeDelta(std::numeric_limits<int64>::max());
|
| + return TimeDelta(std::numeric_limits<int64_t>::max());
|
| }
|
|
|
| int TimeDelta::InDays() const {
|
| @@ -56,10 +58,10 @@ double TimeDelta::InSecondsF() const {
|
| return static_cast<double>(delta_) / Time::kMicrosecondsPerSecond;
|
| }
|
|
|
| -int64 TimeDelta::InSeconds() const {
|
| +int64_t TimeDelta::InSeconds() const {
|
| if (is_max()) {
|
| // Preserve max to prevent overflow.
|
| - return std::numeric_limits<int64>::max();
|
| + return std::numeric_limits<int64_t>::max();
|
| }
|
| return delta_ / Time::kMicrosecondsPerSecond;
|
| }
|
| @@ -72,46 +74,46 @@ double TimeDelta::InMillisecondsF() const {
|
| return static_cast<double>(delta_) / Time::kMicrosecondsPerMillisecond;
|
| }
|
|
|
| -int64 TimeDelta::InMilliseconds() const {
|
| +int64_t TimeDelta::InMilliseconds() const {
|
| if (is_max()) {
|
| // Preserve max to prevent overflow.
|
| - return std::numeric_limits<int64>::max();
|
| + return std::numeric_limits<int64_t>::max();
|
| }
|
| return delta_ / Time::kMicrosecondsPerMillisecond;
|
| }
|
|
|
| -int64 TimeDelta::InMillisecondsRoundedUp() const {
|
| +int64_t TimeDelta::InMillisecondsRoundedUp() const {
|
| if (is_max()) {
|
| // Preserve max to prevent overflow.
|
| - return std::numeric_limits<int64>::max();
|
| + return std::numeric_limits<int64_t>::max();
|
| }
|
| return (delta_ + Time::kMicrosecondsPerMillisecond - 1) /
|
| Time::kMicrosecondsPerMillisecond;
|
| }
|
|
|
| -int64 TimeDelta::InMicroseconds() const {
|
| +int64_t TimeDelta::InMicroseconds() const {
|
| if (is_max()) {
|
| // Preserve max to prevent overflow.
|
| - return std::numeric_limits<int64>::max();
|
| + return std::numeric_limits<int64_t>::max();
|
| }
|
| return delta_;
|
| }
|
|
|
| namespace time_internal {
|
|
|
| -int64 SaturatedAdd(TimeDelta delta, int64 value) {
|
| - CheckedNumeric<int64> rv(delta.delta_);
|
| +int64_t SaturatedAdd(TimeDelta delta, int64_t value) {
|
| + CheckedNumeric<int64_t> rv(delta.delta_);
|
| rv += value;
|
| return FromCheckedNumeric(rv);
|
| }
|
|
|
| -int64 SaturatedSub(TimeDelta delta, int64 value) {
|
| - CheckedNumeric<int64> rv(delta.delta_);
|
| +int64_t SaturatedSub(TimeDelta delta, int64_t value) {
|
| + CheckedNumeric<int64_t> rv(delta.delta_);
|
| rv -= value;
|
| return FromCheckedNumeric(rv);
|
| }
|
|
|
| -int64 FromCheckedNumeric(const CheckedNumeric<int64> value) {
|
| +int64_t FromCheckedNumeric(const CheckedNumeric<int64_t> value) {
|
| if (value.IsValid())
|
| return value.ValueUnsafe();
|
|
|
| @@ -119,7 +121,7 @@ int64 FromCheckedNumeric(const CheckedNumeric<int64> value) {
|
| // is. Instead, return max/(-max), which is something that clients can reason
|
| // about.
|
| // TODO(rvargas) crbug.com/332611: don't use internal values.
|
| - int64 limit = std::numeric_limits<int64>::max();
|
| + int64_t limit = std::numeric_limits<int64_t>::max();
|
| if (value.validity() == internal::RANGE_UNDERFLOW)
|
| limit = -limit;
|
| return value.ValueOrDefault(limit);
|
| @@ -135,7 +137,7 @@ std::ostream& operator<<(std::ostream& os, TimeDelta time_delta) {
|
|
|
| // static
|
| Time Time::Max() {
|
| - return Time(std::numeric_limits<int64>::max());
|
| + return Time(std::numeric_limits<int64_t>::max());
|
| }
|
|
|
| // static
|
| @@ -154,7 +156,7 @@ time_t Time::ToTimeT() const {
|
| // Preserve max without offset to prevent overflow.
|
| return std::numeric_limits<time_t>::max();
|
| }
|
| - if (std::numeric_limits<int64>::max() - kTimeTToMicrosecondsOffset <= us_) {
|
| + if (std::numeric_limits<int64_t>::max() - kTimeTToMicrosecondsOffset <= us_) {
|
| DLOG(WARNING) << "Overflow when converting base::Time with internal " <<
|
| "value " << us_ << " to time_t.";
|
| return std::numeric_limits<time_t>::max();
|
| @@ -210,14 +212,14 @@ double Time::ToJsTime() const {
|
| kMicrosecondsPerMillisecond);
|
| }
|
|
|
| -int64 Time::ToJavaTime() const {
|
| +int64_t Time::ToJavaTime() const {
|
| if (is_null()) {
|
| // Preserve 0 so the invalid result doesn't depend on the platform.
|
| return 0;
|
| }
|
| if (is_max()) {
|
| // Preserve max without offset to prevent overflow.
|
| - return std::numeric_limits<int64>::max();
|
| + return std::numeric_limits<int64_t>::max();
|
| }
|
| return ((us_ - kTimeTToMicrosecondsOffset) /
|
| kMicrosecondsPerMillisecond);
|
|
|