| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Streams classes. | 5 // Streams classes. | 
| 6 // | 6 // | 
| 7 // These memory-resident streams are used for serializing data into a sequential | 7 // These memory-resident streams are used for serializing data into a sequential | 
| 8 // region of memory. | 8 // region of memory. | 
| 9 // | 9 // | 
| 10 // Streams are divided into SourceStreams for reading and SinkStreams for | 10 // Streams are divided into SourceStreams for reading and SinkStreams for | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 108     return source; | 108     return source; | 
| 109   } | 109   } | 
| 110 | 110 | 
| 111   return NULL;  // Value is too long to be a Varint32. | 111   return NULL;  // Value is too long to be a Varint32. | 
| 112 } | 112 } | 
| 113 | 113 | 
| 114 // Write the base-128 digits in little-endian order.  All except the last digit | 114 // Write the base-128 digits in little-endian order.  All except the last digit | 
| 115 // have the high bit set to indicate more digits. | 115 // have the high bit set to indicate more digits. | 
| 116 inline uint8* Varint::Encode32(uint8* destination, uint32 value) { | 116 inline uint8* Varint::Encode32(uint8* destination, uint32 value) { | 
| 117   while (value >= 128) { | 117   while (value >= 128) { | 
| 118     *(destination++) = value | 128; | 118     *(destination++) = static_cast<uint8>(value) | 128; | 
| 119     value = value >> 7; | 119     value = value >> 7; | 
| 120   } | 120   } | 
| 121   *(destination++) = value; | 121   *(destination++) = static_cast<uint8>(value); | 
| 122   return destination; | 122   return destination; | 
| 123 } | 123 } | 
| 124 | 124 | 
| 125 void SourceStream::Init(const SinkStream& sink) { | 125 void SourceStream::Init(const SinkStream& sink) { | 
| 126   Init(sink.Buffer(), sink.Length()); | 126   Init(sink.Buffer(), sink.Length()); | 
| 127 } | 127 } | 
| 128 | 128 | 
| 129 bool SourceStream::Read(void* destination, size_t count) { | 129 bool SourceStream::Read(void* destination, size_t count) { | 
| 130   if (current_ + count > end_) | 130   if (current_ + count > end_) | 
| 131     return false; | 131     return false; | 
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 381     ret = control_stream->WriteSizeVarint32(lengths[i]); | 381     ret = control_stream->WriteSizeVarint32(lengths[i]); | 
| 382   } | 382   } | 
| 383 | 383 | 
| 384   for (size_t i = 0; ret && i < stream_count; ++i) { | 384   for (size_t i = 0; ret && i < stream_count; ++i) { | 
| 385     ret = this->stream(i)->Append(set->stream(i)); | 385     ret = this->stream(i)->Append(set->stream(i)); | 
| 386   } | 386   } | 
| 387   return ret; | 387   return ret; | 
| 388 } | 388 } | 
| 389 | 389 | 
| 390 }  // namespace | 390 }  // namespace | 
| OLD | NEW | 
|---|