| OLD | NEW |
| 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 #ifndef NET_DISK_CACHE_FLASH_SEGMENT_H_ | 5 #ifndef NET_DISK_CACHE_FLASH_SEGMENT_H_ |
| 6 #define NET_DISK_CACHE_FLASH_SEGMENT_H_ | 6 #define NET_DISK_CACHE_FLASH_SEGMENT_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bool ReadData(void* buffer, int32 size, int32 offset) const; | 90 bool ReadData(void* buffer, int32 size, int32 offset) const; |
| 91 | 91 |
| 92 // Closes the segment, returns true on success and false on failure. Closing | 92 // Closes the segment, returns true on success and false on failure. Closing |
| 93 // a segment makes it immutable. | 93 // a segment makes it immutable. |
| 94 bool Close(); | 94 bool Close(); |
| 95 | 95 |
| 96 // Returns true if segment can accommodate an entry of |size| bytes. | 96 // Returns true if segment can accommodate an entry of |size| bytes. |
| 97 bool CanHold(int32 size) const; | 97 bool CanHold(int32 size) const; |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 FRIEND_TEST_ALL_PREFIXES(SegmentTest, CreateDestroy); | |
| 101 | |
| 102 bool read_only_; // Indicates whether the segment can be written to. | 100 bool read_only_; // Indicates whether the segment can be written to. |
| 103 bool init_; // Indicates whether segment was initialized. | 101 bool init_; // Indicates whether segment was initialized. |
| 104 Storage* storage_; // Storage on which the segment resides. | 102 Storage* storage_; // Storage on which the segment resides. |
| 105 const int32 offset_; // Offset of the segment on |storage_|. | 103 const int32 offset_; // Offset of the segment on |storage_|. |
| 106 const int32 summary_offset_; // Offset of the segment summary. | 104 const int32 summary_offset_; // Offset of the segment summary. |
| 107 int32 write_offset_; // Current write offset. | 105 int32 write_offset_; // Current write offset. |
| 108 std::vector<int32> header_offsets_; | 106 std::vector<int32> header_offsets_; |
| 109 | 107 |
| 110 DISALLOW_COPY_AND_ASSIGN(Segment); | 108 DISALLOW_COPY_AND_ASSIGN(Segment); |
| 111 }; | 109 }; |
| 112 | 110 |
| 113 } // namespace disk_cache | 111 } // namespace disk_cache |
| 114 | 112 |
| 115 #endif // NET_DISK_CACHE_FLASH_SEGMENT_H_ | 113 #endif // NET_DISK_CACHE_FLASH_SEGMENT_H_ |
| OLD | NEW |