Make ProtoWrapper accessors const
Bug: 330815376 Change-Id: I92add4a4f980788c29aef98ab59d7adb92101d7f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5873364 Auto-Submit: Joe Mason <joenotcharles@google.com> Commit-Queue: Joe Mason <joenotcharles@google.com> Reviewed-by: Alex Gough <ajgo@chromium.org> Commit-Queue: Alex Gough <ajgo@chromium.org> Cr-Commit-Position: refs/heads/main@{#1357254}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
21b22f8fc5
commit
a759465ee9
mojo/public/cpp/base
@@ -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;
|
||||
}
|
||||
|
@@ -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_;
|
||||
|
Reference in New Issue
Block a user