| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/disk-cache | 6 // http://dev.chromium.org/developers/design-documents/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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // callback that has not been invoked yet), this method cancels said | 58 // callback that has not been invoked yet), this method cancels said |
| 59 // operations so the callbacks are not invoked, possibly leaving the work | 59 // operations so the callbacks are not invoked, possibly leaving the work |
| 60 // half way (for instance, dooming just a few entries). Note that pending IO | 60 // half way (for instance, dooming just a few entries). Note that pending IO |
| 61 // for a given Entry (as opposed to the Backend) will still generate a | 61 // for a given Entry (as opposed to the Backend) will still generate a |
| 62 // callback from within this method. | 62 // callback from within this method. |
| 63 virtual ~Backend() {} | 63 virtual ~Backend() {} |
| 64 | 64 |
| 65 // Returns the number of entries in the cache. | 65 // Returns the number of entries in the cache. |
| 66 virtual int32 GetEntryCount() const = 0; | 66 virtual int32 GetEntryCount() const = 0; |
| 67 | 67 |
| 68 // Opens an existing entry. Upon success, the out param holds a pointer | |
| 69 // to a Entry object representing the specified disk cache entry. | |
| 70 // When the entry pointer is no longer needed, the Close method | |
| 71 // should be called. | |
| 72 // Note: This method is deprecated. | |
| 73 virtual bool OpenEntry(const std::string& key, Entry** entry) = 0; | |
| 74 | |
| 75 // Opens an existing entry. Upon success, |entry| holds a pointer to an Entry | 68 // Opens an existing entry. Upon success, |entry| holds a pointer to an Entry |
| 76 // object representing the specified disk cache entry. When the entry pointer | 69 // object representing the specified disk cache entry. When the entry pointer |
| 77 // is no longer needed, its Close method should be called. The return value is | 70 // is no longer needed, its Close method should be called. The return value is |
| 78 // a net error code. If this method returns ERR_IO_PENDING, the |callback| | 71 // a net error code. If this method returns ERR_IO_PENDING, the |callback| |
| 79 // will be invoked when the entry is available. The pointer to receive the | 72 // will be invoked when the entry is available. The pointer to receive the |
| 80 // |entry| must remain valid until the operation completes. | 73 // |entry| must remain valid until the operation completes. |
| 81 virtual int OpenEntry(const std::string& key, Entry** entry, | 74 virtual int OpenEntry(const std::string& key, Entry** entry, |
| 82 CompletionCallback* callback) = 0; | 75 CompletionCallback* callback) = 0; |
| 83 | 76 |
| 84 // Creates a new entry. Upon success, the out param holds a pointer | |
| 85 // to a Entry object representing the newly created disk cache | |
| 86 // entry. When the entry pointer is no longer needed, the Close | |
| 87 // method should be called. | |
| 88 // Note: This method is deprecated. | |
| 89 virtual bool CreateEntry(const std::string& key, Entry** entry) = 0; | |
| 90 | |
| 91 // Creates a new entry. Upon success, the out param holds a pointer to an | 77 // Creates a new entry. Upon success, the out param holds a pointer to an |
| 92 // Entry object representing the newly created disk cache entry. When the | 78 // Entry object representing the newly created disk cache entry. When the |
| 93 // entry pointer is no longer needed, its Close method should be called. The | 79 // entry pointer is no longer needed, its Close method should be called. The |
| 94 // return value is a net error code. If this method returns ERR_IO_PENDING, | 80 // return value is a net error code. If this method returns ERR_IO_PENDING, |
| 95 // the |callback| will be invoked when the entry is available. The pointer to | 81 // the |callback| will be invoked when the entry is available. The pointer to |
| 96 // receive the |entry| must remain valid until the operation completes. | 82 // receive the |entry| must remain valid until the operation completes. |
| 97 virtual int CreateEntry(const std::string& key, Entry** entry, | 83 virtual int CreateEntry(const std::string& key, Entry** entry, |
| 98 CompletionCallback* callback) = 0; | 84 CompletionCallback* callback) = 0; |
| 99 | 85 |
| 100 // Marks the entry, specified by the given key, for deletion. | |
| 101 // Note: This method is deprecated. | |
| 102 virtual bool DoomEntry(const std::string& key) = 0; | |
| 103 | |
| 104 // Marks the entry, specified by the given key, for deletion. The return value | 86 // Marks the entry, specified by the given key, for deletion. The return value |
| 105 // is a net error code. If this method returns ERR_IO_PENDING, the |callback| | 87 // is a net error code. If this method returns ERR_IO_PENDING, the |callback| |
| 106 // will be invoked after the entry is doomed. | 88 // will be invoked after the entry is doomed. |
| 107 virtual int DoomEntry(const std::string& key, | 89 virtual int DoomEntry(const std::string& key, |
| 108 CompletionCallback* callback) = 0; | 90 CompletionCallback* callback) = 0; |
| 109 | 91 |
| 110 // Marks all entries for deletion. | |
| 111 // Note: This method is deprecated. | |
| 112 virtual bool DoomAllEntries() = 0; | |
| 113 | |
| 114 // Marks all entries for deletion. The return value is a net error code. If | 92 // Marks all entries for deletion. The return value is a net error code. If |
| 115 // this method returns ERR_IO_PENDING, the |callback| will be invoked when the | 93 // this method returns ERR_IO_PENDING, the |callback| will be invoked when the |
| 116 // operation completes. | 94 // operation completes. |
| 117 virtual int DoomAllEntries(CompletionCallback* callback) = 0; | 95 virtual int DoomAllEntries(CompletionCallback* callback) = 0; |
| 118 | 96 |
| 119 // Marks a range of entries for deletion. This supports unbounded deletes in | 97 // Marks a range of entries for deletion. This supports unbounded deletes in |
| 120 // either direction by using null Time values for either argument. | |
| 121 // Note: This method is deprecated. | |
| 122 virtual bool DoomEntriesBetween(const base::Time initial_time, | |
| 123 const base::Time end_time) = 0; | |
| 124 | |
| 125 // Marks a range of entries for deletion. This supports unbounded deletes in | |
| 126 // either direction by using null Time values for either argument. The return | 98 // either direction by using null Time values for either argument. The return |
| 127 // value is a net error code. If this method returns ERR_IO_PENDING, the | 99 // value is a net error code. If this method returns ERR_IO_PENDING, the |
| 128 // |callback| will be invoked when the operation completes. | 100 // |callback| will be invoked when the operation completes. |
| 129 virtual int DoomEntriesBetween(const base::Time initial_time, | 101 virtual int DoomEntriesBetween(const base::Time initial_time, |
| 130 const base::Time end_time, | 102 const base::Time end_time, |
| 131 CompletionCallback* callback) = 0; | 103 CompletionCallback* callback) = 0; |
| 132 | 104 |
| 133 // Marks all entries accessed since initial_time for deletion. | |
| 134 // Note: This method is deprecated. | |
| 135 virtual bool DoomEntriesSince(const base::Time initial_time) = 0; | |
| 136 | |
| 137 // Marks all entries accessed since |initial_time| for deletion. The return | 105 // Marks all entries accessed since |initial_time| for deletion. The return |
| 138 // value is a net error code. If this method returns ERR_IO_PENDING, the | 106 // value is a net error code. If this method returns ERR_IO_PENDING, the |
| 139 // |callback| will be invoked when the operation completes. | 107 // |callback| will be invoked when the operation completes. |
| 140 virtual int DoomEntriesSince(const base::Time initial_time, | 108 virtual int DoomEntriesSince(const base::Time initial_time, |
| 141 CompletionCallback* callback) = 0; | 109 CompletionCallback* callback) = 0; |
| 142 | 110 |
| 143 // Enumerate the cache. Initialize iter to NULL before calling this method | |
| 144 // the first time. That will cause the enumeration to start at the head of | |
| 145 // the cache. For subsequent calls, pass the same iter pointer again without | |
| 146 // changing its value. This method returns false when there are no more | |
| 147 // entries to enumerate. When the entry pointer is no longer needed, the | |
| 148 // Close method should be called. | |
| 149 // | |
| 150 // NOTE: This method does not modify the last_used field of the entry, | |
| 151 // and therefore it does not impact the eviction ranking of the entry. | |
| 152 // Note: This method is deprecated. | |
| 153 virtual bool OpenNextEntry(void** iter, Entry** next_entry) = 0; | |
| 154 | |
| 155 // Enumerates the cache. Initialize |iter| to NULL before calling this method | 111 // Enumerates the cache. Initialize |iter| to NULL before calling this method |
| 156 // the first time. That will cause the enumeration to start at the head of | 112 // the first time. That will cause the enumeration to start at the head of |
| 157 // the cache. For subsequent calls, pass the same |iter| pointer again without | 113 // the cache. For subsequent calls, pass the same |iter| pointer again without |
| 158 // changing its value. This method returns ERR_FAILED when there are no more | 114 // changing its value. This method returns ERR_FAILED when there are no more |
| 159 // entries to enumerate. When the entry pointer is no longer needed, its | 115 // entries to enumerate. When the entry pointer is no longer needed, its |
| 160 // Close method should be called. The return value is a net error code. If | 116 // Close method should be called. The return value is a net error code. If |
| 161 // this method returns ERR_IO_PENDING, the |callback| will be invoked when the | 117 // this method returns ERR_IO_PENDING, the |callback| will be invoked when the |
| 162 // |next_entry| is available. The pointer to receive the |next_entry| must | 118 // |next_entry| is available. The pointer to receive the |next_entry| must |
| 163 // remain valid until the operation completes. | 119 // remain valid until the operation completes. |
| 164 // | 120 // |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // re-created. | 243 // re-created. |
| 288 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | 244 virtual int WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 289 CompletionCallback* completion_callback) = 0; | 245 CompletionCallback* completion_callback) = 0; |
| 290 | 246 |
| 291 // Returns information about the currently stored portion of a sparse entry. | 247 // Returns information about the currently stored portion of a sparse entry. |
| 292 // |offset| and |len| describe a particular range that should be scanned to | 248 // |offset| and |len| describe a particular range that should be scanned to |
| 293 // find out if it is stored or not. |start| will contain the offset of the | 249 // find out if it is stored or not. |start| will contain the offset of the |
| 294 // first byte that is stored within this range, and the return value is the | 250 // first byte that is stored within this range, and the return value is the |
| 295 // minimum number of consecutive stored bytes. Note that it is possible that | 251 // minimum number of consecutive stored bytes. Note that it is possible that |
| 296 // this entry has stored more than the returned value. This method returns a | 252 // this entry has stored more than the returned value. This method returns a |
| 297 // net error code whenever the request cannot be completed successfully. | |
| 298 // Note: This method is deprecated. | |
| 299 virtual int GetAvailableRange(int64 offset, int len, int64* start) = 0; | |
| 300 | |
| 301 // Returns information about the currently stored portion of a sparse entry. | |
| 302 // |offset| and |len| describe a particular range that should be scanned to | |
| 303 // find out if it is stored or not. |start| will contain the offset of the | |
| 304 // first byte that is stored within this range, and the return value is the | |
| 305 // minimum number of consecutive stored bytes. Note that it is possible that | |
| 306 // this entry has stored more than the returned value. This method returns a | |
| 307 // net error code whenever the request cannot be completed successfully. If | 253 // net error code whenever the request cannot be completed successfully. If |
| 308 // this method returns ERR_IO_PENDING, the |callback| will be invoked when the | 254 // this method returns ERR_IO_PENDING, the |callback| will be invoked when the |
| 309 // operation completes, and |start| must remain valid until that point. | 255 // operation completes, and |start| must remain valid until that point. |
| 310 virtual int GetAvailableRange(int64 offset, int len, int64* start, | 256 virtual int GetAvailableRange(int64 offset, int len, int64* start, |
| 311 CompletionCallback* callback) = 0; | 257 CompletionCallback* callback) = 0; |
| 312 | 258 |
| 313 // Returns true if this entry could be a sparse entry or false otherwise. This | 259 // Returns true if this entry could be a sparse entry or false otherwise. This |
| 314 // is a quick test that may return true even if the entry is not really | 260 // is a quick test that may return true even if the entry is not really |
| 315 // sparse. This method doesn't modify the state of this entry (it will not | 261 // sparse. This method doesn't modify the state of this entry (it will not |
| 316 // create sparse tracking data). GetAvailableRange or ReadSparseData can be | 262 // create sparse tracking data). GetAvailableRange or ReadSparseData can be |
| (...skipping 23 matching lines...) Expand all Loading... |
| 340 // Note: This method is deprecated. | 286 // Note: This method is deprecated. |
| 341 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; | 287 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; |
| 342 | 288 |
| 343 protected: | 289 protected: |
| 344 virtual ~Entry() {} | 290 virtual ~Entry() {} |
| 345 }; | 291 }; |
| 346 | 292 |
| 347 } // namespace disk_cache | 293 } // namespace disk_cache |
| 348 | 294 |
| 349 #endif // NET_DISK_CACHE_DISK_CACHE_H_ | 295 #endif // NET_DISK_CACHE_DISK_CACHE_H_ |
| OLD | NEW |