Remove IPC::BrokerableAttachment.
With only ChannelMojo in use, the distinction between brokerable and
non-brokerable attachments no longer makes sense. This CL removes that
distinction by removing BrokerableAttachment and flattening the
hierarchy of attachment types.
This also trims some POSIX-specific parts of IPC::MessageAttachmentSet.
BUG=659448
Committed: https://crrev.com/f6e03ce56c4d2370b79d0c3dd4ceb89cf5528e56
Review-Url: https://codereview.chromium.org/2494943002
Cr-Original-Commit-Position: refs/heads/master@{#432153}
Cr-Commit-Position: refs/heads/master@{#434099}
diff --git a/ipc/ipc_channel_mojo.cc b/ipc/ipc_channel_mojo.cc
index 13af1e3..4189b9c0 100644
--- a/ipc/ipc_channel_mojo.cc
+++ b/ipc/ipc_channel_mojo.cc
@@ -124,14 +124,14 @@
MojoResult WrapAttachmentImpl(MessageAttachment* attachment,
mojom::SerializedHandlePtr* serialized) {
- if (attachment->GetType() == MessageAttachment::TYPE_MOJO_HANDLE) {
+ if (attachment->GetType() == MessageAttachment::Type::MOJO_HANDLE) {
*serialized = CreateSerializedHandle(
static_cast<internal::MojoHandleAttachment&>(*attachment).TakeHandle(),
mojom::SerializedHandle::Type::MOJO_HANDLE);
return MOJO_RESULT_OK;
}
#if defined(OS_POSIX)
- if (attachment->GetType() == MessageAttachment::TYPE_PLATFORM_FILE) {
+ if (attachment->GetType() == MessageAttachment::Type::PLATFORM_FILE) {
// We dup() the handles in IPC::Message to transmit.
// IPC::MessageAttachmentSet has intricate lifecycle semantics
// of FDs, so just to dup()-and-own them is the safest option.
@@ -148,10 +148,7 @@
}
#endif
#if defined(OS_MACOSX)
- DCHECK_EQ(attachment->GetType(),
- MessageAttachment::TYPE_BROKERABLE_ATTACHMENT);
- DCHECK_EQ(static_cast<BrokerableAttachment&>(*attachment).GetBrokerableType(),
- BrokerableAttachment::MACH_PORT);
+ DCHECK_EQ(attachment->GetType(), MessageAttachment::Type::MACH_PORT);
internal::MachPortAttachmentMac& mach_port_attachment =
static_cast<internal::MachPortAttachmentMac&>(*attachment);
MojoResult result = WrapMachPort(mach_port_attachment.get_mach_port(),
@@ -159,10 +156,7 @@
mach_port_attachment.reset_mach_port_ownership();
return result;
#elif defined(OS_WIN)
- DCHECK_EQ(attachment->GetType(),
- MessageAttachment::TYPE_BROKERABLE_ATTACHMENT);
- DCHECK_EQ(static_cast<BrokerableAttachment&>(*attachment).GetBrokerableType(),
- BrokerableAttachment::WIN_HANDLE);
+ DCHECK_EQ(attachment->GetType(), MessageAttachment::Type::WIN_HANDLE);
internal::HandleAttachmentWin& handle_attachment =
static_cast<internal::HandleAttachmentWin&>(*attachment);
MojoResult result = WrapPlatformHandle(
@@ -409,18 +403,9 @@
std::vector<mojom::SerializedHandlePtr> output_handles;
MessageAttachmentSet* set = message->attachment_set();
- for (unsigned i = 0;
- result == MOJO_RESULT_OK && i < set->num_non_brokerable_attachments();
- ++i) {
- result = WrapAttachment(set->GetNonBrokerableAttachmentAt(i).get(),
- &output_handles);
+ for (unsigned i = 0; result == MOJO_RESULT_OK && i < set->size(); ++i) {
+ result = WrapAttachment(set->GetAttachmentAt(i).get(), &output_handles);
}
- for (unsigned i = 0;
- result == MOJO_RESULT_OK && i < set->num_brokerable_attachments(); ++i) {
- result = WrapAttachment(set->GetBrokerableAttachmentAt(i).get(),
- &output_handles);
- }
-
set->CommitAllDescriptors();
if (!output_handles.empty())