diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-08-14 11:38:45 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-08-14 17:16:47 +0000 |
commit | 3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859 (patch) | |
tree | 43cc572ba067417c7341db81f71ae7cc6e0fcc3e /chromium/ipc/ipc_message_attachment_set.cc | |
parent | f61ab1ac7f855cd281809255c0aedbb1895e1823 (diff) | |
download | qtwebengine-chromium-3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859.tar.gz |
BASELINE: Update chromium to 45.0.2454.40
Change-Id: Id2121d9f11a8fc633677236c65a3e41feef589e4
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/ipc/ipc_message_attachment_set.cc')
-rw-r--r-- | chromium/ipc/ipc_message_attachment_set.cc | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/chromium/ipc/ipc_message_attachment_set.cc b/chromium/ipc/ipc_message_attachment_set.cc index cb74a5aaf07..ed653f3466a 100644 --- a/chromium/ipc/ipc_message_attachment_set.cc +++ b/chromium/ipc/ipc_message_attachment_set.cc @@ -7,6 +7,7 @@ #include <algorithm> #include "base/logging.h" #include "base/posix/eintr_wrapper.h" +#include "ipc/brokerable_attachment.h" #include "ipc/ipc_message_attachment.h" #if defined(OS_POSIX) @@ -18,6 +19,21 @@ namespace IPC { +namespace { + +unsigned count_attachments_of_type( + const std::vector<scoped_refptr<MessageAttachment>>& attachments, + MessageAttachment::Type type) { + unsigned count = 0; + for (const scoped_refptr<MessageAttachment>& attachment : attachments) { + if (attachment->GetType() == type) + ++count; + } + return count; +} + +} // namespace + MessageAttachmentSet::MessageAttachmentSet() : consumed_descriptor_highwater_(0) { } @@ -39,17 +55,18 @@ MessageAttachmentSet::~MessageAttachmentSet() { } unsigned MessageAttachmentSet::num_descriptors() const { - return std::count_if(attachments_.begin(), attachments_.end(), - [](scoped_refptr<MessageAttachment> i) { - return i->GetType() == MessageAttachment::TYPE_PLATFORM_FILE; - }); + return count_attachments_of_type(attachments_, + MessageAttachment::TYPE_PLATFORM_FILE); } 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; - }); + return count_attachments_of_type(attachments_, + MessageAttachment::TYPE_MOJO_HANDLE); +} + +unsigned MessageAttachmentSet::num_brokerable_attachments() const { + return count_attachments_of_type( + attachments_, MessageAttachment::TYPE_BROKERABLE_ATTACHMENT); } unsigned MessageAttachmentSet::size() const { @@ -114,6 +131,18 @@ void MessageAttachmentSet::CommitAll() { consumed_descriptor_highwater_ = 0; } +std::vector<const BrokerableAttachment*> +MessageAttachmentSet::PeekBrokerableAttachments() const { + std::vector<const BrokerableAttachment*> output; + for (const scoped_refptr<MessageAttachment>& attachment : attachments_) { + if (attachment->GetType() == + MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) { + output.push_back(static_cast<BrokerableAttachment*>(attachment.get())); + } + } + return output; +} + #if defined(OS_POSIX) void MessageAttachmentSet::PeekDescriptors(base::PlatformFile* buffer) const { |