OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic/quic_data_reader.h" | 5 #include "net/quic/quic_data_reader.h" |
6 | 6 |
7 #include "net/base/int128.h" | 7 #include "net/base/int128.h" |
8 #include "net/quic/quic_protocol.h" | 8 #include "net/quic/quic_protocol.h" |
9 | 9 |
10 using base::StringPiece; | 10 using base::StringPiece; |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 QuicDataReader::QuicDataReader(const char* data, const size_t len) | 14 QuicDataReader::QuicDataReader(const char* data, const size_t len) |
15 : data_(data), | 15 : data_(data), len_(len), pos_(0) { |
16 len_(len), | |
17 pos_(0) { | |
18 } | 16 } |
19 | 17 |
20 bool QuicDataReader::ReadUInt16(uint16* result) { | 18 bool QuicDataReader::ReadUInt16(uint16* result) { |
21 return ReadBytes(result, sizeof(*result)); | 19 return ReadBytes(result, sizeof(*result)); |
22 } | 20 } |
23 | 21 |
24 bool QuicDataReader::ReadUInt32(uint32* result) { | 22 bool QuicDataReader::ReadUInt32(uint32* result) { |
25 return ReadBytes(result, sizeof(*result)); | 23 return ReadBytes(result, sizeof(*result)); |
26 } | 24 } |
27 | 25 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return bytes <= (len_ - pos_); | 156 return bytes <= (len_ - pos_); |
159 } | 157 } |
160 | 158 |
161 void QuicDataReader::OnFailure() { | 159 void QuicDataReader::OnFailure() { |
162 // Set our iterator to the end of the buffer so that further reads fail | 160 // Set our iterator to the end of the buffer so that further reads fail |
163 // immediately. | 161 // immediately. |
164 pos_ = len_; | 162 pos_ = len_; |
165 } | 163 } |
166 | 164 |
167 } // namespace net | 165 } // namespace net |
OLD | NEW |