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

Unified Diff: ipc/ipc_message_attachment_set.cc

Issue 1317093007: ipc: Make a new class PlaceholderBrokerableAttachment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase errors. Created 5 years, 3 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/placeholder_brokerable_attachment.h » ('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 1a4969f505159d318d0b7d684d8368863da49f12..6a8024fe9e6f019606f2172e35f878eda2ba47cb 100644
--- a/ipc/ipc_message_attachment_set.cc
+++ b/ipc/ipc_message_attachment_set.cc
@@ -143,17 +143,25 @@ MessageAttachmentSet::PeekBrokerableAttachments() const {
return output;
}
-std::vector<scoped_refptr<BrokerableAttachment>>
-MessageAttachmentSet::GetBrokerableAttachmentsForUpdating() {
- std::vector<scoped_refptr<BrokerableAttachment>> output;
- for (const scoped_refptr<MessageAttachment>& attachment : attachments_) {
- if (attachment->GetType() ==
- MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) {
- output.push_back(scoped_refptr<BrokerableAttachment>(
- static_cast<BrokerableAttachment*>(attachment.get())));
+void MessageAttachmentSet::ReplacePlaceholderWithAttachment(
+ const scoped_refptr<BrokerableAttachment>& attachment) {
+ for (auto it = attachments_.begin(); it != attachments_.end(); ++it) {
+ if ((*it)->GetType() != MessageAttachment::TYPE_BROKERABLE_ATTACHMENT)
+ continue;
+ BrokerableAttachment* brokerable_attachment =
+ static_cast<BrokerableAttachment*>(it->get());
+
+ if (brokerable_attachment->GetBrokerableType() ==
+ BrokerableAttachment::PLACEHOLDER &&
+ brokerable_attachment->GetIdentifier() == attachment->GetIdentifier()) {
+ *it = attachment;
+ return;
}
}
- return output;
+
+ // This function should only be called if there is a placeholder ready to be
+ // replaced.
+ NOTREACHED();
}
#if defined(OS_POSIX)
« no previous file with comments | « ipc/ipc_message_attachment_set.h ('k') | ipc/placeholder_brokerable_attachment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698