Bug 1644265 - Reject new DataStorages if we are shutting down r=keeler

Differential Revision: https://phabricator.services.mozilla.com/D79760
This commit is contained in:
Doug Thayer 2020-06-16 18:29:35 +00:00
Родитель 76fccc6721
Коммит 2d9e62963a
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -7,6 +7,7 @@
#include "DataStorage.h"
#include "mozilla/Assertions.h"
#include "mozilla/AppShutdown.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/PContent.h"
#include "mozilla/dom/ContentParent.h"
@ -313,6 +314,14 @@ nsresult DataStorage::Init(const nsTArray<DataStorageItem>* aItems,
return NS_ERROR_NOT_SAME_THREAD;
}
if (AppShutdown::IsShuttingDown()) {
// Reject new DataStorage instances if the browser is shutting down. There
// is no guarantee that DataStorage writes will be able to be persisted if
// we init during shutdown, so we return an error here to hopefully make
// this more explicit and consistent.
return NS_ERROR_NOT_AVAILABLE;
}
MutexAutoLock lock(mMutex);
// Ignore attempts to initialize several times.