Chromium Code Reviews| Index: components/tracing/core/proto_zero_message.h |
| diff --git a/components/tracing/core/proto_zero_message.h b/components/tracing/core/proto_zero_message.h |
| index 7f6509387c4289a9fc947dd955c4e7a2ae5cda0b..0b55355f7e5caec1d2e5fecb20303dfecc9e7c75 100644 |
| --- a/components/tracing/core/proto_zero_message.h |
| +++ b/components/tracing/core/proto_zero_message.h |
| @@ -21,12 +21,17 @@ |
| namespace tracing { |
| namespace v2 { |
| +class ProtoZeroMessageHandleBase; |
| + |
| // Base class extended by the proto C++ stubs generated by the ProtoZero |
| // compiler (see //components/tracing/tools/). This class provides the minimal |
| // runtime required to support append-only operations and is desiged for |
| // performance. None of the methods require any dynamic memory allocation. |
| class TRACING_EXPORT ProtoZeroMessage { |
| public: |
| + // Clears up the state, allowing the message to be reused as a fresh one. |
| + void Reset(ScatteredStreamWriter*); |
| + |
| // Commits all the changes to the buffer (backfills the size field of this and |
| // all nested messages) and seals the message. Returns the size of the message |
| // (and all nested sub-messages), without taking into account any chunking. |
| @@ -48,12 +53,16 @@ class TRACING_EXPORT ProtoZeroMessage { |
| // partial size that lies in the last chunk has to be backfilled. |
| void inc_size_already_written(size_t size) { size_already_written_ += size; } |
| + // Only for ProtoZeroMessageHandleBase. |
| + void set_handle(ProtoZeroMessageHandleBase* handle) { |
|
oystein (OOO til 10th of July)
2016/07/20 21:19:37
Maybe wrap the whole function in DCHECK_IS_ON(), s
Primiano Tucci (use gerrit)
2016/07/21 10:50:03
Done.
|
| +#if DCHECK_IS_ON() |
| + handle_ = handle; |
| +#endif |
| + } |
| + |
| protected: |
| ProtoZeroMessage(); |
| - // Clears up the state, allowing the message to be reused as a fresh one. |
| - void Reset(ScatteredStreamWriter*); |
| - |
| void AppendVarIntU64(uint32_t field_id, uint64_t value); |
| void AppendVarIntU32(uint32_t field_id, uint32_t value); |
| void AppendFloat(uint32_t field_id, float value); |
| @@ -87,6 +96,7 @@ class TRACING_EXPORT ProtoZeroMessage { |
| FRIEND_TEST_ALL_PREFIXES(ProtoZeroMessageTest, BackfillSizeOnFinalization); |
| FRIEND_TEST_ALL_PREFIXES(ProtoZeroMessageTest, NestedMessagesSimple); |
| FRIEND_TEST_ALL_PREFIXES(ProtoZeroMessageTest, StressTest); |
| + FRIEND_TEST_ALL_PREFIXES(ProtoZeroMessageTest, MessageHandle); |
| enum : uint32_t { kMaxNestingDepth = 8 }; |
| @@ -125,6 +135,8 @@ class TRACING_EXPORT ProtoZeroMessage { |
| // When true, no more changes to the message are allowed. This is to DCHECK |
| // attempts of writing to a message which has been Finalize()-d. |
| bool sealed_; |
| + |
| + ProtoZeroMessageHandleBase* handle_; |
| #endif |
| // Pointer to the last child message created through BeginNestedMessage(), if |