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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 #ifndef NET_DISK_CACHE_BLOCKFILE_BITMAP_H_ 5 #ifndef NET_DISK_CACHE_BLOCKFILE_BITMAP_H_
6 #define NET_DISK_CACHE_BLOCKFILE_BITMAP_H_ 6 #define NET_DISK_CACHE_BLOCKFILE_BITMAP_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "net/base/net_export.h" 9 #include "net/base/net_export.h"
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 bool FindNextBit(int* index, int limit, bool value) const; 88 bool FindNextBit(int* index, int limit, bool value) const;
89 89
90 // Finds the first offset >= *|index| and < |limit| that has its bit set. 90 // Finds the first offset >= *|index| and < |limit| that has its bit set.
91 // See FindNextBit() for more info. 91 // See FindNextBit() for more info.
92 bool FindNextSetBitBeforeLimit(int* index, int limit) const { 92 bool FindNextSetBitBeforeLimit(int* index, int limit) const {
93 return FindNextBit(index, limit, true); 93 return FindNextBit(index, limit, true);
94 } 94 }
95 95
96 // Finds the first offset >= *|index| that has its bit set. 96 // Finds the first offset >= *|index| that has its bit set.
97 // See FindNextBit() for more info. 97 // See FindNextBit() for more info.
98 bool FindNextSetBit(int *index) const { 98 bool FindNextSetBit(int* index) const {
99 return FindNextSetBitBeforeLimit(index, num_bits_); 99 return FindNextSetBitBeforeLimit(index, num_bits_);
100 } 100 }
101 101
102 // Scans bits starting at bit *|index|, looking for a bit set to |value|. If 102 // Scans bits starting at bit *|index|, looking for a bit set to |value|. If
103 // it finds that bit before reaching bit index |limit|, sets *|index| to the 103 // it finds that bit before reaching bit index |limit|, sets *|index| to the
104 // bit index and then counts the number of consecutive bits set to |value| 104 // bit index and then counts the number of consecutive bits set to |value|
105 // (before reaching |limit|), and returns that count. If no bit is found 105 // (before reaching |limit|), and returns that count. If no bit is found
106 // returns 0. Requires |limit| <= Size(). 106 // returns 0. Requires |limit| <= Size().
107 int FindBits(int* index, int limit, bool value) const; 107 int FindBits(int* index, int limit, bool value) const;
108 108
109 // Returns number of allocated words required for a bitmap of size |num_bits|. 109 // Returns number of allocated words required for a bitmap of size |num_bits|.
110 static int RequiredArraySize(int num_bits) { 110 static int RequiredArraySize(int num_bits) {
111 // Force at least one allocated word. 111 // Force at least one allocated word.
112 if (num_bits <= kIntBits) 112 if (num_bits <= kIntBits)
113 return 1; 113 return 1;
114 114
115 return (num_bits + kIntBits - 1) >> kLogIntBits; 115 return (num_bits + kIntBits - 1) >> kLogIntBits;
116 } 116 }
117 117
118 private: 118 private:
119 static const int kIntBits = sizeof(uint32) * 8; 119 static const int kIntBits = sizeof(uint32) * 8;
120 static const int kLogIntBits = 5; // 2^5 == 32 bits per word. 120 static const int kLogIntBits = 5; // 2^5 == 32 bits per word.
121 121
122 // Sets |len| bits from |start| to |value|. All the bits to be set should be 122 // Sets |len| bits from |start| to |value|. All the bits to be set should be
123 // stored in the same word, and len < kIntBits. 123 // stored in the same word, and len < kIntBits.
124 void SetWordBits(int start, int len, bool value); 124 void SetWordBits(int start, int len, bool value);
125 125
126 uint32* map_; // The bitmap. 126 uint32* map_; // The bitmap.
127 int num_bits_; // The upper bound of the bitmap. 127 int num_bits_; // The upper bound of the bitmap.
128 int array_size_; // The physical size (in uint32s) of the bitmap. 128 int array_size_; // The physical size (in uint32s) of the bitmap.
129 bool alloc_; // Whether or not we allocated the memory. 129 bool alloc_; // Whether or not we allocated the memory.
130 130
131 DISALLOW_COPY_AND_ASSIGN(Bitmap); 131 DISALLOW_COPY_AND_ASSIGN(Bitmap);
132 }; 132 };
133 133
134 } // namespace disk_cache 134 } // namespace disk_cache
135 135
136 #endif // NET_DISK_CACHE_BLOCKFILE_BITMAP_H_ 136 #endif // NET_DISK_CACHE_BLOCKFILE_BITMAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698