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 "base/pickle.h" | 5 #include "base/pickle.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <algorithm> // for max() | 9 #include <algorithm> // for max() |
10 #include <limits> | 10 #include <limits> |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 void PickleSizer::AddData(int length) { | 224 void PickleSizer::AddData(int length) { |
225 CHECK_GE(length, 0); | 225 CHECK_GE(length, 0); |
226 AddInt(); | 226 AddInt(); |
227 AddBytes(length); | 227 AddBytes(length); |
228 } | 228 } |
229 | 229 |
230 void PickleSizer::AddBytes(int length) { | 230 void PickleSizer::AddBytes(int length) { |
231 payload_size_ += bits::Align(length, sizeof(uint32_t)); | 231 payload_size_ += bits::Align(length, sizeof(uint32_t)); |
232 } | 232 } |
233 | 233 |
| 234 void PickleSizer::AddAttachment() { |
| 235 // From IPC::Message::WriteAttachment |
| 236 AddBool(); |
| 237 AddInt(); |
| 238 } |
| 239 |
234 template <size_t length> void PickleSizer::AddBytesStatic() { | 240 template <size_t length> void PickleSizer::AddBytesStatic() { |
235 DCHECK_LE(length, static_cast<size_t>(std::numeric_limits<int>::max())); | 241 DCHECK_LE(length, static_cast<size_t>(std::numeric_limits<int>::max())); |
236 AddBytes(length); | 242 AddBytes(length); |
237 } | 243 } |
238 | 244 |
239 template void PickleSizer::AddBytesStatic<2>(); | 245 template void PickleSizer::AddBytesStatic<2>(); |
240 template void PickleSizer::AddBytesStatic<4>(); | 246 template void PickleSizer::AddBytesStatic<4>(); |
241 template void PickleSizer::AddBytesStatic<8>(); | 247 template void PickleSizer::AddBytesStatic<8>(); |
242 | 248 |
243 Pickle::Attachment::Attachment() {} | 249 Pickle::Attachment::Attachment() {} |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 474 |
469 inline void Pickle::WriteBytesCommon(const void* data, size_t length) { | 475 inline void Pickle::WriteBytesCommon(const void* data, size_t length) { |
470 DCHECK_NE(kCapacityReadOnly, capacity_after_header_) | 476 DCHECK_NE(kCapacityReadOnly, capacity_after_header_) |
471 << "oops: pickle is readonly"; | 477 << "oops: pickle is readonly"; |
472 MSAN_CHECK_MEM_IS_INITIALIZED(data, length); | 478 MSAN_CHECK_MEM_IS_INITIALIZED(data, length); |
473 void* write = ClaimUninitializedBytesInternal(length); | 479 void* write = ClaimUninitializedBytesInternal(length); |
474 memcpy(write, data, length); | 480 memcpy(write, data, length); |
475 } | 481 } |
476 | 482 |
477 } // namespace base | 483 } // namespace base |
OLD | NEW |