diff --git a/mojo/public/cpp/base/proto_wrapper.cc b/mojo/public/cpp/base/proto_wrapper.cc index 4deb7fa12048f..853439552f625 100644 --- a/mojo/public/cpp/base/proto_wrapper.cc +++ b/mojo/public/cpp/base/proto_wrapper.cc @@ -42,7 +42,7 @@ ProtoWrapper::ProtoWrapper(base::span<const uint8_t> data, } bool ProtoWrapper::DeserializeToMessage( - google::protobuf::MessageLite& message) { + google::protobuf::MessageLite& message) const { if (!bytes_.has_value()) { return false; } diff --git a/mojo/public/cpp/base/proto_wrapper.h b/mojo/public/cpp/base/proto_wrapper.h index a9b0807b9cd2f..b0dfb576ae94b 100644 --- a/mojo/public/cpp/base/proto_wrapper.h +++ b/mojo/public/cpp/base/proto_wrapper.h @@ -58,7 +58,7 @@ class COMPONENT_EXPORT(MOJO_BASE_PROTOBUF_SUPPORT) ProtoWrapper { base::PassKey<ProtoWrapperBytes> passkey); template <IsProtoMessage ProtoMessage> - std::optional<ProtoMessage> As() { + std::optional<ProtoMessage> As() const { ProtoMessage message; if (DeserializeToMessage(message)) { return message; @@ -71,7 +71,7 @@ class COMPONENT_EXPORT(MOJO_BASE_PROTOBUF_SUPPORT) ProtoWrapper { // cannot change, the contents might. If you want to unpack the contained // protobuf Message, use As<T>(); std::optional<base::span<const uint8_t>> byte_span( - base::PassKey<ProtoWrapperBytes> passkey) { + base::PassKey<ProtoWrapperBytes> passkey) const { if (!is_valid()) { return std::nullopt; } @@ -94,7 +94,7 @@ class COMPONENT_EXPORT(MOJO_BASE_PROTOBUF_SUPPORT) ProtoWrapper { // bytes will deserialize to a valid message. bool is_valid() const { return bytes_.has_value(); } - bool DeserializeToMessage(google::protobuf::MessageLite& message); + bool DeserializeToMessage(google::protobuf::MessageLite& message) const; std::string proto_name_; std::optional<BigBuffer> bytes_;