| 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 <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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 scoped_refptr<BrokerableAttachment> brokerable_attachment( | 168 scoped_refptr<BrokerableAttachment> brokerable_attachment( |
| 169 brokerable_attachments_[index]); | 169 brokerable_attachments_[index]); |
| 170 return scoped_refptr<MessageAttachment>(brokerable_attachment.get()); | 170 return scoped_refptr<MessageAttachment>(brokerable_attachment.get()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void MessageAttachmentSet::CommitAllDescriptors() { | 173 void MessageAttachmentSet::CommitAllDescriptors() { |
| 174 attachments_.clear(); | 174 attachments_.clear(); |
| 175 consumed_descriptor_highwater_ = 0; | 175 consumed_descriptor_highwater_ = 0; |
| 176 } | 176 } |
| 177 | 177 |
| 178 std::vector<BrokerableAttachment*> | 178 std::vector<scoped_refptr<IPC::BrokerableAttachment>> |
| 179 MessageAttachmentSet::GetBrokerableAttachments() const { | 179 MessageAttachmentSet::GetBrokerableAttachments() const { |
| 180 std::vector<BrokerableAttachment*> output; | 180 return brokerable_attachments_; |
| 181 for (const scoped_refptr<MessageAttachment>& attachment : | |
| 182 brokerable_attachments_) { | |
| 183 output.push_back(static_cast<BrokerableAttachment*>(attachment.get())); | |
| 184 } | |
| 185 return output; | |
| 186 } | 181 } |
| 187 | 182 |
| 188 void MessageAttachmentSet::ReplacePlaceholderWithAttachment( | 183 void MessageAttachmentSet::ReplacePlaceholderWithAttachment( |
| 189 const scoped_refptr<BrokerableAttachment>& attachment) { | 184 const scoped_refptr<BrokerableAttachment>& attachment) { |
| 185 DCHECK_NE(BrokerableAttachment::PLACEHOLDER, attachment->GetBrokerableType()); |
| 190 for (auto it = brokerable_attachments_.begin(); | 186 for (auto it = brokerable_attachments_.begin(); |
| 191 it != brokerable_attachments_.end(); ++it) { | 187 it != brokerable_attachments_.end(); ++it) { |
| 192 BrokerableAttachment* brokerable_attachment = | 188 if ((*it)->GetBrokerableType() == BrokerableAttachment::PLACEHOLDER && |
| 193 static_cast<BrokerableAttachment*>(it->get()); | 189 (*it)->GetIdentifier() == attachment->GetIdentifier()) { |
| 194 | |
| 195 if (brokerable_attachment->GetBrokerableType() == | |
| 196 BrokerableAttachment::PLACEHOLDER && | |
| 197 brokerable_attachment->GetIdentifier() == attachment->GetIdentifier()) { | |
| 198 *it = attachment; | 190 *it = attachment; |
| 199 return; | 191 return; |
| 200 } | 192 } |
| 201 } | 193 } |
| 202 | 194 |
| 203 // This function should only be called if there is a placeholder ready to be | 195 // This function should only be called if there is a placeholder ready to be |
| 204 // replaced. | 196 // replaced. |
| 205 NOTREACHED(); | 197 NOTREACHED(); |
| 206 } | 198 } |
| 207 | 199 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 for (unsigned i = 0; i < count; ++i) | 237 for (unsigned i = 0; i < count; ++i) |
| 246 AddAttachment( | 238 AddAttachment( |
| 247 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i]))); | 239 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i]))); |
| 248 } | 240 } |
| 249 | 241 |
| 250 #endif // OS_POSIX | 242 #endif // OS_POSIX |
| 251 | 243 |
| 252 } // namespace IPC | 244 } // namespace IPC |
| 253 | 245 |
| 254 | 246 |
| OLD | NEW |