Chromium Code Reviews| Index: third_party/libaddressinput/chromium/cpp/src/validating_util.h |
| diff --git a/third_party/libaddressinput/chromium/cpp/src/validating_util.h b/third_party/libaddressinput/chromium/cpp/src/validating_util.h |
| index 8a9b532df9eb83b2acb114ca79f2ffa0a83317f2..b68391568a51a1c38a9d46394f348ae7a6d323d0 100644 |
| --- a/third_party/libaddressinput/chromium/cpp/src/validating_util.h |
| +++ b/third_party/libaddressinput/chromium/cpp/src/validating_util.h |
| @@ -31,21 +31,34 @@ namespace addressinput { |
| // Process(wrapped); |
| // |
| // std::string unwrapped = wrapped; |
| -// if (ValidatingUtil::UnwrapTimestamp(&unwrapped, time(NULL)) && |
| +// if (ValidatingUtil::TIMESTAMP_VALID == |
| +// ValidatingUtil::UnwrapTimestamp(&unwrapped, time(NULL)) && |
| // ValidatingUtil::UnwrapChecksum(&unwrapped)) { |
| // Process(unwrapped); |
| // } |
| class ValidatingUtil { |
| public: |
| + // Result of parsing and validating a timestamp. |
| + enum TimestampStatus { |
| + // The timestamp is present, formatted correctly, valid, and recent. |
| + TIMESTAMP_VALID, |
| + |
| + // The timestamp is either missing, incorrectly formatted, or invalid. |
| + TIMESTAMP_INVALID, |
| + |
| + // The timestamp is present, formatted correctly, and valid, but stale. |
| + TIMESTAMP_STALE |
| + }; |
| + |
| // Returns |data| with attached checksum and given |timestamp|. |
| static std::string Wrap(const std::string& data, time_t timestamp); |
| - // Strips out the timestamp from |data|. Returns |true| if the timestamp is |
| - // present, formatted correctly, valid, and recent with respect to |now|. |
| - static bool UnwrapTimestamp(std::string* data, time_t now); |
| + // Strips out the timestamp from |data| and validates it with respect to |
| + // |now|. |
| + static TimestampStatus UnwrapTimestamp(std::string* data, time_t now); |
|
Evan Stade
2014/01/22 01:42:12
I think that UnwrapTimestamp and UnwrapChecksum sh
please use gerrit instead
2014/01/22 23:57:41
Refactored into:
std::string Wrapper::Wrap(const
Evan Stade
2014/01/23 00:07:23
why is double a better way of representing time th
please use gerrit instead
2014/01/23 00:09:00
The difference between two time_t objects is alway
|
| - // Strips out the checksum from |data|. Returns |true| if the checksum is |
| - // present, formatted correctly, and valid for this data. |
| + // Strips out and validates the checksum from |data|. Returns |true| if the |
| + // checksum is present, formatted correctly, and valid for this data. |
| static bool UnwrapChecksum(std::string* data); |
| }; |