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

Unified Diff: content/browser/dom_storage/dom_storage_context_wrapper.cc

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.h ('k') | content/browser/leveldb_wrapper_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/dom_storage/dom_storage_context_wrapper.cc
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc
index 0490d2e0b1342d9b4dea18a86e2ad7765e9fc784..b0ec4d5ab6545f3e5e01940f5223e86ee6dfae03 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -84,10 +84,11 @@ class DOMStorageContextWrapper::MojoState {
weak_ptr_factory_(this) {}
void OpenLocalStorage(const url::Origin& origin,
+ mojom::LevelDBObserverPtr observer,
mojom::LevelDBWrapperRequest request);
private:
- void LevelDBWrapperImplHasNoBindings(const url::Origin& origin) {
+ void OnLevelDDWrapperHasNoBindings(const url::Origin& origin) {
DCHECK(level_db_wrappers_.find(origin) != level_db_wrappers_.end());
level_db_wrappers_.erase(origin);
}
@@ -99,6 +100,7 @@ class DOMStorageContextWrapper::MojoState {
// The (possibly delayed) implementation of OpenLocalStorage(). Can be called
// directly from that function, or through |on_database_open_callbacks_|.
void BindLocalStorage(const url::Origin& origin,
+ mojom::LevelDBObserverPtr observer,
mojom::LevelDBWrapperRequest request);
// Maps between an origin and its prefixed LevelDB view.
@@ -127,6 +129,7 @@ class DOMStorageContextWrapper::MojoState {
void DOMStorageContextWrapper::MojoState::OpenLocalStorage(
const url::Origin& origin,
+ mojom::LevelDBObserverPtr observer,
mojom::LevelDBWrapperRequest request) {
// If we don't have a filesystem_connection_, we'll need to establish one.
if (connection_state_ == NO_CONNECTION) {
@@ -158,11 +161,11 @@ void DOMStorageContextWrapper::MojoState::OpenLocalStorage(
// Queue this OpenLocalStorage call for when we have a level db pointer.
on_database_opened_callbacks_.push_back(
base::Bind(&MojoState::BindLocalStorage, weak_ptr_factory_.GetWeakPtr(),
- origin, base::Passed(&request)));
+ origin, base::Passed(&observer), base::Passed(&request)));
return;
}
- BindLocalStorage(origin, std::move(request));
+ BindLocalStorage(origin, std::move(observer), std::move(request));
}
void DOMStorageContextWrapper::MojoState::OnDirectoryOpened(
@@ -208,17 +211,22 @@ void DOMStorageContextWrapper::MojoState::OnDatabaseOpened(
void DOMStorageContextWrapper::MojoState::BindLocalStorage(
const url::Origin& origin,
+ mojom::LevelDBObserverPtr observer,
mojom::LevelDBWrapperRequest request) {
- if (level_db_wrappers_.find(origin) == level_db_wrappers_.end()) {
+ auto found = level_db_wrappers_.find(origin);
+ if (found == level_db_wrappers_.end()) {
level_db_wrappers_[origin] = make_scoped_ptr(new LevelDBWrapperImpl(
database_.get(),
origin.Serialize(),
- base::Bind(&MojoState::LevelDBWrapperImplHasNoBindings,
+ kPerStorageAreaQuota + kPerStorageAreaOverQuotaAllowance,
+ base::Bind(&MojoState::OnLevelDDWrapperHasNoBindings,
base::Unretained(this),
origin)));
+ found = level_db_wrappers_.find(origin);
}
- level_db_wrappers_[origin]->Bind(std::move(request));
+ found->second->Bind(std::move(request));
+ found->second->AddObserver(std::move(observer));
}
DOMStorageContextWrapper::DOMStorageContextWrapper(
@@ -336,8 +344,10 @@ void DOMStorageContextWrapper::Flush() {
void DOMStorageContextWrapper::OpenLocalStorage(
const url::Origin& origin,
+ mojom::LevelDBObserverPtr observer,
mojom::LevelDBWrapperRequest request) {
- mojo_state_->OpenLocalStorage(origin, std::move(request));
+ mojo_state_->OpenLocalStorage(
+ origin, std::move(observer), std::move(request));
}
} // namespace content
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.h ('k') | content/browser/leveldb_wrapper_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698