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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_message_attachment_set.h" 5 #include "ipc/ipc_message_attachment_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/posix/eintr_wrapper.h" 9 #include "base/posix/eintr_wrapper.h"
10 #include "ipc/brokerable_attachment.h" 10 #include "ipc/brokerable_attachment.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 std::vector<const BrokerableAttachment*> output; 136 std::vector<const BrokerableAttachment*> output;
137 for (const scoped_refptr<MessageAttachment>& attachment : attachments_) { 137 for (const scoped_refptr<MessageAttachment>& attachment : attachments_) {
138 if (attachment->GetType() == 138 if (attachment->GetType() ==
139 MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) { 139 MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) {
140 output.push_back(static_cast<BrokerableAttachment*>(attachment.get())); 140 output.push_back(static_cast<BrokerableAttachment*>(attachment.get()));
141 } 141 }
142 } 142 }
143 return output; 143 return output;
144 } 144 }
145 145
146 std::vector<scoped_refptr<BrokerableAttachment>> 146 void MessageAttachmentSet::ReplacePlaceholderWithAttachment(
147 MessageAttachmentSet::GetBrokerableAttachmentsForUpdating() { 147 const scoped_refptr<BrokerableAttachment>& attachment) {
148 std::vector<scoped_refptr<BrokerableAttachment>> output; 148 for (auto it = attachments_.begin(); it != attachments_.end(); ++it) {
149 for (const scoped_refptr<MessageAttachment>& attachment : attachments_) { 149 if ((*it)->GetType() != MessageAttachment::TYPE_BROKERABLE_ATTACHMENT)
150 if (attachment->GetType() == 150 continue;
151 MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) { 151 BrokerableAttachment* brokerable_attachment =
152 output.push_back(scoped_refptr<BrokerableAttachment>( 152 static_cast<BrokerableAttachment*>(it->get());
153 static_cast<BrokerableAttachment*>(attachment.get()))); 153
154 if (brokerable_attachment->GetBrokerableType() ==
155 BrokerableAttachment::PLACEHOLDER &&
156 brokerable_attachment->GetIdentifier() == attachment->GetIdentifier()) {
157 *it = attachment;
158 return;
154 } 159 }
155 } 160 }
156 return output; 161
162 // This function should only be called if there is a placeholder ready to be
163 // replaced.
164 NOTREACHED();
157 } 165 }
158 166
159 #if defined(OS_POSIX) 167 #if defined(OS_POSIX)
160 168
161 void MessageAttachmentSet::PeekDescriptors(base::PlatformFile* buffer) const { 169 void MessageAttachmentSet::PeekDescriptors(base::PlatformFile* buffer) const {
162 for (size_t i = 0; i != attachments_.size(); ++i) 170 for (size_t i = 0; i != attachments_.size(); ++i)
163 buffer[i] = internal::GetPlatformFile(attachments_[i]); 171 buffer[i] = internal::GetPlatformFile(attachments_[i]);
164 } 172 }
165 173
166 bool MessageAttachmentSet::ContainsDirectoryDescriptor() const { 174 bool MessageAttachmentSet::ContainsDirectoryDescriptor() const {
(...skipping 29 matching lines...) Expand all
196 for (unsigned i = 0; i < count; ++i) 204 for (unsigned i = 0; i < count; ++i)
197 AddAttachment( 205 AddAttachment(
198 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i]))); 206 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i])));
199 } 207 }
200 208
201 #endif // OS_POSIX 209 #endif // OS_POSIX
202 210
203 } // namespace IPC 211 } // namespace IPC
204 212
205 213
OLDNEW
« 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