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

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: how did i miss that... 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..eea4dc5b4bed40b1c362665d5b18d0944a215a46 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -128,26 +128,30 @@ class DOMStorageContextWrapper::MojoState {
void DOMStorageContextWrapper::MojoState::OpenLocalStorage(
const url::Origin& origin,
LevelDBWrapperRequest request) {
- // If we don't have a specific subdirectory where we want to put our data
- // (ie, we're in incognito mode), just bind the storage with a null leveldb_
- // database.
- if (subdirectory_.empty()) {
- BindLocalStorage(origin, std::move(request));
- return;
- }
-
// If we don't have a filesystem_connection_, we'll need to establish one.
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