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

Unified Diff: content/browser/indexed_db/leveldb/leveldb_database.h

Issue 2760163002: [IndexedDB] Pool and evict leveldb iterators, to save memory (Closed)
Patch Set: compile fixed Created 3 years, 9 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: content/browser/indexed_db/leveldb/leveldb_database.h
diff --git a/content/browser/indexed_db/leveldb/leveldb_database.h b/content/browser/indexed_db/leveldb/leveldb_database.h
index cdcabb54647c83c9d2f56690e2a84ba2fecd87c9..1df138d6a6b3c08b564e40deb1eb4414fd4db18d 100644
--- a/content/browser/indexed_db/leveldb/leveldb_database.h
+++ b/content/browser/indexed_db/leveldb/leveldb_database.h
@@ -8,6 +8,7 @@
#include <memory>
#include <string>
+#include "base/containers/mru_cache.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/strings/string16.h"
@@ -75,6 +76,11 @@ class CONTENT_EXPORT LevelDBDatabase
const LevelDBComparator* comparator_;
};
+ static leveldb::Status OpenForTesting(const base::FilePath& file_name,
+ const LevelDBComparator* comparator,
+ std::unique_ptr<LevelDBDatabase>* db,
+ size_t max_open_cursors);
+
static leveldb::Status Open(const base::FilePath& file_name,
const LevelDBComparator* comparator,
std::unique_ptr<LevelDBDatabase>* db,
@@ -102,8 +108,13 @@ class CONTENT_EXPORT LevelDBDatabase
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override;
+ void NotifyIteratorCreated(LevelDBIterator*);
+ void NotifyIteratorUsed(LevelDBIterator*);
+ void NotifyIteratorDestroyed(LevelDBIterator*);
+
protected:
LevelDBDatabase();
+ LevelDBDatabase(size_t max_open_iterators);
private:
friend class LevelDBSnapshot;
@@ -115,6 +126,13 @@ class CONTENT_EXPORT LevelDBDatabase
std::unique_ptr<leveldb::DB> db_;
std::unique_ptr<const leveldb::FilterPolicy> filter_policy_;
const LevelDBComparator* comparator_;
+
+ // Despite the type name, this object uses LRU eviction.
+ base::MRUCache<LevelDBIterator*, LevelDBIterator*> iterator_lru_;
+ // Recorded for UMA reporting.
+ uint32_t num_iterators_ = 0;
+ uint32_t max_iterators_ = 0;
+
std::string file_name_for_tracing;
};

Powered by Google App Engine
This is Rietveld 408576698