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

Side by Side Diff: net/quic/core/quic_data_reader.cc

Issue 2808273006: Landing Recent QUIC changes until Sun Apr 9 16:12:55 (Closed)
Patch Set: increment enabled_options in e2e test Created 3 years, 8 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 | « net/quic/core/quic_data_reader.h ('k') | net/quic/core/quic_data_writer.h » ('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) 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/core/quic_utils.h"
11 #include "net/quic/platform/api/quic_bug_tracker.h"
10 #include "net/quic/platform/api/quic_endian.h" 12 #include "net/quic/platform/api/quic_endian.h"
11 #include "net/quic/platform/api/quic_logging.h" 13 #include "net/quic/platform/api/quic_logging.h"
12 14
13 namespace net { 15 namespace net {
14 16
15 #define ENDPOINT \ 17 #define ENDPOINT \
16 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") 18 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ")
17 19
18 QuicDataReader::QuicDataReader(const char* data, 20 QuicDataReader::QuicDataReader(const char* data,
19 const size_t len, 21 const size_t len,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 pos_ += size; 94 pos_ += size;
93 95
94 return true; 96 return true;
95 } 97 }
96 98
97 bool QuicDataReader::ReadConnectionId(uint64_t* connection_id) { 99 bool QuicDataReader::ReadConnectionId(uint64_t* connection_id) {
98 if (!ReadUInt64(connection_id)) { 100 if (!ReadUInt64(connection_id)) {
99 return false; 101 return false;
100 } 102 }
101 103
102 if (FLAGS_quic_restart_flag_quic_big_endian_connection_id) { 104 if (QuicUtils::IsConnectionIdWireFormatBigEndian(perspective_)) {
103 *connection_id = QuicEndian::NetToHost64(*connection_id); 105 *connection_id = QuicEndian::NetToHost64(*connection_id);
104 } 106 }
105 107
106 return true; 108 return true;
107 } 109 }
108 110
109 bool QuicDataReader::ReadTag(uint32_t* tag) { 111 bool QuicDataReader::ReadTag(uint32_t* tag) {
110 return ReadBytes(tag, sizeof(*tag)); 112 return ReadBytes(tag, sizeof(*tag));
111 } 113 }
112 114
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool QuicDataReader::CanRead(size_t bytes) const { 149 bool QuicDataReader::CanRead(size_t bytes) const {
148 return bytes <= (len_ - pos_); 150 return bytes <= (len_ - pos_);
149 } 151 }
150 152
151 void QuicDataReader::OnFailure() { 153 void QuicDataReader::OnFailure() {
152 // Set our iterator to the end of the buffer so that further reads fail 154 // Set our iterator to the end of the buffer so that further reads fail
153 // immediately. 155 // immediately.
154 pos_ = len_; 156 pos_ = len_;
155 } 157 }
156 158
159 uint8_t QuicDataReader::PeekByte() const {
160 if (pos_ >= len_) {
161 QUIC_BUG << "Reading is done, cannot peek next byte. Tried to read pos = "
162 << pos_ << " buffer length = " << len_;
163 return 0;
164 }
165 return data_[pos_];
166 }
167
157 } // namespace net 168 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_data_reader.h ('k') | net/quic/core/quic_data_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698