| 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 // See net/disk_cache/disk_cache.h for the public interface. | 5 // See net/disk_cache/disk_cache.h for the public interface. |
| 6 | 6 |
| 7 #ifndef NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ | 7 #ifndef NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ |
| 8 #define NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ | 8 #define NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ |
| 9 | 9 |
| 10 #include <stddef.h> |
| 11 #include <stdint.h> |
| 12 |
| 13 #include "base/macros.h" |
| 10 #include "net/disk_cache/blockfile/addr.h" | 14 #include "net/disk_cache/blockfile/addr.h" |
| 11 #include "net/disk_cache/blockfile/mapped_file.h" | 15 #include "net/disk_cache/blockfile/mapped_file.h" |
| 12 | 16 |
| 13 namespace disk_cache { | 17 namespace disk_cache { |
| 14 | 18 |
| 15 // This class encapsulates common behavior of a single "block" of data that is | 19 // This class encapsulates common behavior of a single "block" of data that is |
| 16 // stored on a block-file. It implements the FileBlock interface, so it can be | 20 // stored on a block-file. It implements the FileBlock interface, so it can be |
| 17 // serialized directly to the backing file. | 21 // serialized directly to the backing file. |
| 18 // This object provides a memory buffer for the related data, and it can be used | 22 // This object provides a memory buffer for the related data, and it can be used |
| 19 // to actually share that memory with another instance of the class. | 23 // to actually share that memory with another instance of the class. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 77 |
| 74 // Loads and store the data. | 78 // Loads and store the data. |
| 75 bool Load(); | 79 bool Load(); |
| 76 bool Store(); | 80 bool Store(); |
| 77 bool Load(FileIOCallback* callback, bool* completed); | 81 bool Load(FileIOCallback* callback, bool* completed); |
| 78 bool Store(FileIOCallback* callback, bool* completed); | 82 bool Store(FileIOCallback* callback, bool* completed); |
| 79 | 83 |
| 80 private: | 84 private: |
| 81 void AllocateData(); | 85 void AllocateData(); |
| 82 void DeleteData(); | 86 void DeleteData(); |
| 83 uint32 CalculateHash() const; | 87 uint32_t CalculateHash() const; |
| 84 | 88 |
| 85 T* data_; | 89 T* data_; |
| 86 MappedFile* file_; | 90 MappedFile* file_; |
| 87 Addr address_; | 91 Addr address_; |
| 88 bool modified_; | 92 bool modified_; |
| 89 bool own_data_; // Is data_ owned by this object or shared with someone else. | 93 bool own_data_; // Is data_ owned by this object or shared with someone else. |
| 90 bool extended_; // Used to store an entry of more than one block. | 94 bool extended_; // Used to store an entry of more than one block. |
| 91 | 95 |
| 92 DISALLOW_COPY_AND_ASSIGN(StorageBlock); | 96 DISALLOW_COPY_AND_ASSIGN(StorageBlock); |
| 93 }; | 97 }; |
| 94 | 98 |
| 95 } // namespace disk_cache | 99 } // namespace disk_cache |
| 96 | 100 |
| 97 #endif // NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ | 101 #endif // NET_DISK_CACHE_BLOCKFILE_STORAGE_BLOCK_H_ |
| OLD | NEW |