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

Unified Diff: net/spdy/spdy_prefixed_buffer_reader.cc

Issue 2832973003: Split net/spdy into core and chromium subdirectories. (Closed)
Patch Set: Fix some more build rules. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_prefixed_buffer_reader.h ('k') | net/spdy/spdy_prefixed_buffer_reader_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_prefixed_buffer_reader.cc
diff --git a/net/spdy/spdy_prefixed_buffer_reader.cc b/net/spdy/spdy_prefixed_buffer_reader.cc
deleted file mode 100644
index c47510de65e0ad0aa5848f5101f53971b538e1ce..0000000000000000000000000000000000000000
--- a/net/spdy/spdy_prefixed_buffer_reader.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2014 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/spdy/spdy_prefixed_buffer_reader.h"
-
-#include "base/logging.h"
-
-namespace net {
-
-SpdyPrefixedBufferReader::SpdyPrefixedBufferReader(
- const char* prefix,
- size_t prefix_length,
- const char* suffix,
- size_t suffix_length)
- : prefix_(prefix),
- suffix_(suffix),
- prefix_length_(prefix_length),
- suffix_length_(suffix_length) {}
-
-size_t SpdyPrefixedBufferReader::Available() {
- return prefix_length_ + suffix_length_;
-}
-
-bool SpdyPrefixedBufferReader::ReadN(size_t count, char* out) {
- if (Available() < count) {
- return false;
- }
-
- if (prefix_length_ >= count) {
- // Read is fully satisfied by the prefix.
- std::copy(prefix_, prefix_ + count, out);
- prefix_ += count;
- prefix_length_ -= count;
- return true;
- } else if (prefix_length_ != 0) {
- // Read is partially satisfied by the prefix.
- out = std::copy(prefix_, prefix_ + prefix_length_, out);
- count -= prefix_length_;
- prefix_length_ = 0;
- // Fallthrough to suffix read.
- }
- DCHECK(suffix_length_ >= count);
- // Read is satisfied by the suffix.
- std::copy(suffix_, suffix_ + count, out);
- suffix_ += count;
- suffix_length_ -= count;
- return true;
-}
-
-bool SpdyPrefixedBufferReader::ReadN(size_t count,
- SpdyPinnableBufferPiece* out) {
- if (Available() < count) {
- return false;
- }
-
- out->storage_.reset();
- out->length_ = count;
-
- if (prefix_length_ >= count) {
- // Read is fully satisfied by the prefix.
- out->buffer_ = prefix_;
- prefix_ += count;
- prefix_length_ -= count;
- return true;
- } else if (prefix_length_ != 0) {
- // Read is only partially satisfied by the prefix. We need to allocate
- // contiguous storage as the read spans the prefix & suffix.
- out->storage_.reset(new char[count]);
- out->buffer_ = out->storage_.get();
- ReadN(count, out->storage_.get());
- return true;
- } else {
- DCHECK(suffix_length_ >= count);
- // Read is fully satisfied by the suffix.
- out->buffer_ = suffix_;
- suffix_ += count;
- suffix_length_ -= count;
- return true;
- }
-}
-
-} // namespace net
« no previous file with comments | « net/spdy/spdy_prefixed_buffer_reader.h ('k') | net/spdy/spdy_prefixed_buffer_reader_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698