Chromium Code Reviews| 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..a2e2b72f3cbf956fb7a53b3d94f5d87d83e76886 100644 |
| --- a/components/tracing/core/proto_utils.h |
| +++ b/components/tracing/core/proto_utils.h |
| @@ -10,6 +10,7 @@ |
| #include <type_traits> |
| #include "base/logging.h" |
| +#include "components/tracing/tracing_export.h" |
| namespace tracing { |
| namespace v2 { |
| @@ -17,7 +18,7 @@ namespace proto { |
| // See https://developers.google.com/protocol-buffers/docs/encoding wire types. |
| -enum : uint32_t { |
| +enum FieldType : uint32_t { |
| kFieldTypeVarInt = 0, |
| kFieldTypeFixed64 = 1, |
| kFieldTypeLengthDelimited = 2, |
| @@ -94,6 +95,24 @@ void StaticAssertSingleBytePreamble() { |
| "Proto field id too big to fit in a single byte preamble"); |
| }; |
| +// Parses a VarInt. Supports both canonical and redundant encoding. |
| +// Returns a pointer to the next unconsumed byte, that is, one byte past the |
| +// end of the VarInt. |
| +TRACING_EXPORT const uint8_t* ParseVarInt(const uint8_t* start, |
| + const uint8_t* end, |
|
kraynov
2016/09/02 16:06:49
You use STL-style when defined ContinuousMemoryRan
Primiano Tucci (use gerrit)
2016/09/02 16:54:59
The same thing is here (unless I screwed something
|
| + uint64_t* value); |
| + |
| +// Parses a protobuf field, returning its id, type and value. |
| +// Returns a pointer to the next unconsumed byte (|start| < retval <= end). |
| +// In the case of a kFieldTypeLengthDelimited field, |field_intvalue| will |
| +// contain the field payload (either a string or a nested message) and the |
| +// return value will point to the first byte of the field payload. |
| +TRACING_EXPORT const uint8_t* ParseField(const uint8_t* start, |
| + const uint8_t* end, |
| + uint32_t* field_id, |
| + FieldType* field_type, |
| + uint64_t* field_intvalue); |
| + |
| } // namespace proto |
| } // namespace v2 |
| } // namespace tracing |