0

Convert MessageWriter APIs to base::span

Change-Id: Ib24b299232e6f0c09556d4e9d6ccbf07c5efce96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5126612
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Commit-Queue: David Benjamin <davidben@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1239219}
This commit is contained in:
David Benjamin
2023-12-19 17:51:57 +00:00
committed by Chromium LUCI CQ
parent 91e2282298
commit 71bf932284
39 changed files with 150 additions and 172 deletions

@ -84,8 +84,7 @@ void GetPropertyCallback(dbus::MethodCall* method_call,
case ui::ozone::mojom::GesturePropValue::Tag::kInts: {
writer.AppendUint32(values->get_ints().size());
writer.OpenVariant("ai", &variant_writer);
variant_writer.AppendArrayOfInt32s(values->get_ints().data(),
values->get_ints().size());
variant_writer.AppendArrayOfInt32s(values->get_ints());
writer.CloseContainer(&variant_writer);
break;
}
@ -119,8 +118,7 @@ void GetPropertyCallback(dbus::MethodCall* method_call,
case ui::ozone::mojom::GesturePropValue::Tag::kReals: {
writer.AppendUint32(values->get_reals().size());
writer.OpenVariant("ad", &variant_writer);
variant_writer.AppendArrayOfDoubles(values->get_reals().data(),
values->get_reals().size());
variant_writer.AppendArrayOfDoubles(values->get_reals());
writer.CloseContainer(&variant_writer);
break;
}

@ -523,7 +523,7 @@ class CrasAudioClientImpl : public CrasAudioClient {
cras::kSetGlobalOutputChannelRemix);
dbus::MessageWriter writer(&method_call);
writer.AppendInt32(channels);
writer.AppendArrayOfDoubles(mixer.data(), mixer.size());
writer.AppendArrayOfDoubles(mixer);
cras_proxy_->CallMethod(&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::DoNothing());

@ -261,7 +261,7 @@ void ChapsClientImpl::GetSlotList(bool token_present,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kGetSlotListMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendBool(token_present);
proxy_->CallMethod(
@ -277,7 +277,7 @@ void ChapsClientImpl::GetMechanismList(uint64_t slot_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kGetMechanismListMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(slot_id);
proxy_->CallMethod(
@ -294,7 +294,7 @@ void ChapsClientImpl::OpenSession(uint64_t slot_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kOpenSessionMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(slot_id);
writer.AppendUint64(flags);
@ -311,7 +311,7 @@ void ChapsClientImpl::CloseSession(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kCloseSessionMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
proxy_->CallMethod(
@ -328,9 +328,9 @@ void ChapsClientImpl::CreateObject(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kCreateObjectMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendArrayOfBytes(attributes.data(), attributes.size());
writer.AppendArrayOfBytes(attributes);
proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
@ -346,7 +346,7 @@ void ChapsClientImpl::DestroyObject(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kDestroyObjectMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(object_handle);
@ -366,10 +366,10 @@ void ChapsClientImpl::GetAttributeValue(
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kGetAttributeValueMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(object_handle);
writer.AppendArrayOfBytes(attributes_query.data(), attributes_query.size());
writer.AppendArrayOfBytes(attributes_query);
proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
@ -411,10 +411,10 @@ void ChapsClientImpl::SetAttributeValue(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kSetAttributeValueMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(object_handle);
writer.AppendArrayOfBytes(attributes.data(), attributes.size());
writer.AppendArrayOfBytes(attributes);
proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
@ -430,9 +430,9 @@ void ChapsClientImpl::FindObjectsInit(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kFindObjectsInitMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendArrayOfBytes(attributes.data(), attributes.size());
writer.AppendArrayOfBytes(attributes);
proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
@ -448,7 +448,7 @@ void ChapsClientImpl::FindObjects(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kFindObjectsMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(max_object_count);
@ -465,7 +465,7 @@ void ChapsClientImpl::FindObjectsFinal(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kFindObjectsFinalMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
proxy_->CallMethod(
@ -485,11 +485,10 @@ void ChapsClientImpl::EncryptInit(
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kEncryptInitMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(mechanism_type);
writer.AppendArrayOfBytes(mechanism_parameter.data(),
mechanism_parameter.size());
writer.AppendArrayOfBytes(mechanism_parameter);
writer.AppendUint64(key_handle);
proxy_->CallMethod(
@ -506,9 +505,9 @@ void ChapsClientImpl::Encrypt(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface, chaps::kEncryptMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendArrayOfBytes(data.data(), data.size());
writer.AppendArrayOfBytes(data);
writer.AppendUint64(max_out_length);
proxy_->CallMethod(
@ -528,11 +527,10 @@ void ChapsClientImpl::DecryptInit(
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kDecryptInitMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(mechanism_type);
writer.AppendArrayOfBytes(mechanism_parameter.data(),
mechanism_parameter.size());
writer.AppendArrayOfBytes(mechanism_parameter);
writer.AppendUint64(key_handle);
proxy_->CallMethod(
@ -549,9 +547,9 @@ void ChapsClientImpl::Decrypt(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface, chaps::kDecryptMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendArrayOfBytes(data.data(), data.size());
writer.AppendArrayOfBytes(data);
writer.AppendUint64(max_out_length);
proxy_->CallMethod(
@ -569,11 +567,10 @@ void ChapsClientImpl::SignInit(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface, chaps::kSignInitMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(mechanism_type);
writer.AppendArrayOfBytes(mechanism_parameter.data(),
mechanism_parameter.size());
writer.AppendArrayOfBytes(mechanism_parameter);
writer.AppendUint64(key_handle);
proxy_->CallMethod(
@ -590,9 +587,9 @@ void ChapsClientImpl::Sign(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface, chaps::kSignMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendArrayOfBytes(data.data(), data.size());
writer.AppendArrayOfBytes(data);
writer.AppendUint64(max_out_length);
proxy_->CallMethod(
@ -613,14 +610,12 @@ void ChapsClientImpl::GenerateKeyPair(
dbus::MethodCall method_call(chaps::kChapsInterface,
chaps::kGenerateKeyPairMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(mechanism_type);
writer.AppendArrayOfBytes(mechanism_parameter.data(),
mechanism_parameter.size());
writer.AppendArrayOfBytes(public_attributes.data(), public_attributes.size());
writer.AppendArrayOfBytes(private_attributes.data(),
private_attributes.size());
writer.AppendArrayOfBytes(mechanism_parameter);
writer.AppendArrayOfBytes(public_attributes);
writer.AppendArrayOfBytes(private_attributes);
proxy_->CallMethod(
&method_call, kDbusLongTimeoutMillis,
@ -664,11 +659,10 @@ void ChapsClientImpl::WrapKey(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface, chaps::kWrapKeyMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(mechanism_type);
writer.AppendArrayOfBytes(mechanism_parameter.data(),
mechanism_parameter.size());
writer.AppendArrayOfBytes(mechanism_parameter);
writer.AppendUint64(wrapping_key_handle);
writer.AppendUint64(key_handle);
writer.AppendUint64(max_out_length);
@ -690,14 +684,13 @@ void ChapsClientImpl::UnwrapKey(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface, chaps::kUnwrapKeyMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(mechanism_type);
writer.AppendArrayOfBytes(mechanism_parameter.data(),
mechanism_parameter.size());
writer.AppendArrayOfBytes(mechanism_parameter);
writer.AppendUint64(wrapping_key_handle);
writer.AppendArrayOfBytes(wrapped_key.data(), wrapped_key.size());
writer.AppendArrayOfBytes(attributes.data(), attributes.size());
writer.AppendArrayOfBytes(wrapped_key);
writer.AppendArrayOfBytes(attributes);
proxy_->CallMethod(
&method_call, kDbusLongTimeoutMillis,
@ -715,13 +708,12 @@ void ChapsClientImpl::DeriveKey(uint64_t session_id,
dbus::MethodCall method_call(chaps::kChapsInterface, chaps::kDeriveKeyMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kIsolateCredential, sizeof(kIsolateCredential));
writer.AppendArrayOfBytes(kIsolateCredential);
writer.AppendUint64(session_id);
writer.AppendUint64(mechanism_type);
writer.AppendArrayOfBytes(mechanism_parameter.data(),
mechanism_parameter.size());
writer.AppendArrayOfBytes(mechanism_parameter);
writer.AppendUint64(base_key_handle);
writer.AppendArrayOfBytes(attributes.data(), attributes.size());
writer.AppendArrayOfBytes(attributes);
proxy_->CallMethod(
&method_call, kDbusLongTimeoutMillis,

@ -52,7 +52,7 @@ std::unique_ptr<dbus::Response> CreateResponse(std::vector<uint8_t> bytes,
uint32_t result_code) {
auto response = dbus::Response::CreateEmpty();
dbus::MessageWriter writer(response.get());
writer.AppendArrayOfBytes(bytes.data(), bytes.size());
writer.AppendArrayOfBytes(bytes);
writer.AppendUint32(result_code);
return response;
}
@ -80,7 +80,7 @@ std::unique_ptr<dbus::Response> CreateResponse(uint64_t uint64_value,
auto response = dbus::Response::CreateEmpty();
dbus::MessageWriter writer(response.get());
writer.AppendUint64(uint64_value);
writer.AppendArrayOfBytes(bytes.data(), bytes.size());
writer.AppendArrayOfBytes(bytes);
writer.AppendUint32(result_code);
return response;
}

@ -539,9 +539,7 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
writer.AppendString(name);
writer.AppendString(uri);
writer.AppendString(language);
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(ppd_contents.data()),
ppd_contents.size());
writer.AppendArrayOfBytes(base::as_byte_span(ppd_contents));
debugdaemon_proxy_->CallMethodWithErrorResponse(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,

@ -39,8 +39,7 @@ std::string PopResponseData(dbus::MessageReader* reader) {
// Converts string to array of bytes and writes it using dbus meddage writer.
void AppendStringAsByteArray(const std::string& data,
dbus::MessageWriter* writer) {
writer->AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(data.data()),
data.length());
writer->AppendArrayOfBytes(base::as_byte_span(data));
}
// The EasyUnlockClient used in production.

@ -85,9 +85,7 @@ class HibermanClientImpl : public HibermanClient {
::hiberman::kResumeFromHibernateASMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendString(account_id);
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(&auth_session_id[0]),
auth_session_id.length());
writer.AppendArrayOfBytes(base::as_byte_span(auth_session_id));
// Bind with the weak pointer of |this| so the response is not
// handled once |this| is already destroyed.
proxy_->CallMethod(&method_call, kHibermanResumeTimeoutMs,

@ -263,9 +263,7 @@ class SessionManagerClientImpl : public SessionManagerClient {
writer.AppendString(key);
const std::string metadata_blob = metadata.SerializeAsString();
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(metadata_blob.data()),
metadata_blob.size());
writer.AppendArrayOfBytes(base::as_byte_span(metadata_blob));
writer.AppendUint64(data.size());
base::ScopedFD fd = CreateSharedMemoryRegionFDWithData(data);
@ -861,9 +859,7 @@ class SessionManagerClientImpl : public SessionManagerClient {
dbus::MessageWriter writer(&method_call);
const std::string descriptor_blob = descriptor.SerializeAsString();
// static_cast does not work due to signedness.
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(descriptor_blob.data()),
descriptor_blob.size());
writer.AppendArrayOfBytes(base::as_byte_span(descriptor_blob));
session_manager_proxy_->CallMethodWithErrorResponse(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&SessionManagerClientImpl::OnRetrievePolicy,
@ -881,9 +877,7 @@ class SessionManagerClientImpl : public SessionManagerClient {
dbus::MessageWriter writer(&method_call);
const std::string descriptor_blob = descriptor.SerializeAsString();
// static_cast does not work due to signedness.
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(descriptor_blob.data()),
descriptor_blob.size());
writer.AppendArrayOfBytes(base::as_byte_span(descriptor_blob));
auto result = blocking_method_caller_->CallMethodAndBlock(&method_call);
RetrievePolicyResponseType response_type =
RetrievePolicyResponseType::SUCCESS;
@ -908,12 +902,8 @@ class SessionManagerClientImpl : public SessionManagerClient {
dbus::MessageWriter writer(&method_call);
const std::string descriptor_blob = descriptor.SerializeAsString();
// static_cast does not work due to signedness.
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(descriptor_blob.data()),
descriptor_blob.size());
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(policy_blob.data()),
policy_blob.size());
writer.AppendArrayOfBytes(base::as_byte_span(descriptor_blob));
writer.AppendArrayOfBytes(base::as_byte_span(policy_blob));
// The timeout is intentionally chosen to be that big because on some
// devices the operation is slow and a short timeout would lead to
// unnecessary enrollment failures. See crbug.com/1155533 for context.

@ -47,7 +47,7 @@ class Modem3gppProxy {
modemmanager::kModem3gppSetCarrierLock);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes((const uint8_t*)config.data(), config.size());
writer.AppendArrayOfBytes(base::as_byte_span(config));
proxy_->CallMethodWithErrorResponse(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,

@ -263,8 +263,7 @@ void ShillThirdPartyVpnDriverClientImpl::SendPacket(
dbus::MessageWriter writer(&method_call);
static_assert(sizeof(uint8_t) == sizeof(char),
"Can't reinterpret ip_packet if char is not 8 bit large.");
writer.AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(ip_packet.data()),
ip_packet.size());
writer.AppendArrayOfBytes(base::as_byte_span(ip_packet));
GetHelper(object_path_value)
->CallVoidMethodWithErrorCallback(&method_call, std::move(callback),
std::move(error_callback));

@ -81,9 +81,7 @@ TEST_F(ShillThirdPartyVpnDriverClientTest, PlatformSignal) {
shill::kOnPacketReceivedFunction);
{
dbus::MessageWriter writer(&preceived_signal);
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(data_packet.data()),
data_packet.size());
writer.AppendArrayOfBytes(base::as_byte_span(data_packet));
}
// Expect each signal to be triggered once.

@ -88,7 +88,7 @@ class SmbProviderClientImpl final : public SmbProviderClient {
dbus::MethodCall method_call(smbprovider::kSmbProviderInterface,
smbprovider::kParseNetBiosPacketMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(packet.data(), packet.size());
writer.AppendArrayOfBytes(packet);
writer.AppendUint16(transaction_id);
CallMethod(&method_call,
&SmbProviderClientImpl::HandleParseNetBiosPacketCallback,

@ -128,7 +128,7 @@ void TypecdClientImpl::SetTypeCPortsUsingDisplays(
dbus::MethodCall method_call(typecd::kTypecdServiceInterface,
typecd::kTypecdSetPortsUsingDisplaysMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfUint32s(port_nums.data(), port_nums.size());
writer.AppendArrayOfUint32s(port_nums);
typecd_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::DoNothing());

@ -165,7 +165,7 @@ class CryptohomeMiscClientTest : public testing::Test {
// a very large value so the parsing will fail.
constexpr uint8_t invalid_protobuf[] = {0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF};
writer.AppendArrayOfBytes(invalid_protobuf, sizeof(invalid_protobuf));
writer.AppendArrayOfBytes(invalid_protobuf);
} else if (method_call->GetMember() == ::user_data_auth::kGetSystemSalt) {
writer.AppendProtoAsArrayOfBytes(expected_get_system_salt_reply_);
} else if (method_call->GetMember() ==
@ -198,7 +198,7 @@ class CryptohomeMiscClientTest : public testing::Test {
// a very large value so the parsing will fail.
constexpr uint8_t invalid_protobuf[] = {0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF};
writer.AppendArrayOfBytes(invalid_protobuf, sizeof(invalid_protobuf));
writer.AppendArrayOfBytes(invalid_protobuf);
} else if (method_call->GetMember() ==
::user_data_auth::kGetSanitizedUsername) {
writer.AppendProtoAsArrayOfBytes(

@ -122,7 +122,7 @@ class CryptohomePkcs11ClientTest : public testing::Test {
// a very large value so the parsing will fail.
constexpr uint8_t invalid_protobuf[] = {0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF};
writer.AppendArrayOfBytes(invalid_protobuf, sizeof(invalid_protobuf));
writer.AppendArrayOfBytes(invalid_protobuf);
} else if (method_call->GetMember() ==
::user_data_auth::kPkcs11IsTpmTokenReady) {
writer.AppendProtoAsArrayOfBytes(

@ -179,7 +179,7 @@ class InstallAttributesClientTest : public testing::Test {
// a very large value so the parsing will fail.
constexpr uint8_t invalid_protobuf[] = {0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF};
writer.AppendArrayOfBytes(invalid_protobuf, sizeof(invalid_protobuf));
writer.AppendArrayOfBytes(invalid_protobuf);
} else if (method_call->GetMember() ==
::user_data_auth::kInstallAttributesGet) {
writer.AppendProtoAsArrayOfBytes(expected_install_attributes_get_reply_);
@ -222,7 +222,7 @@ class InstallAttributesClientTest : public testing::Test {
// a very large value so the parsing will fail.
constexpr uint8_t invalid_protobuf[] = {0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF};
writer.AppendArrayOfBytes(invalid_protobuf, sizeof(invalid_protobuf));
writer.AppendArrayOfBytes(invalid_protobuf);
} else if (method_call->GetMember() ==
::user_data_auth::kInstallAttributesGet) {
writer.AppendProtoAsArrayOfBytes(

@ -212,7 +212,7 @@ class UserDataAuthClientTest : public testing::Test {
// a very large value so the parsing will fail.
constexpr uint8_t invalid_protobuf[] = {0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF};
writer.AppendArrayOfBytes(invalid_protobuf, sizeof(invalid_protobuf));
writer.AppendArrayOfBytes(invalid_protobuf);
} else if (method_call->GetMember() == ::user_data_auth::kIsMounted) {
writer.AppendProtoAsArrayOfBytes(expected_is_mounted_reply_);
} else if (method_call->GetMember() == ::user_data_auth::kIsMounted) {

@ -191,7 +191,7 @@ class IpPeripheralServiceClientImpl : public IpPeripheralServiceClient {
ip_peripheral::kGetControlMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendString(ip);
writer.AppendArrayOfBytes(guid_le.data(), guid_le.size());
writer.AppendArrayOfBytes(guid_le);
writer.AppendByte(control_selector);
writer.AppendByte(uvc_get_request);
ip_peripheral_service_proxy_->CallMethod(
@ -208,9 +208,9 @@ class IpPeripheralServiceClientImpl : public IpPeripheralServiceClient {
ip_peripheral::kSetControlMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendString(ip);
writer.AppendArrayOfBytes(guid_le.data(), guid_le.size());
writer.AppendArrayOfBytes(guid_le);
writer.AppendByte(control_selector);
writer.AppendArrayOfBytes(control_setting.data(), control_setting.size());
writer.AppendArrayOfBytes(control_setting);
ip_peripheral_service_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&OnSetControlMethod, std::move(callback)));

@ -291,9 +291,9 @@ void DbusMenu::OnAboutToShowGroup(ScopedMethodResponse* response) {
}
// IDs of updates needed (none).
response->Writer().AppendArrayOfInt32s(nullptr, 0);
response->Writer().AppendArrayOfInt32s({});
// Invalid IDs.
response->Writer().AppendArrayOfInt32s(id_errors.data(), id_errors.size());
response->Writer().AppendArrayOfInt32s(id_errors);
}
void DbusMenu::OnEvent(ScopedMethodResponse* response) {
@ -320,7 +320,7 @@ void DbusMenu::OnEventGroup(ScopedMethodResponse* response) {
}
}
response->Writer().AppendArrayOfInt32s(id_errors.data(), id_errors.size());
response->Writer().AppendArrayOfInt32s(id_errors);
}
void DbusMenu::OnGetGroupProperties(ScopedMethodResponse* response) {

@ -151,7 +151,7 @@ bool DbusByteArray::IsEqual(const DbusType& other_type) const {
}
void DbusByteArray::Write(dbus::MessageWriter* writer) const {
writer->AppendArrayOfBytes(value_->front(), value_->size());
writer->AppendArrayOfBytes(*value_);
}
// static

@ -342,11 +342,11 @@ KWalletDBus::Error KWalletDBus::WriteEntry(const int wallet_handle,
int* return_code_ptr) {
dbus::MethodCall method_call(kKWalletInterface, "writeEntry");
dbus::MessageWriter builder(&method_call);
builder.AppendInt32(wallet_handle); // handle
builder.AppendString(folder_name); // folder
builder.AppendString(key); // key
builder.AppendArrayOfBytes(data, length); // value
builder.AppendString(app_name); // appid
builder.AppendInt32(wallet_handle); // handle
builder.AppendString(folder_name); // folder
builder.AppendString(key); // key
builder.AppendArrayOfBytes(base::make_span(data, length)); // value
builder.AppendString(app_name); // appid
std::unique_ptr<dbus::Response> response(
kwallet_proxy_
->CallMethodAndBlock(&method_call,

@ -48,7 +48,7 @@ std::unique_ptr<dbus::Response> RespondBytes(
const std::vector<uint8_t>& bytes) {
std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
dbus::MessageWriter writer(response.get());
writer.AppendArrayOfBytes(bytes.data(), bytes.size());
writer.AppendArrayOfBytes(bytes);
return response;
}

@ -590,47 +590,58 @@ void MessageWriter::CloseContainer(MessageWriter* writer) {
container_is_open_ = false;
}
void MessageWriter::AppendArrayOfBytes(const uint8_t* values, size_t length) {
void MessageWriter::AppendArrayOfBytes(base::span<const uint8_t> values) {
DCHECK(!container_is_open_);
MessageWriter array_writer(message_);
OpenArray("y", &array_writer);
// dbus_message_iter_append_fixed_array takes a pointer to a pointer to the
// data.
const uint8_t* ptr = values.data();
const bool success = dbus_message_iter_append_fixed_array(
&(array_writer.raw_message_iter_), DBUS_TYPE_BYTE, &values,
static_cast<int>(length));
&(array_writer.raw_message_iter_), DBUS_TYPE_BYTE, &ptr,
base::checked_cast<int>(values.size()));
CHECK(success) << "Unable to allocate memory";
CloseContainer(&array_writer);
}
void MessageWriter::AppendArrayOfInt32s(const int32_t* values, size_t length) {
void MessageWriter::AppendArrayOfInt32s(base::span<const int32_t> values) {
DCHECK(!container_is_open_);
MessageWriter array_writer(message_);
OpenArray("i", &array_writer);
// dbus_message_iter_append_fixed_array takes a pointer to a pointer to the
// data.
const int32_t* ptr = values.data();
const bool success = dbus_message_iter_append_fixed_array(
&(array_writer.raw_message_iter_), DBUS_TYPE_INT32, &values,
static_cast<int>(length));
&(array_writer.raw_message_iter_), DBUS_TYPE_INT32, &ptr,
base::checked_cast<int>(values.size()));
CHECK(success) << "Unable to allocate memory";
CloseContainer(&array_writer);
}
void MessageWriter::AppendArrayOfUint32s(const uint32_t* values,
size_t length) {
void MessageWriter::AppendArrayOfUint32s(base::span<const uint32_t> values) {
DCHECK(!container_is_open_);
MessageWriter array_writer(message_);
OpenArray("u", &array_writer);
// dbus_message_iter_append_fixed_array takes a pointer to a pointer to the
// data.
const uint32_t* ptr = values.data();
const bool success = dbus_message_iter_append_fixed_array(
&(array_writer.raw_message_iter_), DBUS_TYPE_UINT32, &values,
static_cast<int>(length));
&(array_writer.raw_message_iter_), DBUS_TYPE_UINT32, &ptr,
base::checked_cast<int>(values.size()));
CHECK(success) << "Unable to allocate memory";
CloseContainer(&array_writer);
}
void MessageWriter::AppendArrayOfDoubles(const double* values, size_t length) {
void MessageWriter::AppendArrayOfDoubles(base::span<const double> values) {
DCHECK(!container_is_open_);
MessageWriter array_writer(message_);
OpenArray("d", &array_writer);
// dbus_message_iter_append_fixed_array takes a pointer to a pointer to the
// data.
const double* ptr = values.data();
const bool success = dbus_message_iter_append_fixed_array(
&(array_writer.raw_message_iter_), DBUS_TYPE_DOUBLE, &values,
static_cast<int>(length));
&(array_writer.raw_message_iter_), DBUS_TYPE_DOUBLE, &ptr,
base::checked_cast<int>(values.size()));
CHECK(success) << "Unable to allocate memory";
CloseContainer(&array_writer);
}
@ -664,8 +675,7 @@ bool MessageWriter::AppendProtoAsArrayOfBytes(
LOG(ERROR) << "Unable to serialize supplied protocol buffer";
return false;
}
AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(serialized_proto.data()),
serialized_proto.size());
AppendArrayOfBytes(base::as_byte_span(serialized_proto));
return true;
}

@ -13,6 +13,7 @@
#include <string>
#include <vector>
#include "base/containers/span.h"
#include "base/files/scoped_file.h"
#include "base/memory/raw_ptr.h"
#include "dbus/dbus_export.h"
@ -319,16 +320,16 @@ class CHROME_DBUS_EXPORT MessageWriter {
// Appends the array of bytes. Arrays of bytes are often used for
// exchanging binary blobs hence it's worth having a specialized
// function.
void AppendArrayOfBytes(const uint8_t* values, size_t length);
void AppendArrayOfBytes(base::span<const uint8_t> values);
// Appends array of int32_ts.
void AppendArrayOfInt32s(const int32_t* values, size_t length);
void AppendArrayOfInt32s(base::span<const int32_t> values);
// Appends array of uint32_ts.
void AppendArrayOfUint32s(const uint32_t* values, size_t length);
void AppendArrayOfUint32s(base::span<const uint32_t> values);
// Appends the array of doubles. Used for audio mixer matrix doubles.
void AppendArrayOfDoubles(const double* values, size_t length);
void AppendArrayOfDoubles(base::span<const double> values);
// Appends the array of strings. Arrays of strings are often used for
// exchanging lists of names hence it's worth having a specialized

@ -226,7 +226,7 @@ TEST(MessageTest, ArrayOfBytes) {
bytes.push_back(1);
bytes.push_back(2);
bytes.push_back(3);
writer.AppendArrayOfBytes(bytes.data(), bytes.size());
writer.AppendArrayOfBytes(bytes);
MessageReader reader(message.get());
const uint8_t* output_bytes = nullptr;
@ -247,7 +247,7 @@ TEST(MessageTest, ArrayOfInt32s) {
int32s.push_back(1);
int32s.push_back(2);
int32s.push_back(3);
writer.AppendArrayOfInt32s(int32s.data(), int32s.size());
writer.AppendArrayOfInt32s(int32s);
MessageReader reader(message.get());
const int32_t* output_int32s = nullptr;
@ -268,7 +268,7 @@ TEST(MessageTest, ArrayOfUint32s) {
uint32s.push_back(1);
uint32s.push_back(2);
uint32s.push_back(3);
writer.AppendArrayOfUint32s(uint32s.data(), uint32s.size());
writer.AppendArrayOfUint32s(uint32s);
MessageReader reader(message.get());
const uint32_t* output_uint32s = nullptr;
@ -289,7 +289,7 @@ TEST(MessageTest, ArrayOfDoubles) {
doubles.push_back(0.2);
doubles.push_back(0.5);
doubles.push_back(1);
writer.AppendArrayOfDoubles(doubles.data(), doubles.size());
writer.AppendArrayOfDoubles(doubles);
MessageReader reader(message.get());
const double* output_doubles = nullptr;
@ -307,7 +307,7 @@ TEST(MessageTest, ArrayOfBytes_Empty) {
std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
std::vector<uint8_t> bytes;
writer.AppendArrayOfBytes(bytes.data(), bytes.size());
writer.AppendArrayOfBytes(bytes);
MessageReader reader(message.get());
const uint8_t* output_bytes = nullptr;

@ -548,7 +548,7 @@ void Property<std::vector<uint8_t>>::AppendSetValueToWriter(
MessageWriter* writer) {
MessageWriter variant_writer(nullptr);
writer->OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(set_value_.data(), set_value_.size());
variant_writer.AppendArrayOfBytes(set_value_);
writer->CloseContainer(&variant_writer);
}
@ -640,8 +640,7 @@ void Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>::
for (const auto& pair : set_value_) {
dbus::MessageWriter struct_writer(nullptr);
array_writer.OpenStruct(&struct_writer);
struct_writer.AppendArrayOfBytes(std::get<0>(pair).data(),
std::get<0>(pair).size());
struct_writer.AppendArrayOfBytes(std::get<0>(pair));
struct_writer.AppendUint16(std::get<1>(pair));
array_writer.CloseContainer(&struct_writer);
}
@ -710,8 +709,7 @@ void Property<std::map<std::string, std::vector<uint8_t>>>::
MessageWriter value_varient_writer(nullptr);
entry_writer.OpenVariant("ay", &value_varient_writer);
value_varient_writer.AppendArrayOfBytes(pair.second.data(),
pair.second.size());
value_varient_writer.AppendArrayOfBytes(pair.second);
entry_writer.CloseContainer(&value_varient_writer);
dict_writer.CloseContainer(&entry_writer);
@ -782,8 +780,7 @@ void Property<std::map<uint16_t, std::vector<uint8_t>>>::AppendSetValueToWriter(
MessageWriter value_varient_writer(nullptr);
entry_writer.OpenVariant("ay", &value_varient_writer);
value_varient_writer.AppendArrayOfBytes(pair.second.data(),
pair.second.size());
value_varient_writer.AppendArrayOfBytes(pair.second);
entry_writer.CloseContainer(&value_varient_writer);
dict_writer.CloseContainer(&entry_writer);

@ -379,7 +379,7 @@ TEST(PropertyTestStatic, ReadWriteNetAddressArray) {
for (uint16_t i = 0; i < 5; ++i) {
variant_array_writer.OpenStruct(&struct_entry_writer);
ip_bytes[4] = 0x30 + i;
struct_entry_writer.AppendArrayOfBytes(ip_bytes, std::size(ip_bytes));
struct_entry_writer.AppendArrayOfBytes(ip_bytes);
struct_entry_writer.AppendUint16(i);
variant_array_writer.CloseContainer(&struct_entry_writer);
}
@ -442,7 +442,7 @@ TEST(PropertyTestStatic, ReadWriteStringToByteVectorMapVariantWrapped) {
MessageWriter value_varient_writer(nullptr);
entry_writer.OpenVariant("ay", &value_varient_writer);
value_varient_writer.AppendArrayOfBytes(values[i].data(), values[i].size());
value_varient_writer.AppendArrayOfBytes(values[i]);
entry_writer.CloseContainer(&value_varient_writer);
dict_writer.CloseContainer(&entry_writer);
@ -476,7 +476,7 @@ TEST(PropertyTestStatic, ReadWriteStringToByteVectorMap) {
dict_writer.OpenDictEntry(&entry_writer);
entry_writer.AppendString(keys[i]);
entry_writer.AppendArrayOfBytes(values[i].data(), values[i].size());
entry_writer.AppendArrayOfBytes(values[i]);
dict_writer.CloseContainer(&entry_writer);
}
@ -530,7 +530,7 @@ TEST(PropertyTestStatic, ReadWriteUInt16ToByteVectorMapVariantWrapped) {
MessageWriter value_varient_writer(nullptr);
entry_writer.OpenVariant("ay", &value_varient_writer);
value_varient_writer.AppendArrayOfBytes(values[i].data(), values[i].size());
value_varient_writer.AppendArrayOfBytes(values[i]);
entry_writer.CloseContainer(&value_varient_writer);
dict_writer.CloseContainer(&entry_writer);
@ -564,7 +564,7 @@ TEST(PropertyTestStatic, ReadWriteUInt16ToByteVectorMap) {
dict_writer.OpenDictEntry(&entry_writer);
entry_writer.AppendUint16(keys[i]);
entry_writer.AppendArrayOfBytes(values[i].data(), values[i].size());
entry_writer.AppendArrayOfBytes(values[i]);
dict_writer.CloseContainer(&entry_writer);
}

@ -394,7 +394,7 @@ void TestService::GetProperty(MethodCall* method_call,
writer.OpenVariant("ay", &variant_writer);
const uint8_t bytes[] = {0x54, 0x65, 0x73, 0x74};
variant_writer.AppendArrayOfBytes(bytes, sizeof(bytes));
variant_writer.AppendArrayOfBytes(bytes);
writer.CloseContainer(&variant_writer);
std::move(response_sender).Run(std::move(response));
@ -596,7 +596,7 @@ void TestService::AddPropertiesToWriter(MessageWriter* writer) {
dict_entry_writer.AppendString("Bytes");
dict_entry_writer.OpenVariant("ay", &variant_writer);
const uint8_t bytes[] = {0x54, 0x65, 0x73, 0x74};
variant_writer.AppendArrayOfBytes(bytes, sizeof(bytes));
variant_writer.AppendArrayOfBytes(bytes);
dict_entry_writer.CloseContainer(&variant_writer);
array_writer.CloseContainer(&dict_entry_writer);

@ -237,7 +237,8 @@ void BluetoothAdvertisementMonitorServiceProviderImpl::WritePattern(
struct_writer.AppendByte(start_pos);
struct_writer.AppendByte(ad_data_type);
struct_writer.AppendArrayOfBytes(content_of_pattern, pattern_length);
struct_writer.AppendArrayOfBytes(
base::make_span(content_of_pattern, pattern_length));
pattern_array_writer->CloseContainer(&struct_writer);
}

@ -133,7 +133,7 @@ class BluetoothGattCharacteristicClientImpl
bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface,
bluetooth_gatt_characteristic::kWriteValue);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(value.data(), value.size());
writer.AppendArrayOfBytes(value);
// Append option dict
base::Value::Dict dict;
@ -168,7 +168,7 @@ class BluetoothGattCharacteristicClientImpl
bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface,
bluetooth_gatt_characteristic::kPrepareWriteValue);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(value.data(), value.size());
writer.AppendArrayOfBytes(value);
dbus::AppendValueData(&writer, base::Value::Dict());

@ -158,7 +158,7 @@ void BluetoothGattCharacteristicServiceProviderImpl::SendValueChanged(
array_writer.OpenDictEntry(&dict_entry_writer);
dict_entry_writer.AppendString(bluetooth_gatt_characteristic::kValueProperty);
dict_entry_writer.OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(value.data(), value.size());
variant_writer.AppendArrayOfBytes(value);
dict_entry_writer.CloseContainer(&variant_writer);
array_writer.CloseContainer(&dict_entry_writer);
writer.CloseContainer(&array_writer);
@ -512,7 +512,7 @@ void BluetoothGattCharacteristicServiceProviderImpl::OnReadValue(
std::unique_ptr<dbus::Response> response =
dbus::Response::FromMethodCall(method_call);
dbus::MessageWriter writer(response.get());
writer.AppendArrayOfBytes(value.data(), value.size());
writer.AppendArrayOfBytes(value);
std::move(response_sender).Run(std::move(response));
}

@ -135,7 +135,7 @@ class BluetoothGattDescriptorClientImpl
bluetooth_gatt_descriptor::kBluetoothGattDescriptorInterface,
bluetooth_gatt_descriptor::kWriteValue);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(value.data(), value.size());
writer.AppendArrayOfBytes(value);
// Append empty option dict
dbus::AppendValueData(&writer, base::Value::Dict());

@ -123,7 +123,7 @@ void BluetoothGattDescriptorServiceProviderImpl::SendValueChanged(
array_writer.OpenDictEntry(&dict_entry_writer);
dict_entry_writer.AppendString(bluetooth_gatt_descriptor::kValueProperty);
dict_entry_writer.OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(value.data(), value.size());
variant_writer.AppendArrayOfBytes(value);
dict_entry_writer.CloseContainer(&variant_writer);
array_writer.CloseContainer(&dict_entry_writer);
writer.CloseContainer(&array_writer);
@ -359,7 +359,7 @@ void BluetoothGattDescriptorServiceProviderImpl::OnReadValue(
std::unique_ptr<dbus::Response> response =
dbus::Response::FromMethodCall(method_call);
dbus::MessageWriter writer(response.get());
writer.AppendArrayOfBytes(value.data(), value.size());
writer.AppendArrayOfBytes(value);
std::move(response_sender).Run(std::move(response));
}

@ -269,7 +269,7 @@ class BluetoothAdvertisementServiceProviderImpl
dbus::MessageWriter variant_writer(NULL);
writer.OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(value.data(), value.size());
variant_writer.AppendArrayOfBytes(value);
writer.CloseContainer(&variant_writer);
std::move(response_sender).Run(std::move(response));
@ -361,17 +361,17 @@ class BluetoothAdvertisementServiceProviderImpl
void AppendManufacturerDataVariant(dbus::MessageWriter* writer) {
DCHECK(manufacturer_data_);
dbus::MessageWriter array_writer(NULL);
dbus::MessageWriter array_writer(nullptr);
writer->OpenArray("{qv}", &array_writer);
for (const auto& m : *manufacturer_data_) {
dbus::MessageWriter entry_writer(NULL);
dbus::MessageWriter entry_writer(nullptr);
array_writer.OpenDictEntry(&entry_writer);
entry_writer.AppendUint16(m.first);
dbus::MessageWriter variant_writer(NULL);
dbus::MessageWriter variant_writer(nullptr);
entry_writer.OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(m.second.data(), m.second.size());
variant_writer.AppendArrayOfBytes(m.second);
entry_writer.CloseContainer(&variant_writer);
array_writer.CloseContainer(&entry_writer);
@ -381,17 +381,17 @@ class BluetoothAdvertisementServiceProviderImpl
void AppendServiceDataVariant(dbus::MessageWriter* writer) {
DCHECK(service_data_);
dbus::MessageWriter array_writer(NULL);
dbus::MessageWriter array_writer(nullptr);
writer->OpenArray("{sv}", &array_writer);
for (const auto& m : *service_data_) {
dbus::MessageWriter entry_writer(NULL);
dbus::MessageWriter entry_writer(nullptr);
array_writer.OpenDictEntry(&entry_writer);
entry_writer.AppendString(m.first);
dbus::MessageWriter variant_writer(NULL);
dbus::MessageWriter variant_writer(nullptr);
entry_writer.OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(m.second.data(), m.second.size());
variant_writer.AppendArrayOfBytes(m.second);
entry_writer.CloseContainer(&variant_writer);
array_writer.CloseContainer(&entry_writer);
@ -411,7 +411,7 @@ class BluetoothAdvertisementServiceProviderImpl
entry_writer.AppendByte(m.first);
dbus::MessageWriter variant_writer(nullptr);
entry_writer.OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(m.second.data(), m.second.size());
variant_writer.AppendArrayOfBytes(m.second);
entry_writer.CloseContainer(&variant_writer);
array_writer.CloseContainer(&entry_writer);

@ -1084,8 +1084,7 @@ TEST_F(FlossAdapterClientTest, GenericMethodGetRemoteUuids) {
dbus::MessageWriter writer(response.get());
dbus::MessageWriter array_writer(nullptr);
writer.OpenArray("ay", &array_writer);
array_writer.AppendArrayOfBytes(kFakeUuidByteArray,
sizeof(kFakeUuidByteArray));
array_writer.AppendArrayOfBytes(kFakeUuidByteArray);
writer.CloseContainer(&array_writer);
std::move(*cb).Run(response.get(), /*err=*/nullptr);
});

@ -479,7 +479,7 @@ void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const std::vector<uint8_t>& data) {
writer->AppendArrayOfBytes(data.data(), data.size());
writer->AppendArrayOfBytes(data);
}
template <>

@ -151,7 +151,7 @@ class FlossLEScanClientTest : public testing::Test,
method_call.SetSender(kTestSender);
method_call.SetSerial(kTestSerial);
dbus::MessageWriter writer(&method_call);
writer.AppendArrayOfBytes(kTestUuidByteArray, sizeof(kTestUuidByteArray));
writer.AppendArrayOfBytes(kTestUuidByteArray);
writer.AppendByte(kTestScannerId);
writer.AppendUint32(static_cast<uint32_t>(kTestStatus));
@ -347,8 +347,7 @@ TEST_F(FlossLEScanClientTest, TestInitExportRegisterScanner) {
// Create a fake response with UUID return value.
auto response = ::dbus::Response::CreateEmpty();
dbus::MessageWriter writer(response.get());
writer.AppendArrayOfBytes(kTestUuidByteArray,
sizeof(kTestUuidByteArray));
writer.AppendArrayOfBytes(kTestUuidByteArray);
std::move(*cb).Run(response.get(), /*err=*/nullptr);
});
client_->RegisterScanner(

@ -419,8 +419,7 @@ void NetworkingPrivateLinux::ConnectToNetwork(const std::string& guid,
dbus::MessageWriter variant_writer(&method_call);
wifi_dict_writer.OpenVariant("ay", &variant_writer);
variant_writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(ssid.c_str()), ssid.size());
variant_writer.AppendArrayOfBytes(base::as_byte_span(ssid));
// Close all the arrays and dicts.
wifi_dict_writer.CloseContainer(&variant_writer);

@ -101,9 +101,9 @@ void AppendByteStringOption(dbus::MessageWriter* writer,
option_writer.OpenVariant("ay", &value_writer);
value_writer.AppendArrayOfBytes(
reinterpret_cast<const std::uint8_t*>(value.c_str()),
// size + 1 will include the null terminator.
value.size() + 1);
base::make_span(reinterpret_cast<const std::uint8_t*>(value.c_str()),
// size + 1 will include the null terminator.
value.size() + 1));
option_writer.CloseContainer(&value_writer);
writer->CloseContainer(&option_writer);