| Index: content/browser/leveldb_wrapper_impl.h
|
| diff --git a/content/browser/leveldb_wrapper_impl.h b/content/browser/leveldb_wrapper_impl.h
|
| index 0aa5fccc5d9a4198ba5dd16e60670354cf7064e7..5c05d440e57012771fdab825ff24e44c928b3222 100644
|
| --- a/content/browser/leveldb_wrapper_impl.h
|
| +++ b/content/browser/leveldb_wrapper_impl.h
|
| @@ -9,6 +9,7 @@
|
| #include "base/macros.h"
|
| #include "content/common/leveldb_wrapper.mojom.h"
|
| #include "mojo/public/cpp/bindings/binding_set.h"
|
| +#include "mojo/public/cpp/bindings/interface_ptr_set.h"
|
|
|
| namespace content {
|
|
|
| @@ -17,15 +18,16 @@ namespace content {
|
| // 1) Adds the given prefix, if any, to all keys. This allows the sharing of one
|
| // database across many, possibly untrusted, consumers and ensuring that they
|
| // can't access each other's values.
|
| -// 2) Informs an observer when the given prefix' values are modified by another
|
| -// process.
|
| -// 3) Throttles requests to avoid overwhelming the disk.
|
| +// 2) Enforces a max_size constraint.
|
| +// 3) Informs an observer when the given prefix' values are modified.
|
| +// 4) Throttles requests to avoid overwhelming the disk.
|
| class LevelDBWrapperImpl : public LevelDBWrapper {
|
| public:
|
| // |no_bindings_callback| will be called when this object has no more
|
| // bindings.
|
| LevelDBWrapperImpl(leveldb::LevelDBDatabase* database,
|
| const std::string& prefix,
|
| + size_t max_size,
|
| const base::Closure& no_bindings_callback);
|
| ~LevelDBWrapperImpl() override;
|
|
|
| @@ -33,6 +35,7 @@ class LevelDBWrapperImpl : public LevelDBWrapper {
|
|
|
| private:
|
| // LevelDBWrapperImpl:
|
| + void AddObserver(LevelDBObserverPtr observer) override;
|
| void Put(mojo::Array<uint8_t> key,
|
| mojo::Array<uint8_t> value,
|
| const mojo::String& source,
|
| @@ -40,11 +43,9 @@ class LevelDBWrapperImpl : public LevelDBWrapper {
|
| void Delete(mojo::Array<uint8_t> key,
|
| const mojo::String& source,
|
| const DeleteCallback& callback) override;
|
| - void DeleteAll(LevelDBObserverPtr observer,
|
| - const mojo::String& source,
|
| + void DeleteAll(const mojo::String& source,
|
| const DeleteAllCallback& callback) override;
|
| - void Get(mojo::Array<uint8_t> key, const GetCallback& callback) override;
|
| - void GetAll(LevelDBObserverPtr observer,
|
| + void GetAll(uint64_t request_id,
|
| const GetAllCallback& callback) override;
|
|
|
| void OnConnectionError();
|
| @@ -53,6 +54,10 @@ class LevelDBWrapperImpl : public LevelDBWrapper {
|
| mojo::BindingSet<LevelDBWrapper> bindings_;
|
| base::Closure no_bindings_callback_;
|
| leveldb::LevelDBDatabase* database_;
|
| + std::map<mojo::Array<uint8_t>, mojo::Array<uint8_t>> map_;
|
| + size_t bytes_used_;
|
| + size_t max_size_;
|
| + mojo::InterfacePtrSet<LevelDBObserver> observers_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(LevelDBWrapperImpl);
|
| };
|
|
|