#include "base/trace_event/traced_value.h"
#include <inttypes.h>
#include <stdint.h>
#include <atomic>
#include <string_view>
#include <utility>
#include "base/bits.h"
#include "base/containers/circular_deque.h"
#include "base/containers/span.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/pickle.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_impl.h"
#include "base/trace_event/trace_event_memory_overhead.h"
#include "base/trace_event/trace_log.h"
#include "base/values.h"
namespace base::trace_event {
namespace {
constexpr char kTypeStartDict = …;
constexpr char kTypeEndDict = …;
constexpr char kTypeStartArray = …;
constexpr char kTypeEndArray = …;
constexpr char kTypeBool = …;
constexpr char kTypeInt = …;
constexpr char kTypeDouble = …;
constexpr char kTypeString = …;
constexpr char kTypeCStr = …;
std::atomic<TracedValue::WriterFactoryCallback> g_writer_factory_callback;
#ifndef NDEBUG
constexpr bool kStackTypeDict = …;
constexpr bool kStackTypeArray = …;
#define DCHECK_CURRENT_CONTAINER_IS(x) …
#define DCHECK_CONTAINER_STACK_DEPTH_EQ(x) …
#define DEBUG_PUSH_CONTAINER(x) …
#define DEBUG_POP_CONTAINER() …
#else
#define DCHECK_CURRENT_CONTAINER_IS …
#define DCHECK_CONTAINER_STACK_DEPTH_EQ …
#define DEBUG_PUSH_CONTAINER …
#define DEBUG_POP_CONTAINER …
#endif
inline void WriteKeyNameAsRawPtr(Pickle& pickle, const char* ptr) { … }
inline void WriteKeyNameWithCopy(Pickle& pickle, std::string_view str) { … }
std::string ReadKeyName(PickleIterator& pickle_iterator) { … }
class PickleWriter final : public TracedValue::Writer { … };
std::unique_ptr<TracedValue::Writer> CreateWriter(size_t capacity) { … }
}
bool TracedValue::Writer::AppendToProto(ProtoAppender* appender) { … }
void TracedValue::SetWriterFactoryCallback(WriterFactoryCallback callback) { … }
TracedValue::TracedValue(size_t capacity)
: … { … }
TracedValue::TracedValue(size_t capacity, bool forced_json) { … }
TracedValue::~TracedValue() { … }
void TracedValue::SetInteger(const char* name, int value) { … }
void TracedValue::SetIntegerWithCopiedName(std::string_view name, int value) { … }
void TracedValue::SetDouble(const char* name, double value) { … }
void TracedValue::SetDoubleWithCopiedName(std::string_view name, double value) { … }
void TracedValue::SetBoolean(const char* name, bool value) { … }
void TracedValue::SetBooleanWithCopiedName(std::string_view name, bool value) { … }
void TracedValue::SetString(const char* name, std::string_view value) { … }
void TracedValue::SetStringWithCopiedName(std::string_view name,
std::string_view value) { … }
void TracedValue::SetValue(const char* name, TracedValue* value) { … }
void TracedValue::SetValueWithCopiedName(std::string_view name,
TracedValue* value) { … }
namespace {
std::string PointerToString(const void* value) { … }
}
void TracedValue::SetPointer(const char* name, const void* value) { … }
void TracedValue::SetPointerWithCopiedName(std::string_view name,
const void* value) { … }
void TracedValue::BeginDictionary(const char* name) { … }
void TracedValue::BeginDictionaryWithCopiedName(std::string_view name) { … }
void TracedValue::BeginArray(const char* name) { … }
void TracedValue::BeginArrayWithCopiedName(std::string_view name) { … }
void TracedValue::AppendInteger(int value) { … }
void TracedValue::AppendDouble(double value) { … }
void TracedValue::AppendBoolean(bool value) { … }
void TracedValue::AppendString(std::string_view value) { … }
void TracedValue::AppendPointer(const void* value) { … }
void TracedValue::BeginArray() { … }
void TracedValue::BeginDictionary() { … }
void TracedValue::EndArray() { … }
void TracedValue::EndDictionary() { … }
std::unique_ptr<base::Value> TracedValue::ToBaseValue() const { … }
void TracedValue::AppendAsTraceFormat(std::string* out) const { … }
bool TracedValue::AppendToProto(ProtoAppender* appender) const { … }
void TracedValue::EstimateTraceMemoryOverhead(
TraceEventMemoryOverhead* overhead) { … }
TracedValue::Array::Array(const std::initializer_list<ArrayItem> items) { … }
TracedValue::Array::Array(TracedValue::Array&& other) { … }
void TracedValue::Array::WriteToValue(TracedValue* value) const { … }
TracedValue::Dictionary::Dictionary(
const std::initializer_list<DictionaryItem> items) { … }
TracedValue::Dictionary::Dictionary(TracedValue::Dictionary&& other) { … }
void TracedValue::Dictionary::WriteToValue(TracedValue* value) const { … }
TracedValue::ValueHolder::ValueHolder(int value) { … }
TracedValue::ValueHolder::ValueHolder(double value) { … }
TracedValue::ValueHolder::ValueHolder(bool value) { … }
TracedValue::ValueHolder::ValueHolder(std::string_view value) { … }
TracedValue::ValueHolder::ValueHolder(std::string value) { … }
TracedValue::ValueHolder::ValueHolder(void* value) { … }
TracedValue::ValueHolder::ValueHolder(const char* value) { … }
TracedValue::ValueHolder::ValueHolder(TracedValue::Dictionary& value) { … }
TracedValue::ValueHolder::ValueHolder(TracedValue::Array& value) { … }
TracedValue::ValueHolder::ValueHolder(TracedValue::ValueHolder&& other) { … }
void TracedValue::ValueHolder::WriteToValue(TracedValue* value) const { … }
void TracedValue::ValueHolder::WriteToValue(const char* name,
TracedValue* value) const { … }
void TracedValue::ArrayItem::WriteToValue(TracedValue* value) const { … }
void TracedValue::DictionaryItem::WriteToValue(TracedValue* value) const { … }
std::unique_ptr<TracedValue> TracedValue::Build(
const std::initializer_list<DictionaryItem> items) { … }
std::string TracedValueJSON::ToJSON() const { … }
std::string TracedValueJSON::ToFormattedJSON() const { … }
TracedValue::ArrayScope::ArrayScope(TracedValue* value) : … { … }
TracedValue::ArrayScope::~ArrayScope() { … }
TracedValue::ArrayScope TracedValue::AppendArrayScoped() { … }
TracedValue::ArrayScope TracedValue::BeginArrayScoped(const char* name) { … }
TracedValue::ArrayScope TracedValue::BeginArrayScopedWithCopiedName(
std::string_view name) { … }
TracedValue::DictionaryScope::DictionaryScope(TracedValue* value)
: … { … }
TracedValue::DictionaryScope::~DictionaryScope() { … }
TracedValue::DictionaryScope TracedValue::AppendDictionaryScoped() { … }
TracedValue::DictionaryScope TracedValue::BeginDictionaryScoped(
const char* name) { … }
TracedValue::DictionaryScope TracedValue::BeginDictionaryScopedWithCopiedName(
std::string_view name) { … }
}