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

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

Issue 973683003: CL generated with data from dead-code analysis using (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Change_PrrSender_TimeUntilSend_87535917
Patch Set: Created 5 years, 9 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/quic_data_reader.h ('k') | net/quic/quic_data_stream.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/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),
16 len_(len), 16 len_(len),
17 pos_(0) { 17 pos_(0) {
18 } 18 }
19 19
20 bool QuicDataReader::ReadUInt16(uint16* result) { 20 bool QuicDataReader::ReadUInt16(uint16* result) {
21 return ReadBytes(result, sizeof(*result)); 21 return ReadBytes(result, sizeof(*result));
22 } 22 }
23 23
24 bool QuicDataReader::ReadUInt32(uint32* result) { 24 bool QuicDataReader::ReadUInt32(uint32* result) {
25 return ReadBytes(result, sizeof(*result)); 25 return ReadBytes(result, sizeof(*result));
26 } 26 }
27 27
28 bool QuicDataReader::ReadUInt48(uint64* result) {
29 uint32 lo;
30 if (!ReadUInt32(&lo)) {
31 return false;
32 }
33
34 uint16 hi;
35 if (!ReadUInt16(&hi)) {
36 return false;
37 }
38
39 *result = hi;
40 *result <<= 32;
41 *result += lo;
42
43 return true;
44 }
45
46 bool QuicDataReader::ReadUInt64(uint64* result) { 28 bool QuicDataReader::ReadUInt64(uint64* result) {
47 return ReadBytes(result, sizeof(*result)); 29 return ReadBytes(result, sizeof(*result));
48 } 30 }
49 31
50 bool QuicDataReader::ReadUInt128(uint128* result) {
51 uint64 high_hash;
52 uint64 low_hash;
53
54 if (!ReadUInt64(&low_hash)) {
55 return false;
56 }
57 if (!ReadUInt64(&high_hash)) {
58 return false;
59 }
60
61 *result = uint128(high_hash, low_hash);
62 return true;
63 }
64
65 bool QuicDataReader::ReadUFloat16(uint64* result) { 32 bool QuicDataReader::ReadUFloat16(uint64* result) {
66 uint16 value; 33 uint16 value;
67 if (!ReadUInt16(&value)) { 34 if (!ReadUInt16(&value)) {
68 return false; 35 return false;
69 } 36 }
70 37
71 *result = value; 38 *result = value;
72 if (*result < (1 << kUFloat16MantissaEffectiveBits)) { 39 if (*result < (1 << kUFloat16MantissaEffectiveBits)) {
73 // Fast path: either the value is denormalized (no hidden bit), or 40 // Fast path: either the value is denormalized (no hidden bit), or
74 // normalized (hidden bit set, exponent offset by one) with exponent zero. 41 // normalized (hidden bit set, exponent offset by one) with exponent zero.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return bytes <= (len_ - pos_); 125 return bytes <= (len_ - pos_);
159 } 126 }
160 127
161 void QuicDataReader::OnFailure() { 128 void QuicDataReader::OnFailure() {
162 // Set our iterator to the end of the buffer so that further reads fail 129 // Set our iterator to the end of the buffer so that further reads fail
163 // immediately. 130 // immediately.
164 pos_ = len_; 131 pos_ = len_;
165 } 132 }
166 133
167 } // namespace net 134 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_data_reader.h ('k') | net/quic/quic_data_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698