diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 20:13:57 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 20:13:57 +0000 |
commit | 790656e31f441404fa57944ca1a69890052a7828 (patch) | |
tree | 37e5c7a8bdc2eea8044c8eda4d5fdd9d253694ae /net/disk_cache/entry_unittest.cc | |
parent | e741b941959feba1e0d7317aefad6f948219dc8a (diff) | |
download | chromium_src-790656e31f441404fa57944ca1a69890052a7828.zip chromium_src-790656e31f441404fa57944ca1a69890052a7828.tar.gz chromium_src-790656e31f441404fa57944ca1a69890052a7828.tar.bz2 |
Fixing bugs in sparse cache when dealing with GetAvailableRange queries not aligned
TEST=net_unittests --gtest_filter=DiskCacheEntryTest.PartialSparseEntry
In handling GetAvailableRange() queries, if the start offset is not aligned to 1KB,
there was some strange behaviors:
1. The start offset found is smaller than the input offset
2. Number of continus bytes doesn't take into account offset in a block.
This patch will fix the above problems.
Review URL: http://codereview.chromium.org/186002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_unittest.cc')
-rw-r--r-- | net/disk_cache/entry_unittest.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index f65f593..dbd4f82 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -1256,6 +1256,21 @@ void DiskCacheEntryTest::PartialSparseEntry() { EXPECT_EQ(3616, entry->GetAvailableRange(20 * 1024, 10000, &start)); EXPECT_EQ(20 * 1024, start); + // 1. Query before a filled 1KB block. + // 2. Query within a filled 1KB block. + // 3. Query beyond a filled 1KB block. + if (memory_only_) { + EXPECT_EQ(3496, entry->GetAvailableRange(19400, kSize, &start)); + EXPECT_EQ(20000, start); + } else { + EXPECT_EQ(3016, entry->GetAvailableRange(19400, kSize, &start)); + EXPECT_EQ(20480, start); + } + EXPECT_EQ(1523, entry->GetAvailableRange(3073, kSize, &start)); + EXPECT_EQ(3073, start); + EXPECT_EQ(0, entry->GetAvailableRange(4600, kSize, &start)); + EXPECT_EQ(4600, start); + // Now make another write and verify that there is no hole in between. EXPECT_EQ(kSize, entry->WriteSparseData(500 + kSize, buf1, kSize, NULL)); EXPECT_EQ(7 * 1024 + 500, entry->GetAvailableRange(1024, 10000, &start)); |