diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 23:07:39 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 23:07:39 +0000 |
commit | 06e62baf611d6fca8698d50765bca81989155845 (patch) | |
tree | 5516ccda32e56e7dae301b8b30f5fd24a4c8b83c /net/disk_cache/disk_cache.h | |
parent | 681d3b6b072e17a5de40be8794550f781bf28d87 (diff) | |
download | chromium_src-06e62baf611d6fca8698d50765bca81989155845.zip chromium_src-06e62baf611d6fca8698d50765bca81989155845.tar.gz chromium_src-06e62baf611d6fca8698d50765bca81989155845.tar.bz2 |
Disk cache: Add a method to cancel pending sparse operations.
The sparse IO methods require exclusive use of the cache entry
and they complain when that requirement is violated. When the
user cancels a request and reissues another one to the same entry,
we may be waiting for the previous operation to finish when we
receive a new IO request, so we fail.
This CL add a way for the HTTP cache to cancel IO operations and
get a notification when the disk cache is able to operate on that
entry again.
BUG=23862
TEST=unittests
Review URL: http://codereview.chromium.org/256090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/disk_cache.h')
-rw-r--r-- | net/disk_cache/disk_cache.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/net/disk_cache/disk_cache.h b/net/disk_cache/disk_cache.h index f43cace..04c08d6 100644 --- a/net/disk_cache/disk_cache.h +++ b/net/disk_cache/disk_cache.h @@ -183,6 +183,18 @@ class Entry { // The Backend implementation is free to evict any range from the cache at any // moment, so in practice, the previously stated granularity of 1 KB is not // as bad as it sounds. + // + // The sparse methods don't support multiple simultaneous IO operations to the + // same physical entry, so in practice a single object should be instantiated + // for a given key at any given time. Once an operation has been issued, the + // caller should wait until it completes before starting another one. This + // requirement includes the case when an entry is closed while some operation + // is in progress and another object is instantiated; any IO operation will + // fail while the previous operation is still in-flight. In order to deal with + // this requirement, the caller could either wait until the operation + // completes before closing the entry, or call CancelSparseIO() before closing + // the entry, and call ReadyForSparseIO() on the new entry and wait for the + // callback before issuing new operations. // Behaves like ReadData() except that this method is used to access sparse // entries. @@ -207,6 +219,26 @@ class Entry { // net error code whenever the request cannot be completed successfully. virtual int GetAvailableRange(int64 offset, int len, int64* start) = 0; + // Cancels any pending sparse IO operation (if any). The completion callback + // of the operation in question will still be called when the operation + // finishes, but the operation will finish sooner when this method is used. + virtual void CancelSparseIO() = 0; + + // Returns OK if this entry can be used immediately. If that is not the + // case, returns ERR_IO_PENDING and invokes the provided callback when this + // entry is ready to use. This method always returns OK for non-sparse + // entries, and returns ERR_IO_PENDING when a previous operation was cancelled + // (by calling CancelSparseIO), but the cache is still busy with it. If there + // is a pending operation that has not been cancelled, this method will return + // OK although another IO operation cannot be issued at this time; in this + // case the caller should just wait for the regular callback to be invoked + // instead of using this method to provide another callback. + // + // Note that CancelSparseIO may have been called on another instance of this + // object that refers to the same physical disk entry. + virtual int ReadyForSparseIO( + net::CompletionCallback* completion_callback) = 0; + protected: virtual ~Entry() {} }; |