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

Side by Side Diff: lib/src/protobuf/coded_buffer_reader.dart

Issue 886643002: pkg/protobuf: cleanup and prep for 0.3.5 release (Closed) Base URL: https://github.com/dart-lang/dart-protobuf.git@master
Patch Set: nits Created 5 years, 10 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
« no previous file with comments | « README.md ('k') | lib/src/protobuf/generated_message.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of protobuf; 5 part of protobuf;
6 6
7 class CodedBufferReader { 7 class CodedBufferReader {
8 static const int DEFAULT_RECURSION_LIMIT = 64; 8 static const int DEFAULT_RECURSION_LIMIT = 64;
9 static const int DEFAULT_SIZE_LIMIT = 64 << 20; 9 static const int DEFAULT_SIZE_LIMIT = 64 << 20;
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 void _checkLimit(int increment) { 56 void _checkLimit(int increment) {
57 assert(_currentLimit != -1); 57 assert(_currentLimit != -1);
58 _bufferPos += increment; 58 _bufferPos += increment;
59 if (_bufferPos > _currentLimit) { 59 if (_bufferPos > _currentLimit) {
60 throw new InvalidProtocolBufferException.truncatedMessage(); 60 throw new InvalidProtocolBufferException.truncatedMessage();
61 } 61 }
62 } 62 }
63 63
64 bool _canRead(int increment) => _bufferPos + increment <= _currentLimit;
65
66 void readGroup(int fieldNumber, GeneratedMessage message, 64 void readGroup(int fieldNumber, GeneratedMessage message,
67 ExtensionRegistry extensionRegistry) { 65 ExtensionRegistry extensionRegistry) {
68 if (_recursionDepth >= _recursionLimit) { 66 if (_recursionDepth >= _recursionLimit) {
69 throw new InvalidProtocolBufferException.recursionLimitExceeded(); 67 throw new InvalidProtocolBufferException.recursionLimitExceeded();
70 } 68 }
71 ++_recursionDepth; 69 ++_recursionDepth;
72 message.mergeFromCodedBufferReader(this); 70 message.mergeFromCodedBufferReader(this);
73 checkLastTagWas(makeTag(fieldNumber, WIRETYPE_END_GROUP)); 71 checkLastTagWas(makeTag(fieldNumber, WIRETYPE_END_GROUP));
74 --_recursionDepth; 72 --_recursionDepth;
75 } 73 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 207 }
210 throw new InvalidProtocolBufferException.malformedVarint(); 208 throw new InvalidProtocolBufferException.malformedVarint();
211 } 209 }
212 210
213 ByteData _readByteData(int sizeInBytes) { 211 ByteData _readByteData(int sizeInBytes) {
214 _checkLimit(sizeInBytes); 212 _checkLimit(sizeInBytes);
215 return new ByteData.view( 213 return new ByteData.view(
216 _buffer.buffer, _bufferPos - sizeInBytes, sizeInBytes); 214 _buffer.buffer, _bufferPos - sizeInBytes, sizeInBytes);
217 } 215 }
218 } 216 }
OLDNEW
« no previous file with comments | « README.md ('k') | lib/src/protobuf/generated_message.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698