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

Side by Side Diff: ipc/ipc_message.cc

Issue 2504063002: Revert of Remove IPC::BrokerableAttachment. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « ipc/ipc_message.h ('k') | ipc/ipc_message_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 5 #include "ipc/ipc_message.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const char* pickle_end = range_start + pickle_size; 159 const char* pickle_end = range_start + pickle_size;
160 160
161 info->message_end = pickle_end; 161 info->message_end = pickle_end;
162 162
163 info->pickle_end = pickle_end; 163 info->pickle_end = pickle_end;
164 info->message_found = true; 164 info->message_found = true;
165 } 165 }
166 166
167 bool Message::WriteAttachment( 167 bool Message::WriteAttachment(
168 scoped_refptr<base::Pickle::Attachment> attachment) { 168 scoped_refptr<base::Pickle::Attachment> attachment) {
169 bool brokerable;
169 size_t index; 170 size_t index;
170 bool success = attachment_set()->AddAttachment( 171 bool success = attachment_set()->AddAttachment(
171 make_scoped_refptr(static_cast<MessageAttachment*>(attachment.get())), 172 make_scoped_refptr(static_cast<MessageAttachment*>(attachment.get())),
172 &index); 173 &index, &brokerable);
173 DCHECK(success); 174 DCHECK(success);
174 175
175 // NOTE: If you add more data to the pickle, make sure to update 176 // NOTE: If you add more data to the pickle, make sure to update
176 // PickleSizer::AddAttachment. 177 // PickleSizer::AddAttachment.
177 178
179 // Write the type of descriptor.
180 WriteBool(brokerable);
181
178 // Write the index of the descriptor so that we don't have to 182 // Write the index of the descriptor so that we don't have to
179 // keep the current descriptor as extra decoding state when deserialising. 183 // keep the current descriptor as extra decoding state when deserialising.
180 WriteInt(static_cast<int>(index)); 184 WriteInt(static_cast<int>(index));
181 185
182 return success; 186 return success;
183 } 187 }
184 188
185 bool Message::ReadAttachment( 189 bool Message::ReadAttachment(
186 base::PickleIterator* iter, 190 base::PickleIterator* iter,
187 scoped_refptr<base::Pickle::Attachment>* attachment) const { 191 scoped_refptr<base::Pickle::Attachment>* attachment) const {
192 bool brokerable;
193 if (!iter->ReadBool(&brokerable))
194 return false;
195
188 int index; 196 int index;
189 if (!iter->ReadInt(&index)) 197 if (!iter->ReadInt(&index))
190 return false; 198 return false;
191 199
192 MessageAttachmentSet* attachment_set = attachment_set_.get(); 200 MessageAttachmentSet* attachment_set = attachment_set_.get();
193 if (!attachment_set) 201 if (!attachment_set)
194 return false; 202 return false;
195 203
196 *attachment = attachment_set->GetAttachmentAt(index); 204 *attachment = brokerable
205 ? attachment_set->GetBrokerableAttachmentAt(index)
206 : attachment_set->GetNonBrokerableAttachmentAt(index);
197 207
198 return nullptr != attachment->get(); 208 return nullptr != attachment->get();
199 } 209 }
200 210
201 bool Message::HasAttachments() const { 211 bool Message::HasAttachments() const {
202 return attachment_set_.get() && !attachment_set_->empty(); 212 return attachment_set_.get() && !attachment_set_->empty();
203 } 213 }
204 214
215 bool Message::HasMojoHandles() const {
216 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0;
217 }
218
219 bool Message::HasBrokerableAttachments() const {
220 return attachment_set_.get() &&
221 attachment_set_->num_brokerable_attachments() > 0;
222 }
223
205 } // namespace IPC 224 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_message.h ('k') | ipc/ipc_message_attachment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698