diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 20:23:43 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 20:23:43 +0000 |
commit | 9989c9bb16d23b11ff55daf8545b76c2eeba3440 (patch) | |
tree | 29637e8e9bb9c56fd04369405de6bfc4e73e151a /base/pickle.cc | |
parent | 3abebda09095620356405de505db7dd5bb22f3fd (diff) | |
download | chromium_src-9989c9bb16d23b11ff55daf8545b76c2eeba3440.zip chromium_src-9989c9bb16d23b11ff55daf8545b76c2eeba3440.tar.gz chromium_src-9989c9bb16d23b11ff55daf8545b76c2eeba3440.tar.bz2 |
Make the order of methods in the cc files match the headers in base/.
BUG=68682
TEST=compiles
Review URL: http://codereview.chromium.org/6189001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pickle.cc')
-rw-r--r-- | base/pickle.cc | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/base/pickle.cc b/base/pickle.cc index 3f376e3..a05df28 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -140,12 +140,6 @@ bool Pickle::ReadLong(void** iter, long* result) const { return true; } -bool Pickle::ReadLength(void** iter, int* result) const { - if (!ReadInt(iter, result)) - return false; - return ((*result) >= 0); -} - bool Pickle::ReadSize(void** iter, size_t* result) const { DCHECK(iter); if (!*iter) @@ -256,22 +250,6 @@ bool Pickle::ReadString16(void** iter, string16* result) const { return true; } -bool Pickle::ReadBytes(void** iter, const char** data, int length) const { - DCHECK(iter); - DCHECK(data); - *data = 0; - if (!*iter) - *iter = const_cast<char*>(payload()); - - if (!IteratorHasRoomFor(*iter, length)) - return false; - - *data = reinterpret_cast<const char*>(*iter); - - UpdateIter(iter, length); - return true; -} - bool Pickle::ReadData(void** iter, const char** data, int* length) const { DCHECK(iter); DCHECK(data); @@ -285,41 +263,26 @@ bool Pickle::ReadData(void** iter, const char** data, int* length) const { return ReadBytes(iter, data, *length); } -char* Pickle::BeginWrite(size_t length) { - // write at a uint32-aligned offset from the beginning of the header - size_t offset = AlignInt(header_->payload_size, sizeof(uint32)); - - size_t new_size = offset + length; - size_t needed_size = header_size_ + new_size; - if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size))) - return NULL; +bool Pickle::ReadBytes(void** iter, const char** data, int length) const { + DCHECK(iter); + DCHECK(data); + *data = 0; + if (!*iter) + *iter = const_cast<char*>(payload()); -#ifdef ARCH_CPU_64_BITS - DCHECK_LE(length, std::numeric_limits<uint32>::max()); -#endif + if (!IteratorHasRoomFor(*iter, length)) + return false; - header_->payload_size = static_cast<uint32>(new_size); - return payload() + offset; -} + *data = reinterpret_cast<const char*>(*iter); -void Pickle::EndWrite(char* dest, int length) { - // Zero-pad to keep tools like purify from complaining about uninitialized - // memory. - if (length % sizeof(uint32)) - memset(dest + length, 0, sizeof(uint32) - (length % sizeof(uint32))); + UpdateIter(iter, length); + return true; } -bool Pickle::WriteBytes(const void* data, int data_len) { - DCHECK(capacity_ != kCapacityReadOnly) << "oops: pickle is readonly"; - - char* dest = BeginWrite(data_len); - if (!dest) +bool Pickle::ReadLength(void** iter, int* result) const { + if (!ReadInt(iter, result)) return false; - - memcpy(dest, data, data_len); - - EndWrite(dest, data_len); - return true; + return ((*result) >= 0); } bool Pickle::WriteString(const std::string& value) { @@ -349,6 +312,19 @@ bool Pickle::WriteData(const char* data, int length) { return length >= 0 && WriteInt(length) && WriteBytes(data, length); } +bool Pickle::WriteBytes(const void* data, int data_len) { + DCHECK(capacity_ != kCapacityReadOnly) << "oops: pickle is readonly"; + + char* dest = BeginWrite(data_len); + if (!dest) + return false; + + memcpy(dest, data, data_len); + + EndWrite(dest, data_len); + return true; +} + char* Pickle::BeginWriteData(int length) { DCHECK_EQ(variable_buffer_offset_, 0U) << "There can only be one variable buffer in a Pickle"; @@ -386,6 +362,30 @@ void Pickle::TrimWriteData(int new_length) { *cur_length = new_length; } +char* Pickle::BeginWrite(size_t length) { + // write at a uint32-aligned offset from the beginning of the header + size_t offset = AlignInt(header_->payload_size, sizeof(uint32)); + + size_t new_size = offset + length; + size_t needed_size = header_size_ + new_size; + if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size))) + return NULL; + +#ifdef ARCH_CPU_64_BITS + DCHECK_LE(length, std::numeric_limits<uint32>::max()); +#endif + + header_->payload_size = static_cast<uint32>(new_size); + return payload() + offset; +} + +void Pickle::EndWrite(char* dest, int length) { + // Zero-pad to keep tools like purify from complaining about uninitialized + // memory. + if (length % sizeof(uint32)) + memset(dest + length, 0, sizeof(uint32) - (length % sizeof(uint32))); +} + bool Pickle::Resize(size_t new_capacity) { new_capacity = AlignInt(new_capacity, kPayloadUnit); |