| Index: content/browser/dom_storage/local_storage_context_mojo.cc
|
| diff --git a/content/browser/dom_storage/local_storage_context_mojo.cc b/content/browser/dom_storage/local_storage_context_mojo.cc
|
| index 2be6213f8ce2f40c4be1d0821cb30765217a20f4..e32a02479cb1cacbcffc06a5165c84c027a93a80 100644
|
| --- a/content/browser/dom_storage/local_storage_context_mojo.cc
|
| +++ b/content/browser/dom_storage/local_storage_context_mojo.cc
|
| @@ -388,7 +388,14 @@ void LocalStorageContextMojo::RunWhenConnected(base::OnceClosure callback) {
|
|
|
| void LocalStorageContextMojo::InitiateConnection(bool in_memory_only) {
|
| DCHECK_EQ(connection_state_, CONNECTION_IN_PROGRESS);
|
| - CHECK(connector_);
|
| +
|
| + // Unit tests might not always have a Connector, use in-memory only if that
|
| + // happens.
|
| + if (!connector_) {
|
| + OnDatabaseOpened(false, leveldb::mojom::DatabaseError::OK);
|
| + return;
|
| + }
|
| +
|
| if (!subdirectory_.empty() && !in_memory_only) {
|
| // We were given a subdirectory to write to. Get it and use a disk backed
|
| // database.
|
| @@ -607,6 +614,13 @@ LevelDBWrapperImpl* LocalStorageContextMojo::GetOrCreateDBWrapper(
|
|
|
| void LocalStorageContextMojo::RetrieveStorageUsage(
|
| GetStorageUsageCallback callback) {
|
| + if (!database_) {
|
| + // If for whatever reason no leveldb database is available, no storage is
|
| + // used, so return an empty array.
|
| + std::move(callback).Run(std::vector<LocalStorageUsageInfo>());
|
| + return;
|
| + }
|
| +
|
| database_->GetPrefixed(
|
| std::vector<uint8_t>(kMetaPrefix, kMetaPrefix + arraysize(kMetaPrefix)),
|
| base::Bind(&LocalStorageContextMojo::OnGotMetaData,
|
|
|