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

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

Issue 6263010: More net/ header/implementation method reordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/disk_cache/bitmap.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_BITMAP_H_ 5 #ifndef NET_DISK_CACHE_BITMAP_H_
6 #define NET_DISK_CACHE_BITMAP_H_ 6 #define NET_DISK_CACHE_BITMAP_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm>
10
11 #include "base/basictypes.h" 9 #include "base/basictypes.h"
12 10
13 namespace disk_cache { 11 namespace disk_cache {
14 12
15 // This class provides support for simple maps of bits. 13 // This class provides support for simple maps of bits.
16 class Bitmap { 14 class Bitmap {
17 public: 15 public:
18 Bitmap() : map_(NULL), num_bits_(0), array_size_(0), alloc_(false) {} 16 Bitmap() : map_(NULL), num_bits_(0), array_size_(0), alloc_(false) {}
willchan no longer on Chromium 2011/01/21 23:07:33 I'm a bit surprised you didn't define this out of
Elliot Glaysher 2011/01/21 23:11:15 Yeah; the other ctors called multiple methods and
19 17
20 // This constructor will allocate on a uint32 boundary. If |clear_bits| is 18 // This constructor will allocate on a uint32 boundary. If |clear_bits| is
21 // false, the bitmap bits will not be initialized. 19 // false, the bitmap bits will not be initialized.
22 Bitmap(int num_bits, bool clear_bits) 20 Bitmap(int num_bits, bool clear_bits);
23 : num_bits_(num_bits), array_size_(RequiredArraySize(num_bits)),
24 alloc_(true) {
25 map_ = new uint32[array_size_];
26
27 // Initialize all of the bits.
28 if (clear_bits)
29 Clear();
30 }
31 21
32 // Constructs a Bitmap with the actual storage provided by the caller. |map| 22 // Constructs a Bitmap with the actual storage provided by the caller. |map|
33 // has to be valid until this object destruction. |num_bits| is the number of 23 // has to be valid until this object destruction. |num_bits| is the number of
34 // bits in the bitmap, and |num_words| is the size of |map| in 32-bit words. 24 // bits in the bitmap, and |num_words| is the size of |map| in 32-bit words.
35 Bitmap(uint32* map, int num_bits, int num_words) 25 Bitmap(uint32* map, int num_bits, int num_words);
36 : map_(map), num_bits_(num_bits),
37 // If size is larger than necessary, trim because array_size_ is used
38 // as a bound by various methods.
39 array_size_(std::min(RequiredArraySize(num_bits), num_words)),
40 alloc_(false) {}
41 26
42 ~Bitmap() { 27 ~Bitmap();
43 if (alloc_)
44 delete[] map_;
45 }
46 28
47 // Resizes the bitmap. 29 // Resizes the bitmap.
48 // If |num_bits| < Size(), the extra bits will be discarded. 30 // If |num_bits| < Size(), the extra bits will be discarded.
49 // If |num_bits| > Size(), the extra bits will be filled with zeros if 31 // If |num_bits| > Size(), the extra bits will be filled with zeros if
50 // |clear_bits| is true. 32 // |clear_bits| is true.
51 // This object cannot be using memory provided during construction. 33 // This object cannot be using memory provided during construction.
52 void Resize(int num_bits, bool clear_bits); 34 void Resize(int num_bits, bool clear_bits);
53 35
54 // Returns the number of bits in the bitmap. 36 // Returns the number of bits in the bitmap.
55 int Size() const { return num_bits_; } 37 int Size() const { return num_bits_; }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 int num_bits_; // The upper bound of the bitmap. 127 int num_bits_; // The upper bound of the bitmap.
146 int array_size_; // The physical size (in uint32s) of the bitmap. 128 int array_size_; // The physical size (in uint32s) of the bitmap.
147 bool alloc_; // Whether or not we allocated the memory. 129 bool alloc_; // Whether or not we allocated the memory.
148 130
149 DISALLOW_COPY_AND_ASSIGN(Bitmap); 131 DISALLOW_COPY_AND_ASSIGN(Bitmap);
150 }; 132 };
151 133
152 } // namespace disk_cache 134 } // namespace disk_cache
153 135
154 #endif // NET_DISK_CACHE_BITMAP_H_ 136 #endif // NET_DISK_CACHE_BITMAP_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/bitmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698