summaryrefslogtreecommitdiffstats
path: root/chromium/base/values.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-20 09:47:09 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-06-07 11:15:42 +0000
commit189d4fd8fad9e3c776873be51938cd31a42b6177 (patch)
tree6497caeff5e383937996768766ab3bb2081a40b2 /chromium/base/values.cc
parent8bc75099d364490b22f43a7ce366b366c08f4164 (diff)
BASELINE: Update Chromium to 90.0.4430.221
Change-Id: Iff4d9d18d2fcf1a576f3b1f453010f744a232920 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/values.cc')
-rw-r--r--chromium/base/values.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/chromium/base/values.cc b/chromium/base/values.cc
index 36b6436ac44..388bd76d97c 100644
--- a/chromium/base/values.cc
+++ b/chromium/base/values.cc
@@ -282,6 +282,26 @@ const char* Value::GetTypeName(Value::Type type) {
return kTypeNames[static_cast<size_t>(type)];
}
+Optional<bool> Value::GetIfBool() const {
+ return is_bool() ? make_optional(GetBool()) : nullopt;
+}
+
+Optional<int> Value::GetIfInt() const {
+ return is_int() ? make_optional(GetInt()) : nullopt;
+}
+
+Optional<double> Value::GetIfDouble() const {
+ return (is_int() || is_double()) ? make_optional(GetDouble()) : nullopt;
+}
+
+const std::string* Value::GetIfString() const {
+ return absl::get_if<std::string>(&data_);
+}
+
+const Value::BlobStorage* Value::GetIfBlob() const {
+ return absl::get_if<BlobStorage>(&data_);
+}
+
bool Value::GetBool() const {
return absl::get<bool>(data_);
}
@@ -996,6 +1016,12 @@ size_t Value::EstimateMemoryUsage() const {
}
}
+std::string Value::DebugString() const {
+ std::string json;
+ JSONWriter::WriteWithOptions(*this, JSONWriter::OPTIONS_PRETTY_PRINT, &json);
+ return json;
+}
+
Value* Value::SetKeyInternal(StringPiece key,
std::unique_ptr<Value>&& val_ptr) {
CHECK(is_dict());
@@ -1680,9 +1706,7 @@ ValueSerializer::~ValueSerializer() = default;
ValueDeserializer::~ValueDeserializer() = default;
std::ostream& operator<<(std::ostream& out, const Value& value) {
- std::string json;
- JSONWriter::WriteWithOptions(value, JSONWriter::OPTIONS_PRETTY_PRINT, &json);
- return out << json;
+ return out << value.DebugString();
}
std::ostream& operator<<(std::ostream& out, const Value::Type& type) {