VOOZH about

URL: https://codereview.chromium.org/11125002/diff/25001/net/quic/quic_data_writer.cc

⇱ net/quic/quic_data_writer.cc - 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
(430)

Issues Search
    My Issues | Starred     Open | Closed | All

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

👁 Image
Issue 11125002: Add QuicFramer and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove logging 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
« no previous file with comments | « net/quic/quic_data_writer.h ('k') | net/quic/quic_framer.h » ('j') | net/quic/quic_framer.h » ('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.
#include "net/quic/quic_data_writer.h"
#include <algorithm>
#include <limits>
#include "base/basictypes.h"
#include "base/logging.h"
#include "net/quic/quic_protocol.h"
using std::numeric_limits;
namespace net {
QuicDataWriter::QuicDataWriter(size_t size)
: buffer_(new char[size]),
capacity_(size),
length_(0) {
}
QuicDataWriter::~QuicDataWriter() {
delete[] buffer_;
}
char* QuicDataWriter::BeginWrite(size_t length) {
if (length_ + length > capacity_) {
jar (doing other things) 2012/10/16 19:24:01 nit: To avoid integer overflow confusion, I think
Ryan Hamilton 2012/10/16 19:43:23 Ah, I see. I didn't realize that was why you wrot
return NULL;
}
#ifdef ARCH_CPU_64_BITS
DCHECK_LE(length, numeric_limits<uint32>::max());
#endif
return buffer_ + length_;
}
bool QuicDataWriter::AdvancePointer(uint32 len) {
if (!BeginWrite(len)) {
return false;
}
length_ += len;
return true;
}
bool QuicDataWriter::WriteBytes(const void* data, uint32 data_len) {
char* dest = BeginWrite(data_len);
if (!dest) {
return false;
}
memcpy(dest, data, data_len);
length_ += data_len;
return true;
}
void QuicDataWriter::WriteUint64ToBuffer(uint64 value, char* buffer) {
memcpy(buffer, &value, sizeof(value));
}
void QuicDataWriter::WriteUint128ToBuffer(uint128 value, char* buffer) {
WriteUint64ToBuffer(value.lo, buffer);
WriteUint64ToBuffer(value.hi, buffer + sizeof(value.lo));
}
} // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_data_writer.h ('k') | net/quic/quic_framer.h » ('j') | net/quic/quic_framer.h » ('J')
👁 Powered by Google App Engine
This is Rietveld 408576698