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

Side by Side Diff: ipc/ipc_message_attachment_set.cc

Issue 1414503009: IPC: Remove unnecessary conversions of BrokerableAttachment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 scoped_refptr<BrokerableAttachment> attachment) {
Tom Sepez 2015/10/29 19:12:51 I think this can still be const&
erikchen 2015/10/29 19:53:54 Passing by const& will produce the wrong behavior
190 for (auto it = brokerable_attachments_.begin(); 185 for (auto it = brokerable_attachments_.begin();
191 it != brokerable_attachments_.end(); ++it) { 186 it != brokerable_attachments_.end(); ++it) {
192 BrokerableAttachment* brokerable_attachment = 187 if ((*it)->GetBrokerableType() == BrokerableAttachment::PLACEHOLDER &&
193 static_cast<BrokerableAttachment*>(it->get()); 188 (*it)->GetIdentifier() == attachment->GetIdentifier()) {
194
195 if (brokerable_attachment->GetBrokerableType() ==
196 BrokerableAttachment::PLACEHOLDER &&
197 brokerable_attachment->GetIdentifier() == attachment->GetIdentifier()) {
198 *it = attachment; 189 *it = attachment;
199 return; 190 return;
200 } 191 }
201 } 192 }
202 193
203 // This function should only be called if there is a placeholder ready to be 194 // This function should only be called if there is a placeholder ready to be
204 // replaced. 195 // replaced.
205 NOTREACHED(); 196 NOTREACHED();
206 } 197 }
207 198
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 for (unsigned i = 0; i < count; ++i) 236 for (unsigned i = 0; i < count; ++i)
246 AddAttachment( 237 AddAttachment(
247 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i]))); 238 new internal::PlatformFileAttachment(base::ScopedFD(buffer[i])));
248 } 239 }
249 240
250 #endif // OS_POSIX 241 #endif // OS_POSIX
251 242
252 } // namespace IPC 243 } // namespace IPC
253 244
254 245
OLDNEW
« ipc/ipc_message_attachment_set.h ('K') | « ipc/ipc_message_attachment_set.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698