Index: content/browser/indexed_db/leveldb/leveldb_database.cc |
diff --git a/content/browser/indexed_db/leveldb/leveldb_database.cc b/content/browser/indexed_db/leveldb/leveldb_database.cc |
index 218a71b01901612a35e2bbb841fb9bbf838242db..d654c32d385c950e5f028930bc7b535e605d5e37 100644 |
--- a/content/browser/indexed_db/leveldb/leveldb_database.cc |
+++ b/content/browser/indexed_db/leveldb/leveldb_database.cc |
@@ -25,6 +25,7 @@ |
#include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
#include "third_party/leveldatabase/src/include/leveldb/db.h" |
#include "third_party/leveldatabase/src/include/leveldb/env.h" |
+#include "third_party/leveldatabase/src/include/leveldb/filter_policy.h" |
#include "third_party/leveldatabase/src/include/leveldb/slice.h" |
using base::StringPiece; |
@@ -93,11 +94,13 @@ LevelDBDatabase::~LevelDBDatabase() { |
static leveldb::Status OpenDB(leveldb::Comparator* comparator, |
leveldb::Env* env, |
const base::FilePath& path, |
- leveldb::DB** db) { |
+ leveldb::DB** db, |
+ const leveldb::FilterPolicy** filter_policy) { |
jsbell
2014/09/12 00:14:44
How about passing a scoped_ptr<leveldb::FilterPoli
|
leveldb::Options options; |
options.comparator = comparator; |
options.create_if_missing = true; |
options.paranoid_checks = true; |
+ options.filter_policy = leveldb::NewBloomFilterPolicy(10); |
options.compression = leveldb::kSnappyCompression; |
// For info about the troubles we've run into with this parameter, see: |
@@ -106,7 +109,14 @@ static leveldb::Status OpenDB(leveldb::Comparator* comparator, |
options.env = env; |
// ChromiumEnv assumes UTF8, converts back to FilePath before using. |
- return leveldb::DB::Open(options, path.AsUTF8Unsafe(), db); |
+ leveldb::Status s = leveldb::DB::Open(options, path.AsUTF8Unsafe(), db); |
+ |
+ if (s.ok()) |
+ *filter_policy = options.filter_policy; |
+ else |
+ delete options.filter_policy; |
+ |
+ return s; |
} |
leveldb::Status LevelDBDatabase::Destroy(const base::FilePath& file_name) { |
@@ -270,8 +280,12 @@ leveldb::Status LevelDBDatabase::Open(const base::FilePath& file_name, |
new ComparatorAdapter(comparator)); |
leveldb::DB* db; |
- const leveldb::Status s = |
- OpenDB(comparator_adapter.get(), leveldb::IDBEnv(), file_name, &db); |
+ const leveldb::FilterPolicy* filter_policy; |
+ const leveldb::Status s = OpenDB(comparator_adapter.get(), |
+ leveldb::IDBEnv(), |
+ file_name, |
+ &db, |
+ &filter_policy); |
if (!s.ok()) { |
HistogramLevelDBError("WebCore.IndexedDB.LevelDBOpenErrors", s); |
@@ -295,6 +309,7 @@ leveldb::Status LevelDBDatabase::Open(const base::FilePath& file_name, |
(*result)->db_ = make_scoped_ptr(db); |
(*result)->comparator_adapter_ = comparator_adapter.Pass(); |
(*result)->comparator_ = comparator; |
+ (*result)->filter_policy_ = make_scoped_ptr(filter_policy); |
return s; |
} |
@@ -306,8 +321,12 @@ scoped_ptr<LevelDBDatabase> LevelDBDatabase::OpenInMemory( |
scoped_ptr<leveldb::Env> in_memory_env(leveldb::NewMemEnv(leveldb::IDBEnv())); |
leveldb::DB* db; |
- const leveldb::Status s = OpenDB( |
- comparator_adapter.get(), in_memory_env.get(), base::FilePath(), &db); |
+ const leveldb::FilterPolicy* filter_policy; |
+ const leveldb::Status s = OpenDB(comparator_adapter.get(), |
+ in_memory_env.get(), |
+ base::FilePath(), |
+ &db, |
+ &filter_policy); |
if (!s.ok()) { |
LOG(ERROR) << "Failed to open in-memory LevelDB database: " << s.ToString(); |
@@ -319,6 +338,7 @@ scoped_ptr<LevelDBDatabase> LevelDBDatabase::OpenInMemory( |
result->db_ = make_scoped_ptr(db); |
result->comparator_adapter_ = comparator_adapter.Pass(); |
result->comparator_ = comparator; |
+ result->filter_policy_ = make_scoped_ptr(filter_policy); |
return result.Pass(); |
} |