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

Unified Diff: content/browser/leveldb_wrapper_impl.h

Issue 1837883003: Some fleshing out the mojo based localstorage implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.cc ('k') | content/browser/leveldb_wrapper_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/leveldb_wrapper_impl.h
diff --git a/content/browser/leveldb_wrapper_impl.h b/content/browser/leveldb_wrapper_impl.h
index 9c4434baffbd6c593ce85fff16152723a67de13b..c96edf9ca6bca9c191351e910cd854d214200007 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,19 +18,21 @@ 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 mojom::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;
void Bind(mojom::LevelDBWrapperRequest request);
+ void AddObserver(mojom::LevelDBObserverPtr observer);
private:
// LevelDBWrapperImpl:
@@ -40,19 +43,22 @@ class LevelDBWrapperImpl : public mojom::LevelDBWrapper {
void Delete(mojo::Array<uint8_t> key,
const mojo::String& source,
const DeleteCallback& callback) override;
- void DeleteAll(mojom::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(mojom::LevelDBObserverPtr observer,
+ void GetAll(const mojo::String& source,
const GetAllCallback& callback) override;
void OnConnectionError();
std::string prefix_;
mojo::BindingSet<mojom::LevelDBWrapper> bindings_;
+ mojo::InterfacePtrSet<mojom::LevelDBObserver> observers_;
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_;
DISALLOW_COPY_AND_ASSIGN(LevelDBWrapperImpl);
};
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.cc ('k') | content/browser/leveldb_wrapper_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698