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/sparse_control.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/sparse_control.h')
-rw-r--r-- | net/disk_cache/sparse_control.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/net/disk_cache/sparse_control.h b/net/disk_cache/sparse_control.h index 534d1a9..24f5446 100644 --- a/net/disk_cache/sparse_control.h +++ b/net/disk_cache/sparse_control.h @@ -6,6 +6,7 @@ #define NET_DISK_CACHE_SPARSE_CONTROL_H_ #include <string> +#include <vector> #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -63,6 +64,14 @@ class SparseControl { // Implements Entry::GetAvailableRange(). int GetAvailableRange(int64 offset, int len, int64* start); + // Cancels the current sparse operation (if any). + void CancelIO(); + + // Returns OK if the entry can be used for new IO or ERR_IO_PENDING if we are + // busy. If the entry is busy, we'll invoke the callback when we are ready + // again. See disk_cache::Entry::ReadyToUse() for more info. + int ReadyToUse(net::CompletionCallback* completion_callback); + // Deletes the children entries of |entry|. static void DeleteChildren(EntryImpl* entry); @@ -134,6 +143,7 @@ class SparseControl { // Reports to the user that we are done. void DoUserCallback(); + void DoAbortCallbacks(); EntryImpl* entry_; // The sparse entry. Entry* child_; // The current child entry. @@ -142,6 +152,7 @@ class SparseControl { bool finished_; bool init_; bool range_found_; // True if GetAvailableRange found something. + bool abort_; // True if we should abort the current operation ASAP. SparseHeader sparse_header_; // Data about the children of entry_. Bitmap children_map_; // The actual bitmap of children. @@ -150,6 +161,7 @@ class SparseControl { net::CompletionCallbackImpl<SparseControl> child_callback_; net::CompletionCallback* user_callback_; + std::vector<net::CompletionCallback*> abort_callbacks_; int64 offset_; // Current sparse offset. scoped_refptr<net::ReusedIOBuffer> user_buf_; int buf_len_; // Bytes to read or write. |