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

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

Issue 1823813002: mojo leveldb: Add support to use in memory database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add memory read write unittest Created 4 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
« no previous file with comments | « components/leveldb/public/interfaces/leveldb.mojom ('k') | no next file » | 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 cfacb08805622497391c1d4feb058bef9c7e506c..d2343e0b9bf4497510356268a956bfe545f875f4 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -140,14 +140,26 @@ void DOMStorageContextWrapper::MojoState::OpenLocalStorage(
if (connection_state_ == NO_CONNECTION) {
profile_app_connection_ = MojoAppConnection::Create(
mojo_user_id_, "mojo:profile", kBrowserMojoAppUrl);
- profile_app_connection_->GetInterface(&profile_service_);
- profile_service_->GetSubDirectory(
- mojo::String::From(subdirectory_.AsUTF8Unsafe()),
- GetProxy(&directory_),
- base::Bind(&MojoState::OnDirectoryOpened,
- weak_ptr_factory_.GetWeakPtr()));
connection_state_ = CONNECTION_IN_PROGRESS;
+
+ if (!subdirectory_.empty()) {
+ // We were given a subdirectory to write to. Get it and use a disk backed
+ // database.
+ profile_app_connection_->GetInterface(&profile_service_);
+ profile_service_->GetSubDirectory(
+ mojo::String::From(subdirectory_.AsUTF8Unsafe()),
+ GetProxy(&directory_),
+ base::Bind(&MojoState::OnDirectoryOpened,
+ weak_ptr_factory_.GetWeakPtr()));
+ } else {
+ // We were not given a subdirectory. Use a memory backed database.
+ profile_app_connection_->GetInterface(&leveldb_service_);
+ leveldb_service_->OpenInMemory(
+ GetProxy(&database_),
+ base::Bind(&MojoState::OnDatabaseOpened,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
}
if (connection_state_ == CONNECTION_IN_PROGRESS) {
« no previous file with comments | « components/leveldb/public/interfaces/leveldb.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698