| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/spdy/spdy_prefixed_buffer_reader.h" | 5 #include "net/spdy/spdy_prefixed_buffer_reader.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| 11 SpdyPrefixedBufferReader::SpdyPrefixedBufferReader( | 11 SpdyPrefixedBufferReader::SpdyPrefixedBufferReader(const char* prefix, |
| 12 const char* prefix, | 12 size_t prefix_length, |
| 13 size_t prefix_length, | 13 const char* suffix, |
| 14 const char* suffix, | 14 size_t suffix_length) |
| 15 size_t suffix_length) | |
| 16 : prefix_(prefix), | 15 : prefix_(prefix), |
| 17 suffix_(suffix), | 16 suffix_(suffix), |
| 18 prefix_length_(prefix_length), | 17 prefix_length_(prefix_length), |
| 19 suffix_length_(suffix_length) {} | 18 suffix_length_(suffix_length) { |
| 19 } |
| 20 | 20 |
| 21 size_t SpdyPrefixedBufferReader::Available() { | 21 size_t SpdyPrefixedBufferReader::Available() { |
| 22 return prefix_length_ + suffix_length_; | 22 return prefix_length_ + suffix_length_; |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool SpdyPrefixedBufferReader::ReadN(size_t count, char* out) { | 25 bool SpdyPrefixedBufferReader::ReadN(size_t count, char* out) { |
| 26 if (Available() < count) | 26 if (Available() < count) |
| 27 return false; | 27 return false; |
| 28 | 28 |
| 29 if (prefix_length_ >= count) { | 29 if (prefix_length_ >= count) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 DCHECK(suffix_length_ >= count); | 72 DCHECK(suffix_length_ >= count); |
| 73 // Read is fully satisfied by the suffix. | 73 // Read is fully satisfied by the suffix. |
| 74 out->buffer_ = suffix_; | 74 out->buffer_ = suffix_; |
| 75 suffix_ += count; | 75 suffix_ += count; |
| 76 suffix_length_ -= count; | 76 suffix_length_ -= count; |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace net | 81 } // namespace net |
| OLD | NEW |