Bug 1517089 - Part 5: Move storage service initialization to InitializeLocalStorage; r=asuth

This commit is contained in:
Jan Varga 2019-02-07 19:51:22 +01:00
parent 01b23e7ba8
commit 5302b36c41
2 changed files with 13 additions and 6 deletions

View File

@ -2944,6 +2944,14 @@ void InitializeLocalStorage() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!gLocalStorageInitialized);
if (!QuotaManager::IsRunningGTests()) {
// This service has to be started on the main thread currently.
nsCOMPtr<mozIStorageService> ss;
if (NS_WARN_IF(!(ss = do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID)))) {
NS_WARNING("Failed to get storage service!");
}
}
if (NS_FAILED(QuotaClient::Initialize())) {
NS_WARNING("Failed to initialize quota client!");
}
@ -5652,12 +5660,6 @@ nsresult PrepareDatastoreOp::Open() {
}
}
// This service has to be started on the main thread currently.
nsCOMPtr<mozIStorageService> ss;
if (NS_WARN_IF(!(ss = do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID)))) {
return NS_ERROR_FAILURE;
}
mState = State::Nesting;
mNestedState = NestedState::CheckExistingOperations;

View File

@ -104,6 +104,11 @@ class QuotaManager final : public BackgroundThreadObject {
return kRunningXPCShellTests;
}
static bool IsRunningGTests() {
static bool kRunningGTests = !!PR_GetEnv("MOZ_RUN_GTEST");
return kRunningGTests;
}
static const char kReplaceChars[];
static void GetOrCreate(nsIRunnable* aCallback,