OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "net/disk_cache/blockfile/addr.h" | 7 #include "net/disk_cache/blockfile/addr.h" |
8 #include "net/disk_cache/blockfile/disk_format_v3.h" | 8 #include "net/disk_cache/blockfile/disk_format_v3.h" |
9 #include "net/disk_cache/blockfile/index_table_v3.h" | 9 #include "net/disk_cache/blockfile/index_table_v3.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 class MockIndexBackend : public disk_cache::IndexTableBackend { | 30 class MockIndexBackend : public disk_cache::IndexTableBackend { |
31 public: | 31 public: |
32 MockIndexBackend() : grow_called_(false), buffer_len_(-1) {} | 32 MockIndexBackend() : grow_called_(false), buffer_len_(-1) {} |
33 virtual ~MockIndexBackend() {} | 33 virtual ~MockIndexBackend() {} |
34 | 34 |
35 bool grow_called() const { return grow_called_; } | 35 bool grow_called() const { return grow_called_; } |
36 int buffer_len() const { return buffer_len_; } | 36 int buffer_len() const { return buffer_len_; } |
37 | 37 |
38 virtual void GrowIndex() OVERRIDE { grow_called_ = true; } | 38 virtual void GrowIndex() override { grow_called_ = true; } |
39 virtual void SaveIndex(net::IOBuffer* buffer, int buffer_len) OVERRIDE { | 39 virtual void SaveIndex(net::IOBuffer* buffer, int buffer_len) override { |
40 buffer_len_ = buffer_len; | 40 buffer_len_ = buffer_len; |
41 } | 41 } |
42 virtual void DeleteCell(EntryCell cell) OVERRIDE {} | 42 virtual void DeleteCell(EntryCell cell) override {} |
43 virtual void FixCell(EntryCell cell) OVERRIDE {} | 43 virtual void FixCell(EntryCell cell) override {} |
44 | 44 |
45 private: | 45 private: |
46 bool grow_called_; | 46 bool grow_called_; |
47 int buffer_len_; | 47 int buffer_len_; |
48 }; | 48 }; |
49 | 49 |
50 class TestCacheTables { | 50 class TestCacheTables { |
51 public: | 51 public: |
52 // |num_entries| is the capacity of the main table. The extra table is half | 52 // |num_entries| is the capacity of the main table. The extra table is half |
53 // the size of the main table. | 53 // the size of the main table. |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 697 |
698 uint32 hash = 0; | 698 uint32 hash = 0; |
699 disk_cache::Addr addr(disk_cache::BLOCK_ENTRIES, 1, 5, 6); | 699 disk_cache::Addr addr(disk_cache::BLOCK_ENTRIES, 1, 5, 6); |
700 EntryCell entry = index.CreateEntryCell(hash, addr); | 700 EntryCell entry = index.CreateEntryCell(hash, addr); |
701 EXPECT_TRUE(entry.IsValid()); | 701 EXPECT_TRUE(entry.IsValid()); |
702 | 702 |
703 index.OnBackupTimer(); | 703 index.OnBackupTimer(); |
704 int expected = (1024 + 512) / 8 + sizeof(disk_cache::IndexHeaderV3); | 704 int expected = (1024 + 512) / 8 + sizeof(disk_cache::IndexHeaderV3); |
705 EXPECT_EQ(expected, backend.buffer_len()); | 705 EXPECT_EQ(expected, backend.buffer_len()); |
706 } | 706 } |
OLD | NEW |