Chromium Code Reviews| Index: components/tracing/core/proto_zero_message_handle.h |
| diff --git a/components/tracing/core/proto_zero_message_handle.h b/components/tracing/core/proto_zero_message_handle.h |
| index 2f83ec9638f0d400a96eec74c159c0730eab62f7..9629c3802ec850e4227fbc4ddeaf0fc19b387a47 100644 |
| --- a/components/tracing/core/proto_zero_message_handle.h |
| +++ b/components/tracing/core/proto_zero_message_handle.h |
| @@ -5,6 +5,12 @@ |
| #ifndef COMPONENTS_TRACING_CORE_PROTO_ZERO_MESSAGE_HANDLE_H_ |
| #define COMPONENTS_TRACING_CORE_PROTO_ZERO_MESSAGE_HANDLE_H_ |
| +#include <stdint.h> |
| + |
| +#include <string> |
| +#include <unordered_set> |
| + |
| +#include "base/logging.h" |
| #include "base/macros.h" |
| #include "components/tracing/tracing_export.h" |
| @@ -32,6 +38,12 @@ class TRACING_EXPORT ProtoZeroMessageHandleBase { |
| ProtoZeroMessageHandleBase(ProtoZeroMessageHandleBase&& other); |
| ProtoZeroMessageHandleBase& operator=(ProtoZeroMessageHandleBase&& other); |
| + inline void SealField(uint32_t field_id) { |
|
Primiano Tucci (use gerrit)
2016/08/24 08:59:45
wait why sealfield is a property of the Handle?
Th
|
| + DCHECK(sealed_fields_.count(field_id) == 0) << |
| + "Field (" + std::to_string(field_id) + ") can't be sealed again."; |
| + sealed_fields_.insert(field_id); |
| + } |
| + |
| protected: |
| explicit ProtoZeroMessageHandleBase(ProtoZeroMessage*); |
| ProtoZeroMessage& operator*() const { return *message_; } |
| @@ -40,16 +52,20 @@ class TRACING_EXPORT ProtoZeroMessageHandleBase { |
| private: |
| friend class ProtoZeroMessage; |
| - void reset_message() { message_ = nullptr; } |
| + void reset_message() { |
| + message_ = nullptr; |
| + sealed_fields_.clear(); |
| + } |
| void Move(ProtoZeroMessageHandleBase* other); |
| ProtoZeroMessage* message_; |
| + std::unordered_set<uint32_t> sealed_fields_; |
| DISALLOW_COPY_AND_ASSIGN(ProtoZeroMessageHandleBase); |
| }; |
| template <typename T> |
| -class ProtoZeroMessageHandle : ProtoZeroMessageHandleBase { |
| +class ProtoZeroMessageHandle : public ProtoZeroMessageHandleBase { |
| public: |
| explicit ProtoZeroMessageHandle(T* message) |
| : ProtoZeroMessageHandleBase(message) {} |