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

Unified Diff: ipc/ipc_message_attachment_set.cc

Issue 866223005: IPC: Add MojoHandleAttachment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing windows build again... Created 5 years, 10 months 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_attachment_set.h ('k') | ipc/mojo/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_attachment_set.cc
diff --git a/ipc/ipc_message_attachment_set.cc b/ipc/ipc_message_attachment_set.cc
index dd881c5843f1090c210134ab3821c20e85da75bf..cb74a5aaf07193c8d57367923a52557d40999ab4 100644
--- a/ipc/ipc_message_attachment_set.cc
+++ b/ipc/ipc_message_attachment_set.cc
@@ -45,6 +45,13 @@ unsigned MessageAttachmentSet::num_descriptors() const {
});
}
+unsigned MessageAttachmentSet::num_mojo_handles() const {
+ return std::count_if(attachments_.begin(), attachments_.end(),
+ [](scoped_refptr<MessageAttachment> i) {
+ return i->GetType() == MessageAttachment::TYPE_MOJO_HANDLE;
+ });
+}
+
unsigned MessageAttachmentSet::size() const {
return static_cast<unsigned>(attachments_.size());
}
@@ -52,7 +59,7 @@ unsigned MessageAttachmentSet::size() const {
bool MessageAttachmentSet::AddAttachment(
scoped_refptr<MessageAttachment> attachment) {
#if defined(OS_POSIX)
- if (attachment->GetType() != MessageAttachment::TYPE_PLATFORM_FILE ||
+ if (attachment->GetType() == MessageAttachment::TYPE_PLATFORM_FILE &&
num_descriptors() == kMaxDescriptorsPerMessage) {
DLOG(WARNING) << "Cannot add file descriptor. MessageAttachmentSet full.";
return false;
@@ -102,6 +109,11 @@ scoped_refptr<MessageAttachment> MessageAttachmentSet::GetAttachmentAt(
return attachments_[index];
}
+void MessageAttachmentSet::CommitAll() {
+ attachments_.clear();
+ consumed_descriptor_highwater_ = 0;
+}
+
#if defined(OS_POSIX)
void MessageAttachmentSet::PeekDescriptors(base::PlatformFile* buffer) const {
@@ -120,11 +132,6 @@ bool MessageAttachmentSet::ContainsDirectoryDescriptor() const {
return false;
}
-void MessageAttachmentSet::CommitAll() {
- attachments_.clear();
- consumed_descriptor_highwater_ = 0;
-}
-
void MessageAttachmentSet::ReleaseFDsToClose(
std::vector<base::PlatformFile>* fds) {
for (size_t i = 0; i < attachments_.size(); ++i) {
« no previous file with comments | « ipc/ipc_message_attachment_set.h ('k') | ipc/mojo/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698