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

Unified Diff: net/spdy/hpack_header_table.cc

Issue 145353017: Update HPACK implementation to draft 05 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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_header_table.h ('k') | net/spdy/hpack_header_table_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack_header_table.cc
diff --git a/net/spdy/hpack_header_table.cc b/net/spdy/hpack_header_table.cc
index a9ab1b0518b507b2a7d4cc50cbe91200499e2e33..97a2a0263b5dae3a3ba43c5d0b187da8c2897a4a 100644
--- a/net/spdy/hpack_header_table.cc
+++ b/net/spdy/hpack_header_table.cc
@@ -20,13 +20,15 @@ uint32 HpackHeaderTable::GetEntryCount() const {
}
const HpackEntry& HpackHeaderTable::GetEntry(uint32 index) const {
- CHECK_LT(index, GetEntryCount());
- return entries_[index];
+ CHECK_GE(index, 1u);
+ CHECK_LE(index, GetEntryCount());
+ return entries_[index-1];
}
HpackEntry* HpackHeaderTable::GetMutableEntry(uint32 index) {
- CHECK_LT(index, GetEntryCount());
- return &entries_[index];
+ CHECK_GE(index, 1u);
+ CHECK_LE(index, GetEntryCount());
+ return &entries_[index-1];
}
void HpackHeaderTable::SetMaxSize(uint32 max_size) {
@@ -40,9 +42,9 @@ void HpackHeaderTable::SetMaxSize(uint32 max_size) {
void HpackHeaderTable::TryAddEntry(
const HpackEntry& entry,
- int32* index,
+ uint32* index,
std::vector<uint32>* removed_referenced_indices) {
- *index = -1;
+ *index = 0;
removed_referenced_indices->clear();
// The algorithm used here is described in 3.3.3. We're assuming
@@ -53,9 +55,10 @@ void HpackHeaderTable::TryAddEntry(
// The conditional implies the difference can fit in 32 bits.
target_size = size_t_max_size - entry.Size();
}
- while ((static_cast<size_t>(size_) > target_size) && !entries_.empty()) {
+ while (static_cast<size_t>(size_) > target_size) {
+ DCHECK(!entries_.empty());
if (entries_.back().IsReferenced()) {
- removed_referenced_indices->push_back(entries_.size() - 1);
+ removed_referenced_indices->push_back(entries_.size());
}
size_ -= entries_.back().Size();
entries_.pop_back();
@@ -66,7 +69,7 @@ void HpackHeaderTable::TryAddEntry(
// condition of the if.
DCHECK_LE(static_cast<size_t>(size_) + entry.Size(), size_t_max_size);
size_ += entry.Size();
- *index = 0;
+ *index = 1;
entries_.push_front(entry);
}
}
« no previous file with comments | « net/spdy/hpack_header_table.h ('k') | net/spdy/hpack_header_table_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698