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

Side by Side Diff: net/disk_cache/blockfile/addr.cc

Issue 1910023002: Remove partial blockfile v3 disk_cache implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « net/disk_cache/blockfile/addr.h ('k') | net/disk_cache/blockfile/addr_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/disk_cache/blockfile/addr.h" 5 #include "net/disk_cache/blockfile/addr.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace disk_cache { 9 namespace disk_cache {
10 10
11 int Addr::start_block() const { 11 int Addr::start_block() const {
12 DCHECK(is_block_file()); 12 DCHECK(is_block_file());
13 return value_ & kStartBlockMask; 13 return value_ & kStartBlockMask;
14 } 14 }
15 15
16 int Addr::num_blocks() const { 16 int Addr::num_blocks() const {
17 DCHECK(is_block_file() || !value_); 17 DCHECK(is_block_file() || !value_);
18 return ((value_ & kNumBlocksMask) >> kNumBlocksOffset) + 1; 18 return ((value_ & kNumBlocksMask) >> kNumBlocksOffset) + 1;
19 } 19 }
20 20
21 bool Addr::SetFileNumber(int file_number) { 21 bool Addr::SetFileNumber(int file_number) {
22 DCHECK(is_separate_file()); 22 DCHECK(is_separate_file());
23 if (file_number & ~kFileNameMask) 23 if (file_number & ~kFileNameMask)
24 return false; 24 return false;
25 value_ = kInitializedMask | file_number; 25 value_ = kInitializedMask | file_number;
26 return true; 26 return true;
27 } 27 }
28 28
29 bool Addr::SanityCheckV2() const { 29 bool Addr::SanityCheck() const {
30 if (!is_initialized()) 30 if (!is_initialized())
31 return !value_; 31 return !value_;
32 32
33 if (file_type() > BLOCK_4K) 33 if (file_type() > BLOCK_4K)
34 return false; 34 return false;
35 35
36 if (is_separate_file()) 36 if (is_separate_file())
37 return true; 37 return true;
38 38
39 return !reserved_bits(); 39 return !reserved_bits();
40 } 40 }
41 41
42 bool Addr::SanityCheckV3() const { 42 bool Addr::SanityCheckForEntry() const {
43 if (!is_initialized()) 43 if (!SanityCheck() || !is_initialized())
44 return !value_;
45
46 // For actual entries, SanityCheckForEntryV3 should be used.
47 if (file_type() > BLOCK_FILES)
48 return false;
49
50 if (is_separate_file())
51 return true;
52
53 return !reserved_bits();
54 }
55
56 bool Addr::SanityCheckForEntryV2() const {
57 if (!SanityCheckV2() || !is_initialized())
58 return false; 44 return false;
59 45
60 if (is_separate_file() || file_type() != BLOCK_256) 46 if (is_separate_file() || file_type() != BLOCK_256)
61 return false; 47 return false;
62 48
63 return true; 49 return true;
64 } 50 }
65 51
66 bool Addr::SanityCheckForEntryV3() const {
67 if (!is_initialized())
68 return false;
69
70 if (reserved_bits())
71 return false;
72
73 if (file_type() != BLOCK_ENTRIES && file_type() != BLOCK_EVICTED)
74 return false;
75
76 if (num_blocks() != 1)
77 return false;
78
79 return true;
80 }
81
82 bool Addr::SanityCheckForRankings() const { 52 bool Addr::SanityCheckForRankings() const {
83 if (!SanityCheckV2() || !is_initialized()) 53 if (!SanityCheck() || !is_initialized())
84 return false; 54 return false;
85 55
86 if (is_separate_file() || file_type() != RANKINGS || num_blocks() != 1) 56 if (is_separate_file() || file_type() != RANKINGS || num_blocks() != 1)
87 return false; 57 return false;
88 58
89 return true; 59 return true;
90 } 60 }
91 61
92 } // namespace disk_cache 62 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/addr.h ('k') | net/disk_cache/blockfile/addr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698