Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(741)

Unified Diff: components/tracing/core/proto_utils.h

Issue 2293073002: Tracing V2: Proto fields reflection. (Closed)
Patch Set: new one Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/tracing/core/proto_utils.h
diff --git a/components/tracing/core/proto_utils.h b/components/tracing/core/proto_utils.h
index fdadf1a18df0b98f0f269b23c02c978c659a78c0..1a67e3f67728ffda173b729acb5544404fcef194 100644
--- a/components/tracing/core/proto_utils.h
+++ b/components/tracing/core/proto_utils.h
@@ -24,6 +24,68 @@ enum : uint32_t {
kFieldTypeFixed32 = 5,
};
+class ProtoFieldDescriptor {
+ public:
+ enum Type {
+ TYPE_INVALID = 0,
+ TYPE_DOUBLE = 1,
+ TYPE_FLOAT = 2,
+ TYPE_INT64 = 3,
+ TYPE_UINT64 = 4,
+ TYPE_INT32 = 5,
+ TYPE_FIXED64 = 6,
+ TYPE_FIXED32 = 7,
+ TYPE_BOOL = 8,
+ TYPE_STRING = 9,
+ TYPE_MESSAGE = 11,
+ TYPE_BYTES = 12,
+ TYPE_UINT32 = 13,
+ TYPE_ENUM = 14,
+ TYPE_SFIXED32 = 15,
+ TYPE_SFIXED64 = 16,
+ TYPE_SINT32 = 17,
+ TYPE_SINT64 = 18,
+ // TYPE_GROUP = 10 is not supported.
picksi1 2016/09/01 16:38:39 Should this comment be put at the 'correct' place
+ };
+
+ ProtoFieldDescriptor(const char* name,
Primiano Tucci (use gerrit) 2016/09/01 16:18:06 is this git-cl formatted?
+ Type type,
+ uint32_t number,
+ bool is_repeated) : name_(name),
+ type_(type),
+ number_(number),
+ is_repeated_(is_repeated) {
+ }
+
+ const char* name() const {
+ return name_;
+ }
+
+ Type type() const {
+ return type_;
+ }
+
+ uint32_t number() const {
+ return number_;
+ }
+
+ bool is_repeated() const {
+ return is_repeated_;
+ }
+
+ bool is_valid() const {
+ return type_ != Type::TYPE_INVALID;
+ }
+
+ private:
+ const char* const name_;
+ const Type type_;
+ const uint32_t number_;
+ const bool is_repeated_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProtoFieldDescriptor);
+};
+
// Maximum message size supported: 256 MiB (4 x 7-bit due to varint encoding).
constexpr size_t kMessageLengthFieldSize = 4;
constexpr size_t kMaxMessageLength = (1u << (kMessageLengthFieldSize * 7)) - 1;

Powered by Google App Engine
This is Rietveld 408576698