summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 22:09:21 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 22:09:21 +0000
commit8f28d63586a48273a6e05bba97e3cb7d5c5d8cb0 (patch)
tree9a17cfd0ff4d0557d665f8ba5c6856f3dd4a6000 /net/http
parent406017c4dd6fe0a2d4680e319256fd898ef86e7d (diff)
downloadchromium_src-8f28d63586a48273a6e05bba97e3cb7d5c5d8cb0.zip
chromium_src-8f28d63586a48273a6e05bba97e3cb7d5c5d8cb0.tar.gz
chromium_src-8f28d63586a48273a6e05bba97e3cb7d5c5d8cb0.tar.bz2
Handle reading to the end of a sparse entry
TEST=run chrome with --enable-byte-range-support --incognito and watch a video in http://tinyvid.tv/, seeking should be fine. http_cache::PartialData used to read a length of zero when reading has reached the end. The zero parameter will cause MemEntryImpl to complain about invalid argument, so early return for the case that we know we have nothing to read. Review URL: http://codereview.chromium.org/255034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache_unittest.cc3
-rw-r--r--net/http/partial_data.cc3
2 files changed, 6 insertions, 0 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 35e6736..064f7c4 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -2214,6 +2214,9 @@ TEST(HttpCache, RangeGET_Previous200) {
EXPECT_EQ(1, cache.disk_cache()->open_count());
EXPECT_EQ(1, cache.disk_cache()->create_count());
+ // The last transaction has finished so make sure the entry is deactivated.
+ MessageLoop::current()->RunAllPending();
+
// Now we should receive a range from the server and drop the stored entry.
handler.set_not_modified(false);
transaction2.request_headers = kRangeGET_TransactionOK.request_headers;
diff --git a/net/http/partial_data.cc b/net/http/partial_data.cc
index 1b4b575..7257f00 100644
--- a/net/http/partial_data.cc
+++ b/net/http/partial_data.cc
@@ -256,6 +256,9 @@ void PartialData::FixContentLength(HttpResponseHeaders* headers) {
int PartialData::CacheRead(disk_cache::Entry* entry, IOBuffer* data,
int data_len, CompletionCallback* callback) {
int read_len = std::min(data_len, cached_min_len_);
+ if (!read_len)
+ return 0;
+
int rv = 0;
if (sparse_entry_) {
rv = entry->ReadSparseData(current_range_start_, data, read_len,