Skip to content

Commit

Permalink
Wrap base::Value::{Dict,List}}:WriteIntoTrace() with correct #ifs.
Browse files Browse the repository at this point in the history
  • Loading branch information
klzgrad committed Aug 6, 2022
1 parent e88e600 commit 3555c20
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/base/values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -789,12 +789,14 @@ std::string Value::Dict::DebugString() const {
return DebugStringImpl(*this);
}

#if BUILDFLAG(ENABLE_BASE_TRACING)
void Value::Dict::WriteIntoTrace(perfetto::TracedValue context) const {
perfetto::TracedDictionary dict = std::move(context).WriteDictionary();
for (auto kv : *this) {
dict.Add(perfetto::DynamicString(kv.first), kv.second);
}
}
#endif // BUILDFLAG(ENABLE_BASE_TRACING)

Value::Dict::Dict(
const flat_map<std::string, std::unique_ptr<Value>>& storage) {
Expand Down Expand Up @@ -999,12 +1001,14 @@ std::string Value::List::DebugString() const {
return DebugStringImpl(*this);
}

#if BUILDFLAG(ENABLE_BASE_TRACING)
void Value::List::WriteIntoTrace(perfetto::TracedValue context) const {
perfetto::TracedArray array = std::move(context).WriteArray();
for (const auto& item : *this) {
array.Append(item);
}
}
#endif // BUILDFLAG(ENABLE_BASE_TRACING)

Value::List::List(const std::vector<Value>& storage) {
storage_.reserve(storage.size());
Expand Down

0 comments on commit 3555c20

Please sign in to comment.