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

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

Issue 11958018: Queueing QUIC frames to be resent instead of packets and packing RST frames with acks and congestio… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
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_writer.h" 5 #include "net/quic/quic_data_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (!dest) { 91 if (!dest) {
92 return false; 92 return false;
93 } 93 }
94 94
95 memcpy(dest, data, data_len); 95 memcpy(dest, data, data_len);
96 96
97 length_ += data_len; 97 length_ += data_len;
98 return true; 98 return true;
99 } 99 }
100 100
101 void QuicDataWriter::WriteUint8ToBuffer(uint8 value, char* buffer) {
102 memcpy(buffer, &value, sizeof(value));
103 }
104
105 void QuicDataWriter::WriteUint16ToBuffer(uint16 value, char* buffer) {
106 memcpy(buffer, &value, sizeof(value));
107 }
108
109 void QuicDataWriter::WriteUint32ToBuffer(uint32 value, char* buffer) {
110 memcpy(buffer, &value, sizeof(value));
111 }
112
113 void QuicDataWriter::WriteUint48ToBuffer(uint64 value, char* buffer) {
114 uint16 hi = value >> 32;
115 uint32 lo = value & 0x00000000FFFFFFFF;
116 WriteUint32ToBuffer(lo, buffer);
117 WriteUint16ToBuffer(hi, buffer + sizeof(lo));
118 }
119
120 void QuicDataWriter::WriteUint64ToBuffer(uint64 value, char* buffer) {
121 memcpy(buffer, &value, sizeof(value));
122 }
123
124 void QuicDataWriter::WriteUint128ToBuffer(uint128 value, char* buffer) {
125 uint64 high = Uint128High64(value);
126 uint64 low = Uint128Low64(value);
127 WriteUint64ToBuffer(low, buffer);
128 WriteUint64ToBuffer(high, buffer + sizeof(low));
129 }
130
131 bool QuicDataWriter::WriteUInt8ToOffset(uint8 value, size_t offset) { 101 bool QuicDataWriter::WriteUInt8ToOffset(uint8 value, size_t offset) {
132 DCHECK_LT(offset, capacity_); 102 DCHECK_LT(offset, capacity_);
133 int latched_length = length_; 103 int latched_length = length_;
134 length_ = offset; 104 length_ = offset;
135 bool success = WriteUInt8(value); 105 bool success = WriteUInt8(value);
136 length_ = latched_length; 106 length_ = latched_length;
137 return success; 107 return success;
138 } 108 }
139 109
140 bool QuicDataWriter::WriteUInt48ToOffset(uint64 value, size_t offset) { 110 bool QuicDataWriter::WriteUInt48ToOffset(uint64 value, size_t offset) {
141 DCHECK_LT(offset, capacity_); 111 DCHECK_LT(offset, capacity_);
142 int latched_length = length_; 112 int latched_length = length_;
143 length_ = offset; 113 length_ = offset;
144 bool success = WriteUInt48(value); 114 bool success = WriteUInt48(value);
145 length_ = latched_length; 115 length_ = latched_length;
146 return success; 116 return success;
147 } 117 }
148 118
149 } // namespace net 119 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698