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

Unified Diff: net/http/partial_data.cc

Issue 6588105: Http cache: Fix handling of truncated entries.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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
« net/http/http_cache_transaction.cc ('K') | « net/http/partial_data.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/partial_data.cc
===================================================================
--- net/http/partial_data.cc (revision 75777)
+++ net/http/partial_data.cc (working copy)
@@ -111,6 +111,7 @@
final_range_(false),
sparse_entry_(true),
truncated_(false),
+ initial_validation_(false),
core_(NULL),
callback_(NULL) {
}
@@ -153,7 +154,7 @@
byte_range_.suffix_length() : byte_range_.last_byte_position();
headers->CopyFrom(extra_headers_);
- if (byte_range_.IsValid())
+ if (!truncated_ && byte_range_.IsValid())
AddRangeHeader(current_range_start_, end, headers);
}
@@ -178,13 +179,7 @@
callback_ = callback;
return ERR_IO_PENDING;
}
- } else if (truncated_) {
- if (!current_range_start_) {
- // Update the cached range only the first time.
- cached_min_len_ = static_cast<int32>(byte_range_.first_byte_position());
- cached_start_ = 0;
- }
- } else {
+ } else if (!truncated_) {
if (byte_range_.HasFirstBytePosition() &&
byte_range_.first_byte_position() >= resource_size_) {
// The caller should take care of this condition because we should have
@@ -259,10 +254,14 @@
return false;
truncated_ = true;
+ initial_validation_ = true;
sparse_entry_ = false;
- byte_range_.set_first_byte_position(entry->GetDataSize(kDataStream));
+ int current_len = entry->GetDataSize(kDataStream);
+ byte_range_.set_first_byte_position(current_len);
resource_size_ = total_length;
- current_range_start_ = 0;
+ current_range_start_ = current_len;
+ cached_min_len_ = current_len;
+ cached_start_ = current_len + 1;
return true;
}
@@ -284,12 +283,20 @@
return entry->CouldBeSparse();
}
+void PartialData::SetRangeToStartDownload() {
+ DCHECK(truncated_);
+ DCHECK(!sparse_entry_);
+ current_range_start_ = 0;
+ cached_start_ = 0;
+ initial_validation_ = false;
+}
+
bool PartialData::IsRequestedRangeOK() {
if (byte_range_.IsValid()) {
+ if (!byte_range_.ComputeBounds(resource_size_))
+ return false;
if (truncated_)
return true;
- if (!byte_range_.ComputeBounds(resource_size_))
- return false;
if (current_range_start_ < 0)
current_range_start_ = byte_range_.first_byte_position();
« net/http/http_cache_transaction.cc ('K') | « net/http/partial_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698