diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/base/util/values/values_util.h | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/util/values/values_util.h')
-rw-r--r-- | chromium/base/util/values/values_util.h | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/chromium/base/util/values/values_util.h b/chromium/base/util/values/values_util.h index de9fd1b9dc4..2958ae01405 100644 --- a/chromium/base/util/values/values_util.h +++ b/chromium/base/util/values/values_util.h @@ -6,31 +6,57 @@ #define BASE_UTIL_VALUES_VALUES_UTIL_H_ #include "base/optional.h" -#include "base/time/time.h" #include "base/values.h" +namespace base { +class FilePath; +class Time; +class TimeDelta; +class UnguessableToken; +} // namespace base + namespace util { -// Simple helper functions for converting int64_t, base::TimeDelta and -// base::Time to numeric string base::Values. -// Because base::TimeDelta and base::Time share the same internal representation -// as int64_t they are stored using the exact same numeric string format. +// Simple helper functions for converting between base::Value and other types. +// The base::Value representation is stable, suitable for persistent storage +// e.g. as JSON on disk. +// +// It is valid to pass nullptr to the ValueToEtc functions. They will just +// return base::nullopt. -// Stores the int64_t as a string. +// Converts between an int64_t and a string-flavored base::Value (a human +// readable string of that number). base::Value Int64ToValue(int64_t integer); base::Optional<int64_t> ValueToInt64(const base::Value* value); base::Optional<int64_t> ValueToInt64(const base::Value& value); -// Converts the TimeDelta to an int64_t of microseconds. +// Converts between a base::TimeDelta (an int64_t number of microseconds) and a +// string-flavored base::Value (a human readable string of that number). base::Value TimeDeltaToValue(base::TimeDelta time_delta); base::Optional<base::TimeDelta> ValueToTimeDelta(const base::Value* value); base::Optional<base::TimeDelta> ValueToTimeDelta(const base::Value& value); -// Converts the Time to a TimeDelta from the Windows epoch. +// Converts between a base::Time (an int64_t number of microseconds since the +// Windows epoch) and a string-flavored base::Value (a human readable string of +// that number). base::Value TimeToValue(base::Time time); base::Optional<base::Time> ValueToTime(const base::Value* value); base::Optional<base::Time> ValueToTime(const base::Value& value); +// Converts between a base::FilePath (a std::string or base::string16) and a +// string-flavored base::Value (the UTF-8 representation). +base::Value FilePathToValue(base::FilePath file_path); +base::Optional<base::FilePath> ValueToFilePath(const base::Value* value); +base::Optional<base::FilePath> ValueToFilePath(const base::Value& value); + +// Converts between a base::UnguessableToken (128 bits) and a string-flavored +// base::Value (32 hexadecimal digits). +base::Value UnguessableTokenToValue(base::UnguessableToken token); +base::Optional<base::UnguessableToken> ValueToUnguessableToken( + const base::Value* value); +base::Optional<base::UnguessableToken> ValueToUnguessableToken( + const base::Value& value); + } // namespace util #endif // BASE_UTIL_VALUES_VALUES_UTIL_H_ |