OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_STORAGE_BLOCK_H__ | 7 #ifndef NET_DISK_CACHE_STORAGE_BLOCK_H__ |
8 #define NET_DISK_CACHE_STORAGE_BLOCK_H__ | 8 #define NET_DISK_CACHE_STORAGE_BLOCK_H__ |
9 | 9 |
10 #include "net/disk_cache/addr.h" | 10 #include "net/disk_cache/addr.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Allows the overide of dummy values passed on the constructor. | 43 // Allows the overide of dummy values passed on the constructor. |
44 bool LazyInit(MappedFile* file, Addr address); | 44 bool LazyInit(MappedFile* file, Addr address); |
45 | 45 |
46 // Sets the internal storage to share the memory provided by other instance. | 46 // Sets the internal storage to share the memory provided by other instance. |
47 void SetData(T* other); | 47 void SetData(T* other); |
48 | 48 |
49 // Deletes the data, even if it was modified and not saved. This object must | 49 // Deletes the data, even if it was modified and not saved. This object must |
50 // own the memory buffer (it cannot be shared). | 50 // own the memory buffer (it cannot be shared). |
51 void Discard(); | 51 void Discard(); |
52 | 52 |
| 53 // Stops sharing the data with another object. |
| 54 void StopSharingData(); |
| 55 |
53 // Sets the object to lazily save the in-memory data on destruction. | 56 // Sets the object to lazily save the in-memory data on destruction. |
54 void set_modified(); | 57 void set_modified(); |
55 | 58 |
56 // Gets a pointer to the internal storage (allocates storage if needed). | 59 // Gets a pointer to the internal storage (allocates storage if needed). |
57 T* Data(); | 60 T* Data(); |
58 | 61 |
59 // Returns true if there is data associated with this object. | 62 // Returns true if there is data associated with this object. |
60 bool HasData() const; | 63 bool HasData() const; |
61 | 64 |
| 65 // Returns true if this object owns the data buffer, false if it is shared. |
| 66 bool own_data() const; |
| 67 |
62 const Addr address() const; | 68 const Addr address() const; |
63 | 69 |
64 // Loads and store the data. | 70 // Loads and store the data. |
65 bool Load(); | 71 bool Load(); |
66 bool Store(); | 72 bool Store(); |
67 | 73 |
68 private: | 74 private: |
69 void AllocateData(); | 75 void AllocateData(); |
70 void DeleteData(); | 76 void DeleteData(); |
71 | 77 |
72 T* data_; | 78 T* data_; |
73 MappedFile* file_; | 79 MappedFile* file_; |
74 Addr address_; | 80 Addr address_; |
75 bool modified_; | 81 bool modified_; |
76 bool own_data_; // Is data_ owned by this object or shared with someone else. | 82 bool own_data_; // Is data_ owned by this object or shared with someone else. |
77 bool extended_; // Used to store an entry of more than one block. | 83 bool extended_; // Used to store an entry of more than one block. |
78 | 84 |
79 DISALLOW_EVIL_CONSTRUCTORS(StorageBlock); | 85 DISALLOW_EVIL_CONSTRUCTORS(StorageBlock); |
80 }; | 86 }; |
81 | 87 |
82 typedef StorageBlock<EntryStore> CacheEntryBlock; | 88 typedef StorageBlock<EntryStore> CacheEntryBlock; |
83 typedef StorageBlock<RankingsNode> CacheRankingsBlock; | 89 typedef StorageBlock<RankingsNode> CacheRankingsBlock; |
84 | 90 |
85 } // namespace disk_cache | 91 } // namespace disk_cache |
86 | 92 |
87 #endif // NET_DISK_CACHE_STORAGE_BLOCK_H__ | 93 #endif // NET_DISK_CACHE_STORAGE_BLOCK_H__ |
OLD | NEW |