| 6 | #define BASE_UTIL_VALUES_VALUES_UTIL_H_ |
| 7 |
| 8 | #include "base/optional.h" |
| 9 | #include "base/time/time.h" |
| 10 | #include "base/values.h" |
| 11 |
| 12 | namespace util { |
| 13 |
| 14 | // Simple helper functions for converting int64_t, base::TimeDelta and |
| 15 | // base::Time to numeric string base::Values. |
| 16 | // Because base::TimeDelta and base::Time share the same internal representation |
| 17 | // as int64_t they are stored using the exact same numeric string format. |
| 18 |
| 19 | // Stores the int64_t as a string. |
| 20 | base::Value Int64ToValue(int64_t integer); |
| 21 | base::Optional<int64_t> ValueToInt64(const base::Value* value); |
| 22 | base::Optional<int64_t> ValueToInt64(const base::Value& value); |
| 23 |
| 24 | // Converts the TimeDelta to an int64_t of microseconds. |
| 25 | base::Value TimeDeltaToValue(base::TimeDelta time_delta); |
| 26 | base::Optional<base::TimeDelta> ValueToTimeDelta(const base::Value* value); |
| 27 | base::Optional<base::TimeDelta> ValueToTimeDelta(const base::Value& value); |
| 28 |
| 29 | // Converts the Time to a TimeDelta from the Windows epoch. |
| 30 | base::Value TimeToValue(base::Time time); |
| 31 | base::Optional<base::Time> ValueToTime(const base::Value* value); |
| 32 | base::Optional<base::Time> ValueToTime(const base::Value& value); |
| 33 |
| 34 | } // namespace util |
| 35 |
| 36 | #endif // BASE_UTIL_VALUES_VALUES_UTIL_H_ |
| 37 |