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_writer.h" | 5 #include "net/quic/core/quic_data_writer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
| 10 #include "net/quic/core/quic_flags.h" |
| 11 #include "net/quic/platform/api/quic_endian.h" |
| 12 |
10 namespace net { | 13 namespace net { |
11 | 14 |
12 QuicDataWriter::QuicDataWriter(size_t size, char* buffer) | 15 QuicDataWriter::QuicDataWriter(size_t size, char* buffer) |
13 : buffer_(buffer), capacity_(size), length_(0) {} | 16 : buffer_(buffer), capacity_(size), length_(0) {} |
14 | 17 |
15 QuicDataWriter::~QuicDataWriter() {} | 18 QuicDataWriter::~QuicDataWriter() {} |
16 | 19 |
17 char* QuicDataWriter::data() { | 20 char* QuicDataWriter::data() { |
18 return buffer_; | 21 return buffer_; |
19 } | 22 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 134 |
132 void QuicDataWriter::WritePadding() { | 135 void QuicDataWriter::WritePadding() { |
133 DCHECK_LE(length_, capacity_); | 136 DCHECK_LE(length_, capacity_); |
134 if (length_ > capacity_) { | 137 if (length_ > capacity_) { |
135 return; | 138 return; |
136 } | 139 } |
137 memset(buffer_ + length_, 0x00, capacity_ - length_); | 140 memset(buffer_ + length_, 0x00, capacity_ - length_); |
138 length_ = capacity_; | 141 length_ = capacity_; |
139 } | 142 } |
140 | 143 |
| 144 bool QuicDataWriter::WriteConnectionId(uint64_t connection_id) { |
| 145 if (FLAGS_quic_restart_flag_quic_big_endian_connection_id) { |
| 146 connection_id = QuicEndian::HostToNet64(connection_id); |
| 147 } |
| 148 |
| 149 return WriteUInt64(connection_id); |
| 150 } |
| 151 |
141 } // namespace net | 152 } // namespace net |
OLD | NEW |