OLD | NEW |
---|---|
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 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 #endif | 140 #endif |
141 | 141 |
142 Message::NextMessageInfo::NextMessageInfo() | 142 Message::NextMessageInfo::NextMessageInfo() |
143 : message_size(0), message_found(false), pickle_end(nullptr), | 143 : message_size(0), message_found(false), pickle_end(nullptr), |
144 message_end(nullptr) {} | 144 message_end(nullptr) {} |
145 Message::NextMessageInfo::~NextMessageInfo() {} | 145 Message::NextMessageInfo::~NextMessageInfo() {} |
146 | 146 |
147 Message::SerializedAttachmentIds | 147 Message::SerializedAttachmentIds |
148 Message::SerializedIdsOfBrokerableAttachments() { | 148 Message::SerializedIdsOfBrokerableAttachments() { |
149 DCHECK(HasBrokerableAttachments()); | 149 DCHECK(HasBrokerableAttachments()); |
150 std::vector<BrokerableAttachment*> attachments = | 150 std::vector<scoped_refptr<IPC::BrokerableAttachment>> attachments( |
Tom Sepez
2015/10/29 19:12:51
and here too
| |
151 attachment_set_->GetBrokerableAttachments(); | 151 attachment_set_->GetBrokerableAttachments()); |
152 CHECK_LE(attachments.size(), std::numeric_limits<size_t>::max() / | 152 CHECK_LE(attachments.size(), std::numeric_limits<size_t>::max() / |
153 BrokerableAttachment::kNonceSize); | 153 BrokerableAttachment::kNonceSize); |
154 size_t size = attachments.size() * BrokerableAttachment::kNonceSize; | 154 size_t size = attachments.size() * BrokerableAttachment::kNonceSize; |
155 char* buffer = static_cast<char*>(malloc(size)); | 155 char* buffer = static_cast<char*>(malloc(size)); |
156 for (size_t i = 0; i < attachments.size(); ++i) { | 156 for (size_t i = 0; i < attachments.size(); ++i) { |
157 const BrokerableAttachment* attachment = attachments[i]; | |
158 char* start_range = buffer + i * BrokerableAttachment::kNonceSize; | 157 char* start_range = buffer + i * BrokerableAttachment::kNonceSize; |
159 BrokerableAttachment::AttachmentId id = attachment->GetIdentifier(); | 158 BrokerableAttachment::AttachmentId id = attachments[i]->GetIdentifier(); |
160 id.SerializeToBuffer(start_range, BrokerableAttachment::kNonceSize); | 159 id.SerializeToBuffer(start_range, BrokerableAttachment::kNonceSize); |
161 } | 160 } |
162 SerializedAttachmentIds ids; | 161 SerializedAttachmentIds ids; |
163 ids.buffer = buffer; | 162 ids.buffer = buffer; |
164 ids.size = size; | 163 ids.size = size; |
165 return ids; | 164 return ids; |
166 } | 165 } |
167 | 166 |
168 // static | 167 // static |
169 void Message::FindNext(const char* range_start, | 168 void Message::FindNext(const char* range_start, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 bool Message::HasMojoHandles() const { | 289 bool Message::HasMojoHandles() const { |
291 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; | 290 return attachment_set_.get() && attachment_set_->num_mojo_handles() > 0; |
292 } | 291 } |
293 | 292 |
294 bool Message::HasBrokerableAttachments() const { | 293 bool Message::HasBrokerableAttachments() const { |
295 return attachment_set_.get() && | 294 return attachment_set_.get() && |
296 attachment_set_->num_brokerable_attachments() > 0; | 295 attachment_set_->num_brokerable_attachments() > 0; |
297 } | 296 } |
298 | 297 |
299 } // namespace IPC | 298 } // namespace IPC |
OLD | NEW |