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

Side by Side Diff: base/pickle.cc

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Addressed feedback Created 4 years, 7 months 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) 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 DCHECK_GE(data_len, length); 357 DCHECK_GE(data_len, length);
358 #ifdef ARCH_CPU_64_BITS 358 #ifdef ARCH_CPU_64_BITS
359 DCHECK_LE(data_len, std::numeric_limits<uint32_t>::max()); 359 DCHECK_LE(data_len, std::numeric_limits<uint32_t>::max());
360 #endif 360 #endif
361 DCHECK_LE(write_offset_, std::numeric_limits<uint32_t>::max() - data_len); 361 DCHECK_LE(write_offset_, std::numeric_limits<uint32_t>::max() - data_len);
362 size_t new_size = write_offset_ + data_len; 362 size_t new_size = write_offset_ + data_len;
363 if (new_size > capacity_after_header_) 363 if (new_size > capacity_after_header_)
364 Resize(capacity_after_header_ * 2 + new_size); 364 Resize(capacity_after_header_ * 2 + new_size);
365 } 365 }
366 366
367 bool Pickle::WriteAttachment(scoped_refptr<Attachment> attachment) { 367 bool Pickle::WriteAttachment(scoped_refptr<Attachment> /*attachment*/) {
368 return false; 368 return false;
369 } 369 }
370 370
371 bool Pickle::ReadAttachment(base::PickleIterator* iter, 371 bool Pickle::ReadAttachment(base::PickleIterator* /*iter*/,
372 scoped_refptr<Attachment>* attachment) const { 372 scoped_refptr<Attachment>* /*attachment*/) const {
373 return false; 373 return false;
374 } 374 }
375 375
376 bool Pickle::HasAttachments() const { 376 bool Pickle::HasAttachments() const {
377 return false; 377 return false;
378 } 378 }
379 379
380 void Pickle::Resize(size_t new_capacity) { 380 void Pickle::Resize(size_t new_capacity) {
381 CHECK_NE(capacity_after_header_, kCapacityReadOnly); 381 CHECK_NE(capacity_after_header_, kCapacityReadOnly);
382 capacity_after_header_ = bits::Align(new_capacity, kPayloadUnit); 382 capacity_after_header_ = bits::Align(new_capacity, kPayloadUnit);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 inline void Pickle::WriteBytesCommon(const void* data, size_t length) { 475 inline void Pickle::WriteBytesCommon(const void* data, size_t length) {
476 DCHECK_NE(kCapacityReadOnly, capacity_after_header_) 476 DCHECK_NE(kCapacityReadOnly, capacity_after_header_)
477 << "oops: pickle is readonly"; 477 << "oops: pickle is readonly";
478 MSAN_CHECK_MEM_IS_INITIALIZED(data, length); 478 MSAN_CHECK_MEM_IS_INITIALIZED(data, length);
479 void* write = ClaimUninitializedBytesInternal(length); 479 void* write = ClaimUninitializedBytesInternal(length);
480 memcpy(write, data, length); 480 memcpy(write, data, length);
481 } 481 }
482 482
483 } // namespace base 483 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698