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/core/quic_data_reader.h" | 5 #include "net/quic/core/quic_data_reader.h" |
6 | 6 |
7 #include "net/base/int128.h" | 7 #include "net/base/int128.h" |
8 #include "net/quic/core/quic_flags.h" | 8 #include "net/quic/core/quic_flags.h" |
9 #include "net/quic/core/quic_packets.h" | 9 #include "net/quic/core/quic_packets.h" |
| 10 #include "net/quic/platform/api/quic_bug_tracker.h" |
10 #include "net/quic/platform/api/quic_endian.h" | 11 #include "net/quic/platform/api/quic_endian.h" |
11 #include "net/quic/platform/api/quic_logging.h" | 12 #include "net/quic/platform/api/quic_logging.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 | 15 |
15 #define ENDPOINT \ | 16 #define ENDPOINT \ |
16 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") | 17 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") |
17 | 18 |
18 QuicDataReader::QuicDataReader(const char* data, | 19 QuicDataReader::QuicDataReader(const char* data, |
19 const size_t len, | 20 const size_t len, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool QuicDataReader::CanRead(size_t bytes) const { | 148 bool QuicDataReader::CanRead(size_t bytes) const { |
148 return bytes <= (len_ - pos_); | 149 return bytes <= (len_ - pos_); |
149 } | 150 } |
150 | 151 |
151 void QuicDataReader::OnFailure() { | 152 void QuicDataReader::OnFailure() { |
152 // Set our iterator to the end of the buffer so that further reads fail | 153 // Set our iterator to the end of the buffer so that further reads fail |
153 // immediately. | 154 // immediately. |
154 pos_ = len_; | 155 pos_ = len_; |
155 } | 156 } |
156 | 157 |
| 158 uint8_t QuicDataReader::PeekByte() const { |
| 159 if (pos_ >= len_) { |
| 160 QUIC_BUG << "Reading is done, cannot peek next byte. Tried to read pos = " |
| 161 << pos_ << " buffer length = " << len_; |
| 162 return 0; |
| 163 } |
| 164 return data_[pos_]; |
| 165 } |
| 166 |
157 } // namespace net | 167 } // namespace net |
OLD | NEW |