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

Side by Side Diff: net/disk_cache/blockfile/disk_format_base.h

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply fixups Created 5 years, 11 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/disk_format.h ('k') | net/disk_cache/blockfile/disk_format_v3.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // For a general description of the files used by the cache see file_format.h. 5 // For a general description of the files used by the cache see file_format.h.
6 // 6 //
7 // A block file is a file designed to store blocks of data of a given size. It 7 // A block file is a file designed to store blocks of data of a given size. It
8 // is able to store data that spans from one to four consecutive "blocks", and 8 // is able to store data that spans from one to four consecutive "blocks", and
9 // it grows as needed to store up to approximately 65000 blocks. It has a fixed 9 // it grows as needed to store up to approximately 65000 blocks. It has a fixed
10 // size header used for book keeping such as tracking free of blocks on the 10 // size header used for book keeping such as tracking free of blocks on the
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 int32 entry_size; // Size of the blocks of this file. 54 int32 entry_size; // Size of the blocks of this file.
55 int32 num_entries; // Number of stored entries. 55 int32 num_entries; // Number of stored entries.
56 int32 max_entries; // Current maximum number of entries. 56 int32 max_entries; // Current maximum number of entries.
57 int32 empty[4]; // Counters of empty entries for each type. 57 int32 empty[4]; // Counters of empty entries for each type.
58 int32 hints[4]; // Last used position for each entry type. 58 int32 hints[4]; // Last used position for each entry type.
59 volatile int32 updating; // Keep track of updates to the header. 59 volatile int32 updating; // Keep track of updates to the header.
60 int32 user[5]; 60 int32 user[5];
61 AllocBitmap allocation_map; 61 AllocBitmap allocation_map;
62 }; 62 };
63 63
64 COMPILE_ASSERT(sizeof(BlockFileHeader) == kBlockHeaderSize, bad_header); 64 static_assert(sizeof(BlockFileHeader) == kBlockHeaderSize, "bad header");
65 65
66 // Sparse data support: 66 // Sparse data support:
67 // We keep a two level hierarchy to enable sparse data for an entry: the first 67 // We keep a two level hierarchy to enable sparse data for an entry: the first
68 // level consists of using separate "child" entries to store ranges of 1 MB, 68 // level consists of using separate "child" entries to store ranges of 1 MB,
69 // and the second level stores blocks of 1 KB inside each child entry. 69 // and the second level stores blocks of 1 KB inside each child entry.
70 // 70 //
71 // Whenever we need to access a particular sparse offset, we first locate the 71 // Whenever we need to access a particular sparse offset, we first locate the
72 // child entry that stores that offset, so we discard the 20 least significant 72 // child entry that stores that offset, so we discard the 20 least significant
73 // bits of the offset, and end up with the child id. For instance, the child id 73 // bits of the offset, and end up with the child id. For instance, the child id
74 // to store the first megabyte is 0, and the child that should store offset 74 // to store the first megabyte is 0, and the child that should store offset
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 SparseHeader header; 117 SparseHeader header;
118 uint32 bitmap[32]; // Bitmap representation of known children (if this 118 uint32 bitmap[32]; // Bitmap representation of known children (if this
119 // is a parent entry), or used blocks (for child 119 // is a parent entry), or used blocks (for child
120 // entries. The size is fixed for child entries but 120 // entries. The size is fixed for child entries but
121 // not for parents; it can be as small as 4 bytes 121 // not for parents; it can be as small as 4 bytes
122 // and as large as 8 KB. 122 // and as large as 8 KB.
123 }; 123 };
124 124
125 // The number of blocks stored by a child entry. 125 // The number of blocks stored by a child entry.
126 const int kNumSparseBits = 1024; 126 const int kNumSparseBits = 1024;
127 COMPILE_ASSERT(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8, 127 static_assert(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8,
128 Invalid_SparseData_bitmap); 128 "invalid SparseData bitmap");
129 129
130 } // namespace disk_cache 130 } // namespace disk_cache
131 131
132 #endif // NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_ 132 #endif // NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/disk_format.h ('k') | net/disk_cache/blockfile/disk_format_v3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698