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

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

Issue 2847013002: Switch to mojo localstorage backend by default. (Closed)
Patch Set: minor cleanup Created 3 years, 7 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
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 1a18095a5c5e08ee83efddfdefa2667a023070a6..7d0607d6fd9c1ff8f6c5fbbdcfa831af66e8db03 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -104,8 +104,8 @@ DOMStorageContextWrapper::DOMStorageContextWrapper(
new DOMStorageWorkerPoolTaskRunner(std::move(primary_sequence),
std::move(commit_sequence)));
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kMojoLocalStorage)) {
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableMojoLocalStorage)) {
base::FilePath storage_dir;
if (!profile_path.empty())
storage_dir = local_partition_path.AppendASCII(kLocalStorageDirectory);
@@ -271,7 +271,7 @@ void DOMStorageContextWrapper::Shutdown() {
if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
}
-
+ context_ = nullptr;
michaeln 2017/05/26 19:12:44 this might turn up some crashes in odd cases where
Marijn Kruisselbrink 2017/05/26 23:43:02 attempting to post tasks to the TaskScheduler (as
michaeln 2017/05/27 01:59:03 calling contextwrapper methods after shutdown used
}
void DOMStorageContextWrapper::Flush() {
@@ -306,6 +306,13 @@ void DOMStorageContextWrapper::OpenLocalStorage(
std::move(request)));
}
+leveldb::mojom::LevelDBDatabaseAssociatedRequest
+DOMStorageContextWrapper::LocalStorageDatabaseRequestForTesting() {
+ if (!mojo_state_)
+ return nullptr;
+ return mojo_state_->DatabaseRequestForTesting();
+}
+
void DOMStorageContextWrapper::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
DOMStorageContextImpl::PurgeOption purge_option =
@@ -341,6 +348,9 @@ void DOMStorageContextWrapper::GotMojoLocalStorageUsage(
GetLocalStorageUsageCallback callback,
base::SingleThreadTaskRunner* reply_task_runner,
std::vector<LocalStorageUsageInfo> usage) {
+ // If we were shutdown in the meantime, just give up.
+ if (!context_)
michaeln 2017/05/26 19:12:44 we might need more early outs like this to protect
Marijn Kruisselbrink 2017/05/26 23:43:02 every other usage (other than the one in PurgeMemo
michaeln 2017/05/27 01:59:03 The dchecks were to document it's non-nullness and
Marijn Kruisselbrink 2017/05/30 20:53:55 I agree that the current CL is somewhat scare in t
+ return;
context_->task_runner()->PostShutdownBlockingTask(
FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE,
base::Bind(&GetLocalStorageUsageHelper, base::Passed(&usage),

Powered by Google App Engine
This is Rietveld 408576698