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 // Defines the public interface of the disk cache. For more details see | 5 // Defines the public interface of the disk cache. For more details see |
6 // http://dev.chromium.org/developers/design-documents/network-stack/disk-cache | 6 // http://dev.chromium.org/developers/design-documents/network-stack/disk-cache |
7 | 7 |
8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_ | 8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_ |
9 #define NET_DISK_CACHE_DISK_CACHE_H_ | 9 #define NET_DISK_CACHE_DISK_CACHE_H_ |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 virtual void GetStats(base::StringPairs* stats) = 0; | 177 virtual void GetStats(base::StringPairs* stats) = 0; |
178 | 178 |
179 // Called whenever an external cache in the system reuses the resource | 179 // Called whenever an external cache in the system reuses the resource |
180 // referred to by |key|. | 180 // referred to by |key|. |
181 virtual void OnExternalCacheHit(const std::string& key) = 0; | 181 virtual void OnExternalCacheHit(const std::string& key) = 0; |
182 | 182 |
183 // Returns the estimate of dynamically allocated memory in bytes. | 183 // Returns the estimate of dynamically allocated memory in bytes. |
184 virtual size_t DumpMemoryStats( | 184 virtual size_t DumpMemoryStats( |
185 base::trace_event::ProcessMemoryDump* pmd, | 185 base::trace_event::ProcessMemoryDump* pmd, |
186 const std::string& parent_absolute_name) const = 0; | 186 const std::string& parent_absolute_name) const = 0; |
| 187 |
| 188 // Backends can optionally permit one to store, probabilistically, up to a |
| 189 // byte associated with a key (for an existing entry). Accessing the key is |
| 190 // guaranteed to be cheap, but the method is permitted to return 0, and may, |
| 191 // with low probability, even return values associated with the wrong key in |
| 192 // case of collisions. Therefore it should not be used to make decisions that |
| 193 // affect correctness (especially security). |
| 194 virtual uint8_t GetMemoryEntryData(const std::string& key); |
| 195 virtual void SetMemoryEntryData(const std::string& key, uint8_t data); |
187 }; | 196 }; |
188 | 197 |
189 // This interface represents an entry in the disk cache. | 198 // This interface represents an entry in the disk cache. |
190 class NET_EXPORT Entry { | 199 class NET_EXPORT Entry { |
191 public: | 200 public: |
192 typedef net::CompletionCallback CompletionCallback; | 201 typedef net::CompletionCallback CompletionCallback; |
193 typedef net::IOBuffer IOBuffer; | 202 typedef net::IOBuffer IOBuffer; |
194 | 203 |
195 // Marks this cache entry for deletion. | 204 // Marks this cache entry for deletion. |
196 virtual void Doom() = 0; | 205 virtual void Doom() = 0; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 entry->Close(); | 362 entry->Close(); |
354 } | 363 } |
355 }; | 364 }; |
356 | 365 |
357 // Automatically closes an entry when it goes out of scope. | 366 // Automatically closes an entry when it goes out of scope. |
358 typedef std::unique_ptr<Entry, EntryDeleter> ScopedEntryPtr; | 367 typedef std::unique_ptr<Entry, EntryDeleter> ScopedEntryPtr; |
359 | 368 |
360 } // namespace disk_cache | 369 } // namespace disk_cache |
361 | 370 |
362 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 371 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
OLD | NEW |