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