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

Unified Diff: components/safe_browsing_db/v4_rice.cc

Issue 2206733002: PVer4: Verify checksum for downloaded updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_v4_rice_store
Patch Set: Minor: nparker@'s CR feedback Created 4 years, 4 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
Index: components/safe_browsing_db/v4_rice.cc
diff --git a/components/safe_browsing_db/v4_rice.cc b/components/safe_browsing_db/v4_rice.cc
index 3016fac87941e381e549b2535eb02e4125423c67..0e7148048fc379e1a3645906d818845e9932ab16 100644
--- a/components/safe_browsing_db/v4_rice.cc
+++ b/components/safe_browsing_db/v4_rice.cc
@@ -14,7 +14,8 @@ namespace safe_browsing {
namespace {
-const unsigned int kMaxBitIndex = 8 * sizeof(uint32_t);
+const int kBitsPerByte = 8;
+const unsigned int kMaxBitIndex = kBitsPerByte * sizeof(uint32_t);
void GetBytesFromUInt32(uint32_t word, char* bytes) {
const size_t mask = 0xFF;
@@ -264,10 +265,15 @@ void V4RiceDecoder::GetBitsFromCurrentWord(unsigned int num_requested_bits,
};
std::string V4RiceDecoder::DebugString() const {
+ // Calculates the total number of bits that we have read from the buffer,
+ // excluding those that have been read into current_word_ but not yet
+ // consumed byt GetNextBits().
+ unsigned bits_read = (data_byte_index_ - sizeof(uint32_t)) * kBitsPerByte +
+ current_word_bit_index_;
return base::StringPrintf(
- "current_word_: %x; data_byte_index_; %x, "
+ "bits_read: %x; current_word_: %x; data_byte_index_; %x, "
"current_word_bit_index_: %x; rice_parameter_: %x",
- current_word_, data_byte_index_, current_word_bit_index_,
+ bits_read, current_word_, data_byte_index_, current_word_bit_index_,
rice_parameter_);
}

Powered by Google App Engine
This is Rietveld 408576698