OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void MessageAttachmentSet::CommitAllDescriptors() { | 177 void MessageAttachmentSet::CommitAllDescriptors() { |
178 attachments_.clear(); | 178 attachments_.clear(); |
179 consumed_descriptor_highwater_ = 0; | 179 consumed_descriptor_highwater_ = 0; |
180 } | 180 } |
181 | 181 |
182 std::vector<scoped_refptr<IPC::BrokerableAttachment>> | 182 std::vector<scoped_refptr<IPC::BrokerableAttachment>> |
183 MessageAttachmentSet::GetBrokerableAttachments() const { | 183 MessageAttachmentSet::GetBrokerableAttachments() const { |
184 return brokerable_attachments_; | 184 return brokerable_attachments_; |
185 } | 185 } |
186 | 186 |
187 void MessageAttachmentSet::ReplacePlaceholderWithAttachment( | |
188 const scoped_refptr<BrokerableAttachment>& attachment) { | |
189 DCHECK_NE(BrokerableAttachment::PLACEHOLDER, attachment->GetBrokerableType()); | |
190 for (auto it = brokerable_attachments_.begin(); | |
191 it != brokerable_attachments_.end(); ++it) { | |
192 if ((*it)->GetBrokerableType() == BrokerableAttachment::PLACEHOLDER && | |
193 (*it)->GetIdentifier() == attachment->GetIdentifier()) { | |
194 *it = attachment; | |
195 return; | |
196 } | |
197 } | |
198 | |
199 // This function should only be called if there is a placeholder ready to be | |
200 // replaced. | |
201 NOTREACHED(); | |
202 } | |
203 | |
204 #if defined(OS_POSIX) | 187 #if defined(OS_POSIX) |
205 | 188 |
206 void MessageAttachmentSet::PeekDescriptors(base::PlatformFile* buffer) const { | 189 void MessageAttachmentSet::PeekDescriptors(base::PlatformFile* buffer) const { |
207 for (size_t i = 0; i != attachments_.size(); ++i) | 190 for (size_t i = 0; i != attachments_.size(); ++i) |
208 buffer[i] = internal::GetPlatformFile(attachments_[i]); | 191 buffer[i] = internal::GetPlatformFile(attachments_[i]); |
209 } | 192 } |
210 | 193 |
211 bool MessageAttachmentSet::ContainsDirectoryDescriptor() const { | 194 bool MessageAttachmentSet::ContainsDirectoryDescriptor() const { |
212 struct stat st; | 195 struct stat st; |
213 | 196 |
(...skipping 27 matching lines...) Expand all Loading... |
241 for (unsigned i = 0; i < count; ++i) | 224 for (unsigned i = 0; i < count; ++i) |
242 AddAttachment( | 225 AddAttachment( |
243 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i]))); | 226 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i]))); |
244 } | 227 } |
245 | 228 |
246 #endif // OS_POSIX | 229 #endif // OS_POSIX |
247 | 230 |
248 } // namespace IPC | 231 } // namespace IPC |
249 | 232 |
250 | 233 |
OLD | NEW |