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

Unified Diff: net/http2/decoder/http2_structure_decoder.cc

Issue 2554683003: Revert of Add new HTTP/2 and HPACK decoder in net/http2/. (Closed)
Patch Set: Created 4 years 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/http2/decoder/http2_structure_decoder.h ('k') | net/http2/decoder/http2_structure_decoder_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http2/decoder/http2_structure_decoder.cc
diff --git a/net/http2/decoder/http2_structure_decoder.cc b/net/http2/decoder/http2_structure_decoder.cc
deleted file mode 100644
index a7b1dca47a346594ff9e7776a7d3aeddc5c407be..0000000000000000000000000000000000000000
--- a/net/http2/decoder/http2_structure_decoder.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2016 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/http2/decoder/http2_structure_decoder.h"
-
-#include <algorithm>
-
-#include "net/http2/tools/http2_bug_tracker.h"
-
-namespace net {
-
-// Below we have some defensive coding: if we somehow run off the end, don't
-// overwrite lots of memory. Note that most of this decoder is not defensive
-// against bugs in the decoder, only against malicious encoders, but since
-// we're copying memory into a buffer here, let's make sure we don't allow a
-// small mistake to grow larger. The decoder will get stuck if we hit the
-// HTTP2_BUG conditions, but shouldn't corrupt memory.
-
-uint32_t Http2StructureDecoder::IncompleteStart(DecodeBuffer* db,
- uint32_t target_size) {
- if (target_size > sizeof buffer_) {
- HTTP2_BUG << "target_size too large for buffer: " << target_size;
- return 0;
- }
- const uint32_t num_to_copy = db->MinLengthRemaining(target_size);
- memcpy(buffer_, db->cursor(), num_to_copy);
- offset_ = num_to_copy;
- db->AdvanceCursor(num_to_copy);
- return num_to_copy;
-}
-
-DecodeStatus Http2StructureDecoder::IncompleteStart(DecodeBuffer* db,
- uint32_t* remaining_payload,
- uint32_t target_size) {
- DVLOG(1) << "IncompleteStart@" << this
- << ": *remaining_payload=" << *remaining_payload
- << "; target_size=" << target_size
- << "; db->Remaining=" << db->Remaining();
- *remaining_payload -=
- IncompleteStart(db, std::min(target_size, *remaining_payload));
- if (*remaining_payload > 0 && db->Empty()) {
- return DecodeStatus::kDecodeInProgress;
- }
- DVLOG(1) << "IncompleteStart: kDecodeError";
- return DecodeStatus::kDecodeError;
-}
-
-bool Http2StructureDecoder::ResumeFillingBuffer(DecodeBuffer* db,
- uint32_t target_size) {
- DVLOG(2) << "ResumeFillingBuffer@" << this << ": target_size=" << target_size
- << "; offset_=" << offset_ << "; db->Remaining=" << db->Remaining();
- if (target_size < offset_) {
- HTTP2_BUG << "Already filled buffer_! target_size=" << target_size
- << " offset_=" << offset_;
- return false;
- }
- const uint32_t needed = target_size - offset_;
- const uint32_t num_to_copy = db->MinLengthRemaining(needed);
- DVLOG(2) << "ResumeFillingBuffer num_to_copy=" << num_to_copy;
- memcpy(&buffer_[offset_], db->cursor(), num_to_copy);
- db->AdvanceCursor(num_to_copy);
- offset_ += num_to_copy;
- return needed == num_to_copy;
-}
-
-bool Http2StructureDecoder::ResumeFillingBuffer(DecodeBuffer* db,
- uint32_t* remaining_payload,
- uint32_t target_size) {
- DVLOG(2) << "ResumeFillingBuffer@" << this << ": target_size=" << target_size
- << "; offset_=" << offset_
- << "; *remaining_payload=" << *remaining_payload
- << "; db->Remaining=" << db->Remaining();
- if (target_size < offset_) {
- HTTP2_BUG << "Already filled buffer_! target_size=" << target_size
- << " offset_=" << offset_;
- return false;
- }
- const uint32_t needed = target_size - offset_;
- const uint32_t num_to_copy =
- db->MinLengthRemaining(std::min(needed, *remaining_payload));
- DVLOG(2) << "ResumeFillingBuffer num_to_copy=" << num_to_copy;
- memcpy(&buffer_[offset_], db->cursor(), num_to_copy);
- db->AdvanceCursor(num_to_copy);
- offset_ += num_to_copy;
- *remaining_payload -= num_to_copy;
- return needed == num_to_copy;
-}
-
-} // namespace net
« no previous file with comments | « net/http2/decoder/http2_structure_decoder.h ('k') | net/http2/decoder/http2_structure_decoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698