xref: /aosp_15_r20/external/cronet/net/data/cache_tests/good_2_0/contents.txt (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1This is a sample valid cache in 2.0 format.
2This was produced before the 3.0 format change by the following test:
3
4TEST_F(DiskCacheBackendTest, CreateCorrect) {
5  const char* kKey = "https://example.org/data";
6  cache_path_ = base::FilePath("/tmp/cache-correct-2.0");
7  CleanupCacheDir();
8  CHECK(base::CreateDirectory(cache_path_));
9
10  SetMaxSize(16*1024);
11  InitCache();
12
13  disk_cache::Entry* entry = nullptr;
14  ASSERT_THAT(CreateEntry(kKey, &entry), IsOk());
15
16  const int kBufSize = 1234;
17  auto buffer = base::MakeRefCounted<net::IOBufferWithSize>(kBufSize);
18  CacheTestFillBuffer(buffer->data(), kBufSize, /*no_nulls=*/false);
19
20  EXPECT_EQ(kBufSize, WriteData(entry, /*index=*/1, /*offset=*/0, buffer.get(),
21                                /*len=*/kBufSize, /*truncate=*/false));
22  entry->Close();
23}
24
25With the following patch applied:
26--- a/net/disk_cache/blockfile/block_files.cc
27+++ b/net/disk_cache/blockfile/block_files.cc
28@@ -487,7 +487,7 @@ bool BlockFiles::GrowBlockFile(MappedFile* file, BlockFileHeader* header) {
29
30   ScopedFlush flush(file);
31   DCHECK(!header->empty[3]);
32-  int new_size = header->max_entries + 1024;
33+  int new_size = header->max_entries + 64;
34   if (new_size > kMaxBlocks)
35     new_size = kMaxBlocks;
36
37To keep the data_ file size down somewhat.
38