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

Unified Diff: net/spdy/hpack_output_stream.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/hpack_output_stream.h ('k') | net/spdy/hpack_output_stream_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack_output_stream.cc
diff --git a/net/spdy/hpack_output_stream.cc b/net/spdy/hpack_output_stream.cc
deleted file mode 100644
index d8eb54bb839b91dbca37d7ffc16213916a306634..0000000000000000000000000000000000000000
--- a/net/spdy/hpack_output_stream.cc
+++ /dev/null
@@ -1,77 +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/hpack_output_stream.h"
-
-#include "base/logging.h"
-
-
-namespace net {
-
-using base::StringPiece;
-using std::string;
-
-HpackOutputStream::HpackOutputStream()
- : bit_offset_(0) {}
-
-HpackOutputStream::~HpackOutputStream() {}
-
-void HpackOutputStream::AppendBits(uint8 bits, size_t bit_size) {
- DCHECK_GT(bit_size, 0u);
- DCHECK_LE(bit_size, 8u);
- DCHECK_EQ(bits >> bit_size, 0);
- size_t new_bit_offset = bit_offset_ + bit_size;
- if (bit_offset_ == 0) {
- // Buffer ends on a byte boundary.
- DCHECK_LE(bit_size, 8u);
- buffer_.append(1, bits << (8 - bit_size));
- } else if (new_bit_offset <= 8) {
- // Buffer does not end on a byte boundary but the given bits fit
- // in the remainder of the last byte.
- *buffer_.rbegin() |= bits << (8 - new_bit_offset);
- } else {
- // Buffer does not end on a byte boundary and the given bits do
- // not fit in the remainder of the last byte.
- *buffer_.rbegin() |= bits >> (new_bit_offset - 8);
- buffer_.append(1, bits << (16 - new_bit_offset));
- }
- bit_offset_ = new_bit_offset % 8;
-}
-
-void HpackOutputStream::AppendPrefix(HpackPrefix prefix) {
- AppendBits(prefix.bits, prefix.bit_size);
-}
-
-void HpackOutputStream::AppendBytes(StringPiece buffer) {
- DCHECK_EQ(bit_offset_, 0u);
- buffer_.append(buffer.data(), buffer.size());
-}
-
-void HpackOutputStream::AppendUint32(uint32 I) {
- // The algorithm below is adapted from the pseudocode in 6.1.
- size_t N = 8 - bit_offset_;
- uint8 max_first_byte = static_cast<uint8>((1 << N) - 1);
- if (I < max_first_byte) {
- AppendBits(static_cast<uint8>(I), N);
- } else {
- AppendBits(max_first_byte, N);
- I -= max_first_byte;
- while ((I & ~0x7f) != 0) {
- buffer_.append(1, (I & 0x7f) | 0x80);
- I >>= 7;
- }
- AppendBits(static_cast<uint8>(I), 8);
- }
-}
-
-void HpackOutputStream::TakeString(string* output) {
- // This must hold, since all public functions cause the buffer to
- // end on a byte boundary.
- DCHECK_EQ(bit_offset_, 0u);
- buffer_.swap(*output);
- buffer_.clear();
- bit_offset_ = 0;
-}
-
-} // namespace net
« no previous file with comments | « net/spdy/hpack_output_stream.h ('k') | net/spdy/hpack_output_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698