| Index: third_party/libaddressinput/chromium/cpp/src/validating_util.cc
|
| diff --git a/third_party/libaddressinput/chromium/cpp/src/validating_util.cc b/third_party/libaddressinput/chromium/cpp/src/validating_util.cc
|
| index 7f225c6500e3a6c9263522b4b04e2d647a03078e..a283a45bf4e263014c6a7d45fc7decb5217b7204 100644
|
| --- a/third_party/libaddressinput/chromium/cpp/src/validating_util.cc
|
| +++ b/third_party/libaddressinput/chromium/cpp/src/validating_util.cc
|
| @@ -104,21 +104,28 @@ std::string ValidatingUtil::Wrap(const std::string& data, time_t timestamp) {
|
| }
|
|
|
| // static
|
| -bool ValidatingUtil::UnwrapTimestamp(std::string* data, time_t now) {
|
| +ValidatingUtil::TimestampStatus ValidatingUtil::UnwrapTimestamp(
|
| + std::string* data,
|
| + time_t now) {
|
| assert(data != NULL);
|
| if (now < 0) {
|
| - return false;
|
| + return TIMESTAMP_INVALID;
|
| }
|
|
|
| std::string timestamp_string;
|
| if (!UnwrapHeader(
|
| kTimestampPrefix, kTimestampPrefixLength, data, ×tamp_string)) {
|
| - return false;
|
| + return TIMESTAMP_INVALID;
|
| }
|
|
|
| time_t timestamp = atol(timestamp_string.c_str());
|
| if (timestamp < 0) {
|
| - return false;
|
| + return TIMESTAMP_INVALID;
|
| + }
|
| +
|
| + double age_in_seconds = difftime(now, timestamp);
|
| + if (age_in_seconds < 0.0) {
|
| + return TIMESTAMP_INVALID;
|
| }
|
|
|
| // One month contains:
|
| @@ -127,8 +134,8 @@ bool ValidatingUtil::UnwrapTimestamp(std::string* data, time_t now) {
|
| // 60 minutes per hour *
|
| // 60 seconds per minute.
|
| static const double kOneMonthInSeconds = 30.0 * 24.0 * 60.0 * 60.0;
|
| - double age_in_seconds = difftime(now, timestamp);
|
| - return !(age_in_seconds < 0.0) && age_in_seconds < kOneMonthInSeconds;
|
| + return age_in_seconds < kOneMonthInSeconds ? TIMESTAMP_VALID
|
| + : TIMESTAMP_STALE;
|
| }
|
|
|
| // static
|
|
|