summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/backend_impl.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-01 01:12:00 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-01 01:12:00 +0000
commit05bebf1bc8d96ca3262cd3015af5c8178d3e7f84 (patch)
tree147efbc0cd0087e277aed96ed01ba6b85a254faf /net/disk_cache/backend_impl.h
parent6ebf2fc952b8170971e37971e9d1362c64424e89 (diff)
downloadchromium_src-05bebf1bc8d96ca3262cd3015af5c8178d3e7f84.zip
chromium_src-05bebf1bc8d96ca3262cd3015af5c8178d3e7f84.tar.gz
chromium_src-05bebf1bc8d96ca3262cd3015af5c8178d3e7f84.tar.bz2
Revert 51312 - Disk cache: Switch the disk cache to use the cache_thread.
(tsan errors on the unit tests) Add an InFlightBackendIO class that handles posting of cacheoperations back and forth between the IO thread and the cachethread. BUG=26730 TEST=unit tests Review URL: http://codereview.chromium.org/2829008 TBR=nsylvain@chromium.org Review URL: http://codereview.chromium.org/2819032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/backend_impl.h')
-rw-r--r--net/disk_cache/backend_impl.h49
1 files changed, 9 insertions, 40 deletions
diff --git a/net/disk_cache/backend_impl.h b/net/disk_cache/backend_impl.h
index 6dc2d2e..706a0cb 100644
--- a/net/disk_cache/backend_impl.h
+++ b/net/disk_cache/backend_impl.h
@@ -13,7 +13,6 @@
#include "net/disk_cache/block_files.h"
#include "net/disk_cache/disk_cache.h"
#include "net/disk_cache/eviction.h"
-#include "net/disk_cache/in_flight_backend_io.h"
#include "net/disk_cache/rankings.h"
#include "net/disk_cache/stats.h"
#include "net/disk_cache/trace.h"
@@ -37,20 +36,18 @@ class BackendImpl : public Backend {
friend class Eviction;
public:
BackendImpl(const FilePath& path, base::MessageLoopProxy* cache_thread)
- : ALLOW_THIS_IN_INITIALIZER_LIST(background_queue_(this, cache_thread)),
- path_(path), block_files_(path), mask_(0), max_size_(0),
+ : path_(path), block_files_(path), mask_(0), max_size_(0),
cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(0),
init_(false), restarted_(false), unit_test_(false), read_only_(false),
- new_eviction_(false), first_timer_(true), done_(true, false),
+ new_eviction_(false), first_timer_(true),
ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
// mask can be used to limit the usable size of the hash table, for testing.
BackendImpl(const FilePath& path, uint32 mask,
base::MessageLoopProxy* cache_thread)
- : ALLOW_THIS_IN_INITIALIZER_LIST(background_queue_(this, cache_thread)),
- path_(path), block_files_(path), mask_(mask), max_size_(0),
+ : path_(path), block_files_(path), mask_(mask), max_size_(0),
cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask),
init_(false), restarted_(false), unit_test_(false), read_only_(false),
- new_eviction_(false), first_timer_(true), done_(true, false),
+ new_eviction_(false), first_timer_(true),
ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
~BackendImpl();
@@ -62,12 +59,7 @@ class BackendImpl : public Backend {
Backend** backend, CompletionCallback* callback);
// Performs general initialization for this current instance of the cache.
- bool Init(); // Deprecated.
- int Init(CompletionCallback* callback);
- int SyncInit();
-
- // Performs final cleanup on destruction.
- void CleanupCache();
+ bool Init();
// Backend interface.
virtual int32 GetEntryCount() const;
@@ -87,17 +79,6 @@ class BackendImpl : public Backend {
virtual void EndEnumeration(void** iter);
virtual void GetStats(StatsItems* stats);
- // Synchronous implementation of the asynchronous interface.
- int SyncOpenEntry(const std::string& key, Entry** entry);
- int SyncCreateEntry(const std::string& key, Entry** entry);
- int SyncDoomEntry(const std::string& key);
- int SyncDoomAllEntries();
- int SyncDoomEntriesBetween(const base::Time initial_time,
- const base::Time end_time);
- int SyncDoomEntriesSince(const base::Time initial_time);
- int SyncOpenNextEntry(void** iter, Entry** next_entry);
- void SyncEndEnumeration(void* iter);
-
// Sets the maximum size for the total amount of data stored by this instance.
bool SetMaxSize(int max_bytes);
@@ -110,10 +91,6 @@ class BackendImpl : public Backend {
// Returns the actual file used to store a given (non-external) address.
MappedFile* File(Addr address);
- InFlightBackendIO* background_queue() {
- return &background_queue_;
- }
-
// Creates an external storage file.
bool CreateExternalFile(Addr* address);
@@ -216,17 +193,12 @@ class BackendImpl : public Backend {
// Clears the counter of references to test handling of corruptions.
void ClearRefCountForTest();
- // Sends a dummy operation through the operation queue, for unit tests.
- int FlushQueueForTest(CompletionCallback* callback);
-
// Peforms a simple self-check, and returns the number of dirty items
// or an error code (negative value).
int SelfCheck();
// Same bahavior as OpenNextEntry but walks the list from back to front.
- int OpenPrevEntry(void** iter, Entry** prev_entry,
- CompletionCallback* callback);
- int SyncOpenPrevEntry(void** iter, Entry** prev_entry);
+ bool OpenPrevEntry(void** iter, Entry** prev_entry);
// Old Backend interface.
bool OpenEntry(const std::string& key, Entry** entry);
@@ -236,12 +208,11 @@ class BackendImpl : public Backend {
bool DoomEntriesBetween(const base::Time initial_time,
const base::Time end_time);
bool DoomEntriesSince(const base::Time initial_time);
+ bool OpenNextEntry(void** iter, Entry** next_entry);
- // Open or create an entry for the given |key| or |iter|.
+ // Open or create an entry for the given |key|.
EntryImpl* OpenEntryImpl(const std::string& key);
EntryImpl* CreateEntryImpl(const std::string& key);
- EntryImpl* OpenNextEntryImpl(void** iter);
- EntryImpl* OpenPrevEntryImpl(void** iter);
private:
typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap;
@@ -265,7 +236,7 @@ class BackendImpl : public Backend {
EntryImpl* MatchEntry(const std::string& key, uint32 hash, bool find_parent);
// Opens the next or previous entry on a cache iteration.
- EntryImpl* OpenFollowingEntry(bool forward, void** iter);
+ bool OpenFollowingEntry(bool forward, void** iter, Entry** next_entry);
// Opens the next or previous entry on a single list. If successfull,
// |from_entry| will be updated to point to the new entry, otherwise it will
@@ -312,7 +283,6 @@ class BackendImpl : public Backend {
// Part of the self test. Returns false if the entry is corrupt.
bool CheckEntry(EntryImpl* cache_entry);
- InFlightBackendIO background_queue_; // The controller of pending operations.
scoped_refptr<MappedFile> index_; // The main cache index.
FilePath path_; // Path to the folder used as backing storage.
Index* data_; // Pointer to the index data.
@@ -338,7 +308,6 @@ class BackendImpl : public Backend {
Stats stats_; // Usage statistcs.
base::RepeatingTimer<BackendImpl> timer_; // Usage timer.
- base::WaitableEvent done_; // Signals the end of background work.
scoped_refptr<TraceObject> trace_object_; // Inits internal tracing.
ScopedRunnableMethodFactory<BackendImpl> factory_;