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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 virtual void GetStats(base::StringPairs* stats) = 0; | 216 virtual void GetStats(base::StringPairs* stats) = 0; |
217 | 217 |
218 // Called whenever an external cache in the system reuses the resource | 218 // Called whenever an external cache in the system reuses the resource |
219 // referred to by |key|. | 219 // referred to by |key|. |
220 virtual void OnExternalCacheHit(const std::string& key) = 0; | 220 virtual void OnExternalCacheHit(const std::string& key) = 0; |
221 | 221 |
222 // Returns the estimate of dynamically allocated memory in bytes. | 222 // Returns the estimate of dynamically allocated memory in bytes. |
223 virtual size_t DumpMemoryStats( | 223 virtual size_t DumpMemoryStats( |
224 base::trace_event::ProcessMemoryDump* pmd, | 224 base::trace_event::ProcessMemoryDump* pmd, |
225 const std::string& parent_absolute_name) const = 0; | 225 const std::string& parent_absolute_name) const = 0; |
| 226 |
| 227 // Backends can optionally permit one to store, probabilistically, up to a |
| 228 // byte associated with a key of an existing entry in memory. |
| 229 |
| 230 // GetEntryInMemoryData has the following behavior: |
| 231 // - If the data is not available at this time for any reason, returns 0. |
| 232 // - Otherwise, returns a value that was with very high probability |
| 233 // given to SetEntryInMemoryData(|key|) (and with a very low probability |
| 234 // to a different key that collides in the in-memory index). |
| 235 // |
| 236 // Due to the probability of collisions, including those that can be induced |
| 237 // by hostile 3rd parties, this interface should not be used to make decisions |
| 238 // that affect correctness (especially security). |
| 239 virtual uint8_t GetEntryInMemoryData(const std::string& key); |
| 240 virtual void SetEntryInMemoryData(const std::string& key, uint8_t data); |
226 }; | 241 }; |
227 | 242 |
228 // This interface represents an entry in the disk cache. | 243 // This interface represents an entry in the disk cache. |
229 class NET_EXPORT Entry { | 244 class NET_EXPORT Entry { |
230 public: | 245 public: |
231 typedef net::CompletionCallback CompletionCallback; | 246 typedef net::CompletionCallback CompletionCallback; |
232 typedef net::IOBuffer IOBuffer; | 247 typedef net::IOBuffer IOBuffer; |
233 | 248 |
234 // Marks this cache entry for deletion. | 249 // Marks this cache entry for deletion. |
235 virtual void Doom() = 0; | 250 virtual void Doom() = 0; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 entry->Close(); | 407 entry->Close(); |
393 } | 408 } |
394 }; | 409 }; |
395 | 410 |
396 // Automatically closes an entry when it goes out of scope. | 411 // Automatically closes an entry when it goes out of scope. |
397 typedef std::unique_ptr<Entry, EntryDeleter> ScopedEntryPtr; | 412 typedef std::unique_ptr<Entry, EntryDeleter> ScopedEntryPtr; |
398 | 413 |
399 } // namespace disk_cache | 414 } // namespace disk_cache |
400 | 415 |
401 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 416 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
OLD | NEW |