VOOZH about

URL: https://codereview.chromium.org/11125002/diff/11031/net/quic/quic_data_writer.h

⇱ net/quic/quic_data_writer.h - Issue 11125002: Add QuicFramer and friends. - Code Review


Side by Side Diff

Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Keyboard Shortcuts

File
u :up to issue
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
Issue
u :up to list of issues
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
👁 Image
Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Issues Search
    My Issues | Starred     Open | Closed | All

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

👁 Image
Issue 11125002: Add QuicFramer and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: narrowing in Created 8 years, 2 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
« net/quic/quic_data_reader.cc ('K') | « net/quic/quic_data_reader.cc ('k') | net/quic/quic_data_writer.cc » ('j') | net/quic/quic_data_writer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_QUIC_QUIC_DATA_WRITER_H_
#define NET_QUIC_QUIC_DATA_WRITER_H_
#include <string>
#include "base/basictypes.h"
#include "base/logging.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/uint128.h"
#include "base/string_piece.h"
namespace net {
// This class provides facilities for packing QUIC data.
//
// The QuicDataWriter supports appending primitive values (int, string, etc)
// to a frame instance. The QuicDataWriter grows its internal memory buffer
// dynamically to hold the sequence of primitive values. The internal memory
// buffer is exposed as the "data" of the QuicDataWriter.
class QuicDataWriter {
public:
~QuicDataWriter();
explicit QuicDataWriter(size_t length);
jar (doing other things) 2012/10/14 23:04:38 nit: constructors then destructors.
Ryan Hamilton 2012/10/15 21:22:08 Done.
// Returns the size of the QuicDataWriter's data.
size_t length() const { return length_; }
// Takes the buffer from the QuicDataWriter.
char* take() {
char* rv = buffer_;
jar (doing other things) 2012/10/14 23:04:38 nit: Usually we try not to put much code in the he
Ryan Hamilton 2012/10/15 21:22:08 This code mostly came from the SPDY equivalent and
buffer_ = NULL;
capacity_ = 0;
length_ = 0;
return rv;
}
// Methods for adding to the payload. These values are appended to the end
// of the QuicDataWriter payload. Note - binary integers are written in
// host byte order (little endian) not network byte order (big endian).
bool WriteUInt8(uint8 value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt16(uint16 value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt32(uint32 value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt48(uint64 value) {
uint32 hi = value >> 32;
uint32 lo = value & 0x00000000FFFFFFFF;
return WriteUInt32(lo) && WriteUInt16(hi);
}
bool WriteUInt64(uint64 value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt128(uint128 value) {
return WriteUInt64(value.lo) && WriteUInt64(value.hi);
}
bool AdvancePointer(uint32 len);
bool WriteBytes(const void* data, uint32 data_len);
static void WriteUint64ToBuffer(uint64 value, char* buffer);
static void WriteUint128ToBuffer(uint128 value, char* buffer);
jar (doing other things) 2012/10/14 23:04:38 This API is a bit scary (no way to check). Is thi
Ryan Hamilton 2012/10/15 21:22:08 I believe these methods are used for tweaking fiel
size_t capacity() const {
return capacity_;
}
protected:
const char* end_of_payload() const { return buffer_ + length_; }
private:
// Returns the location that the data should be written at, or NULL if there
// is not enough room. Call EndWrite with the returned offset and the given
// length to pad out for the next write.
char* BeginWrite(size_t length);
char* buffer_;
size_t capacity_; // Allocation size of payload (or -1 if buffer is const).
size_t length_; // current length of the buffer
jar (doing other things) 2012/10/14 23:04:38 nit: Capital and period.
Ryan Hamilton 2012/10/15 21:22:08 Done.
};
} // namespace net
#endif // NET_QUIC_QUIC_DATA_WRITER_H_
OLDNEW
« net/quic/quic_data_reader.cc ('K') | « net/quic/quic_data_reader.cc ('k') | net/quic/quic_data_writer.cc » ('j') | net/quic/quic_data_writer.cc » ('J')
👁 Powered by Google App Engine
This is Rietveld 408576698