Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: net/disk_cache/simple/simple_entry_impl.h

Issue 15563005: **STILLBAKING** Switch SimpleCache to SequencedWorkerPool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/simple/simple_entry_impl.h
diff --git a/net/disk_cache/simple/simple_entry_impl.h b/net/disk_cache/simple/simple_entry_impl.h
index 134d28a11e6a9e494a41ea441cf026cf8cff10cf..692a69e8c859da5ccad17e8becfd9a58323b1a6f 100644
--- a/net/disk_cache/simple/simple_entry_impl.h
+++ b/net/disk_cache/simple/simple_entry_impl.h
@@ -17,7 +17,7 @@
#include "net/disk_cache/simple/simple_entry_format.h"
namespace base {
-class MessageLoopProxy;
+class TaskRunner;
}
namespace net {
@@ -37,6 +37,7 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>,
friend class base::RefCounted<SimpleEntryImpl>;
public:
SimpleEntryImpl(SimpleBackendImpl* backend,
+ base::TaskRunner* task_runner,
const base::FilePath& path,
const std::string& key,
uint64 entry_hash);
@@ -89,27 +90,6 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>,
virtual int ReadyForSparseIO(const CompletionCallback& callback) OVERRIDE;
private:
- class ScopedOperationRunner;
- friend class ScopedOperationRunner;
-
- enum State {
- // The state immediately after construction, but before |synchronous_entry_|
- // has been assigned. This is the state at construction, and is the only
- // legal state to destruct an entry in.
- STATE_UNINITIALIZED,
-
- // This entry is available for regular IO.
- STATE_READY,
-
- // IO is currently in flight, operations must wait for completion before
- // launching.
- STATE_IO_PENDING,
-
- // A failure occurred in the current or previous operation. All operations
- // after that must fail, until we receive a Close().
- STATE_FAILURE,
- };
-
virtual ~SimpleEntryImpl();
// Sets entry to STATE_UNINITIALIZED.
@@ -128,31 +108,25 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>,
// index.
void MarkAsDoomed();
- // Runs the next operation in the queue, if any and if there is no other
- // operation running at the moment.
- // WARNING: May delete |this|, as an operation in the queue can contain
- // the last reference.
- void RunNextOperationIfNeeded();
-
- void OpenEntryInternal(const CompletionCallback& callback, Entry** out_entry);
+ int OpenEntryInternal(const CompletionCallback& callback, Entry** out_entry);
- void CreateEntryInternal(const CompletionCallback& callback,
+ int CreateEntryInternal(const CompletionCallback& callback,
Entry** out_entry);
void CloseInternal();
- void ReadDataInternal(int index,
+ int ReadDataInternal(int index,
+ int offset,
+ net::IOBuffer* buf,
+ int buf_len,
+ const CompletionCallback& callback);
+
+ int WriteDataInternal(int index,
int offset,
net::IOBuffer* buf,
int buf_len,
- const CompletionCallback& callback);
-
- void WriteDataInternal(int index,
- int offset,
- net::IOBuffer* buf,
- int buf_len,
- const CompletionCallback& callback,
- bool truncate);
+ const CompletionCallback& callback,
+ bool truncate);
// Called after a SimpleSynchronousEntry has completed CreateEntry() or
// OpenEntry(). If |in_sync_entry| is non-NULL, creation is successful and we
@@ -161,15 +135,9 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>,
void CreationOperationComplete(
const CompletionCallback& completion_callback,
const base::TimeTicks& start_time,
- scoped_ptr<SimpleSynchronousEntry*> in_sync_entry,
scoped_ptr<int> in_result,
Entry** out_entry);
- // Called after we've closed and written the EOF record to our entry. Until
- // this point it hasn't been safe to OpenEntry() the same entry, but from this
- // point it is.
- void CloseOperationComplete();
-
// Internal utility method used by other completion methods. Calls
// |completion_callback| after updating state and dooming on errors.
void EntryOperationComplete(
@@ -221,13 +189,6 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>,
base::Time last_modified_;
int32 data_size_[kSimpleEntryFileCount];
- // Number of times this object has been returned from Backend::OpenEntry() and
- // Backend::CreateEntry() without subsequent Entry::Close() calls. Used to
- // notify the backend when this entry not used by any callers.
- int open_count_;
-
- State state_;
-
// When possible, we compute a crc32, for the data in each entry as we read or
// write. For each stream, |crc32s_[index]| is the crc32 of that stream from
// [0 .. |crc32s_end_offset_|). If |crc32s_end_offset_[index] == 0| then the
@@ -243,7 +204,8 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>,
// is false (i.e. when an operation is not pending on the worker pool).
SimpleSynchronousEntry* synchronous_entry_;
- std::queue<base::Closure> pending_operations_;
+ // Used to run all IO operations for this entry.
+ scoped_refptr<base::TaskRunner> task_runner_;
};
} // namespace disk_cache

Powered by Google App Engine
This is Rietveld 408576698