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

Unified Diff: ipc/ipc_message.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/ipc_message.h ('k') | ipc/ipc_message_attachment.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message.cc
diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc
index f5e9ac7a8b807cd04842aa8139a5b9b8cfb0b9ee..008401f14f358c620a7e6a206bb9fb969fa63220 100644
--- a/ipc/ipc_message.cc
+++ b/ipc/ipc_message.cc
@@ -166,14 +166,18 @@
bool Message::WriteAttachment(
scoped_refptr<base::Pickle::Attachment> attachment) {
+ bool brokerable;
size_t index;
bool success = attachment_set()->AddAttachment(
make_scoped_refptr(static_cast<MessageAttachment*>(attachment.get())),
- &index);
+ &index, &brokerable);
DCHECK(success);
// NOTE: If you add more data to the pickle, make sure to update
// PickleSizer::AddAttachment.
+
+ // Write the type of descriptor.
+ WriteBool(brokerable);
// Write the index of the descriptor so that we don't have to
// keep the current descriptor as extra decoding state when deserialising.
@@ -185,6 +189,10 @@
bool Message::ReadAttachment(
base::PickleIterator* iter,
scoped_refptr<base::Pickle::Attachment>* attachment) const {
+ bool brokerable;
+ if (!iter->ReadBool(&brokerable))
+ return false;
+
int index;
if (!iter->ReadInt(&index))
return false;
@@ -193,7 +201,9 @@
if (!attachment_set)
return false;
- *attachment = attachment_set->GetAttachmentAt(index);
+ *attachment = brokerable
+ ? attachment_set->GetBrokerableAttachmentAt(index)
+ : attachment_set->GetNonBrokerableAttachmentAt(index);
return nullptr != attachment->get();
}
@@ -202,4 +212,13 @@
return attachment_set_.get() && !attachment_set_->empty();
}
+bool Message::HasMojoHandles() const {
+ return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0;
+}
+
+bool Message::HasBrokerableAttachments() const {
+ return attachment_set_.get() &&
+ attachment_set_->num_brokerable_attachments() > 0;
+}
+
} // namespace IPC
« no previous file with comments | « ipc/ipc_message.h ('k') | ipc/ipc_message_attachment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698