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

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

Issue 14130015: Support overlapping operations on the SimpleEntryImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Egor comments Created 7 years, 8 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 d1b1c73ea7a67e52f54a61dee77f061f4abb4c88..eb396fbe1d04912b68254ccfcc66589b1fad06f2 100644
--- a/net/disk_cache/simple/simple_entry_impl.h
+++ b/net/disk_cache/simple/simple_entry_impl.h
@@ -5,6 +5,7 @@
#ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
#define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
+#include <queue>
#include <string>
#include "base/files/file_path.h"
@@ -91,6 +92,23 @@ class SimpleEntryImpl : public Entry,
virtual ~SimpleEntryImpl();
+ // Runs the next operation in the queue, if any and if there is no other
+ // operation running at the moment. Returns true if a operation has run.
+ bool RunNextOperationIfNeeded();
+
+ void ReadDataInternal(int index,
+ int offset,
+ scoped_refptr<net::IOBuffer> buf,
+ int buf_len,
+ const CompletionCallback& callback);
+
+ void WriteDataInternal(int index,
+ int offset,
+ scoped_refptr<net::IOBuffer> buf,
+ int buf_len,
+ const CompletionCallback& callback,
+ bool truncate);
+
// Called after a SimpleSynchronousEntry has completed CreateEntry() or
// OpenEntry(). If |sync_entry| is non-NULL, creation is successful and we
// can return |this| SimpleEntryImpl to |*out_entry|. Runs
@@ -116,7 +134,6 @@ class SimpleEntryImpl : public Entry,
// thread, in all cases. |io_thread_checker_| documents and enforces this.
base::ThreadChecker io_thread_checker_;
- const scoped_refptr<base::MessageLoopProxy> constructor_thread_;
const scoped_refptr<SimpleIndex> index_;
const base::FilePath path_;
const std::string key_;
@@ -128,16 +145,15 @@ class SimpleEntryImpl : public Entry,
int32 data_size_[kSimpleEntryFileCount];
// The |synchronous_entry_| is the worker thread object that performs IO on
- // entries. It's owned by this SimpleEntryImpl whenever
- // |synchronous_entry_in_use_by_worker_| is false (i.e. when an operation
- // is not pending on the worker pool). When an operation is pending on the
- // worker pool, the |synchronous_entry_| is owned by itself.
+ // entries. It's owned by this SimpleEntryImpl whenever |operation_running_|
+ // is false (i.e. when an operation is not pending on the worker pool).
SimpleSynchronousEntry* synchronous_entry_;
// Set to true when a worker operation is posted on the |synchronous_entry_|,
// and false after. Used to ensure thread safety by not allowing multiple
// threads to access the |synchronous_entry_| simultaneously.
- bool synchronous_entry_in_use_by_worker_;
+ bool operation_running_;
+ std::queue<base::Closure> pending_operations_;
};
} // namespace disk_cache

Powered by Google App Engine
This is Rietveld 408576698