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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() { | 234 void PickleSizer::AddAttachment() { |
235 // From IPC::Message::WriteAttachment | 235 // From IPC::Message::WriteAttachment |
236 AddBool(); | |
237 AddInt(); | 236 AddInt(); |
238 } | 237 } |
239 | 238 |
240 template <size_t length> void PickleSizer::AddBytesStatic() { | 239 template <size_t length> void PickleSizer::AddBytesStatic() { |
241 DCHECK_LE(length, static_cast<size_t>(std::numeric_limits<int>::max())); | 240 DCHECK_LE(length, static_cast<size_t>(std::numeric_limits<int>::max())); |
242 AddBytes(length); | 241 AddBytes(length); |
243 } | 242 } |
244 | 243 |
245 template void PickleSizer::AddBytesStatic<2>(); | 244 template void PickleSizer::AddBytesStatic<2>(); |
246 template void PickleSizer::AddBytesStatic<4>(); | 245 template void PickleSizer::AddBytesStatic<4>(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 473 |
475 inline void Pickle::WriteBytesCommon(const void* data, size_t length) { | 474 inline void Pickle::WriteBytesCommon(const void* data, size_t length) { |
476 DCHECK_NE(kCapacityReadOnly, capacity_after_header_) | 475 DCHECK_NE(kCapacityReadOnly, capacity_after_header_) |
477 << "oops: pickle is readonly"; | 476 << "oops: pickle is readonly"; |
478 MSAN_CHECK_MEM_IS_INITIALIZED(data, length); | 477 MSAN_CHECK_MEM_IS_INITIALIZED(data, length); |
479 void* write = ClaimUninitializedBytesInternal(length); | 478 void* write = ClaimUninitializedBytesInternal(length); |
480 memcpy(write, data, length); | 479 memcpy(write, data, length); |
481 } | 480 } |
482 | 481 |
483 } // namespace base | 482 } // namespace base |
OLD | NEW |