Chromium Code Reviews| Index: net/disk_cache/disk_cache.h |
| diff --git a/net/disk_cache/disk_cache.h b/net/disk_cache/disk_cache.h |
| index 4a3ae119b53f9c90b22f5c70379e5d4fb0f1f057..adcb21195bf0934e15da5b5af4cf602da223db55 100644 |
| --- a/net/disk_cache/disk_cache.h |
| +++ b/net/disk_cache/disk_cache.h |
| @@ -71,7 +71,10 @@ NET_EXPORT int CreateCacheBackend( |
| // The root interface for a disk cache instance. |
| class NET_EXPORT Backend { |
| public: |
| + enum class OracleJudgement { HIT, MISS_AND_DOOM }; |
| + |
| typedef net::CompletionCallback CompletionCallback; |
| + typedef base::Callback<OracleJudgement(uint8_t)> OracleCallback; |
| class Iterator { |
| public: |
| @@ -116,6 +119,16 @@ class NET_EXPORT Backend { |
| virtual int OpenEntry(const std::string& key, Entry** entry, |
| const CompletionCallback& callback) = 0; |
| + // This is a variant of above, which can give the client a chance to quickly |
| + // invalidate the entry w/o fully opening it, by taking a look at a byte |
| + // it has previously passed to Entry::SetOracleByte inside |oracle|. |
| + // |
| + // Default implementation just delegates to OpenEntry. |
| + virtual int OpenEntryWithOracleByte(const std::string& key, |
|
jkarlin
2017/06/07 20:01:54
I'd rather we have a more general purpose byte in
jkarlin
2017/06/07 20:04:44
Ah, this will have to be an async call won't it be
|
| + Entry** entry, |
| + const OracleCallback& oracle, |
| + const CompletionCallback& callback); |
| + |
| // Creates a new entry. Upon success, the out param holds a pointer to an |
| // Entry object representing the newly created disk cache entry. When the |
| // entry pointer is no longer needed, its Close method should be called. The |
| @@ -212,6 +225,15 @@ class NET_EXPORT Entry { |
| // Returns the size of the cache data with the given index. |
| virtual int32_t GetDataSize(int index) const = 0; |
| + // If supported by the backend, stores a byte associated with this entry in a |
| + // way that can be accessed efficiently by OpenEntryWithOracleByte (before |
| + // opening the whole entry). |
| + // TBD non-zero, blah blah. |
| + // TBD. |
| + // |
| + // Default implementation does nothing. |
| + virtual void SetOracleByte(uint8_t); |
| + |
| // Copies cached data into the given buffer of length |buf_len|. Returns the |
| // number of bytes read or a network error code. If this function returns |
| // ERR_IO_PENDING, the completion callback will be called on the current |