Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: ipc/ipc_channel_mojo.cc

Issue 2504063002: Revert of Remove IPC::BrokerableAttachment. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/handle_win.cc ('k') | ipc/ipc_channel_mojo_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_mojo.cc
diff --git a/ipc/ipc_channel_mojo.cc b/ipc/ipc_channel_mojo.cc
index 5d468ab59b5446ef8cac9482bad6a8a375c95952..e71baff895e6892d9dc36d6d0bfc44f1f159b7eb 100644
--- a/ipc/ipc_channel_mojo.cc
+++ b/ipc/ipc_channel_mojo.cc
@@ -126,14 +126,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.
@@ -150,7 +150,10 @@
}
#endif
#if defined(OS_MACOSX)
- DCHECK_EQ(attachment->GetType(), MessageAttachment::Type::MACH_PORT);
+ DCHECK_EQ(attachment->GetType(),
+ MessageAttachment::TYPE_BROKERABLE_ATTACHMENT);
+ DCHECK_EQ(static_cast<BrokerableAttachment&>(*attachment).GetBrokerableType(),
+ BrokerableAttachment::MACH_PORT);
internal::MachPortAttachmentMac& mach_port_attachment =
static_cast<internal::MachPortAttachmentMac&>(*attachment);
MojoResult result = WrapMachPort(mach_port_attachment.get_mach_port(),
@@ -158,7 +161,10 @@
mach_port_attachment.reset_mach_port_ownership();
return result;
#elif defined(OS_WIN)
- DCHECK_EQ(attachment->GetType(), MessageAttachment::Type::WIN_HANDLE);
+ DCHECK_EQ(attachment->GetType(),
+ MessageAttachment::TYPE_BROKERABLE_ATTACHMENT);
+ DCHECK_EQ(static_cast<BrokerableAttachment&>(*attachment).GetBrokerableType(),
+ BrokerableAttachment::WIN_HANDLE);
internal::HandleAttachmentWin& handle_attachment =
static_cast<internal::HandleAttachmentWin&>(*attachment);
MojoResult result = WrapPlatformHandle(
@@ -405,9 +411,18 @@
std::vector<mojom::SerializedHandlePtr> output_handles;
MessageAttachmentSet* set = message->attachment_set();
- 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_non_brokerable_attachments();
+ ++i) {
+ result = WrapAttachment(set->GetNonBrokerableAttachmentAt(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())
« no previous file with comments | « ipc/handle_win.cc ('k') | ipc/ipc_channel_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698