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

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

Issue 2293073002: Tracing V2: Proto fields reflection. (Closed)
Patch Set: nit Created 4 years, 3 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
« no previous file with comments | « no previous file | components/tracing/test/proto_zero_generation_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4ac93bb4d3d3b85eb0a9adea72f2e0c003281645 100644
--- a/components/tracing/core/proto_utils.h
+++ b/components/tracing/core/proto_utils.h
@@ -24,6 +24,66 @@ 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_GROUP = 10 is not supported.
+ TYPE_BYTES = 12,
+ TYPE_UINT32 = 13,
+ TYPE_ENUM = 14,
+ TYPE_SFIXED32 = 15,
+ TYPE_SFIXED64 = 16,
+ TYPE_SINT32 = 17,
+ TYPE_SINT64 = 18,
+ };
+
+ ProtoFieldDescriptor(const char* name,
+ 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;
« no previous file with comments | « no previous file | components/tracing/test/proto_zero_generation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698