зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1619592 - Replace EnsureStorageAndOriginIsInitialized with EnsureTemporaryOriginIsInitialized in dom/cache; r=dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D97258
This commit is contained in:
Родитель
fc8f82ce8a
Коммит
f9fdb2de2a
|
@ -391,25 +391,36 @@ Context::QuotaInitRunnable::Run() {
|
|||
case STATE_ENSURE_ORIGIN_INITIALIZED: {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
if (mCanceled) {
|
||||
resolver->Resolve(NS_ERROR_ABORT);
|
||||
break;
|
||||
auto res = [this]() -> Result<Ok, nsresult> {
|
||||
if (mCanceled) {
|
||||
return Err(NS_ERROR_ABORT);
|
||||
}
|
||||
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_DIAGNOSTIC_ASSERT(quotaManager);
|
||||
|
||||
CACHE_TRY(quotaManager->EnsureStorageIsInitialized());
|
||||
|
||||
CACHE_TRY(quotaManager->EnsureTemporaryStorageIsInitialized());
|
||||
|
||||
CACHE_TRY_UNWRAP(mQuotaInfo.mDir,
|
||||
quotaManager
|
||||
->EnsureTemporaryOriginIsInitialized(
|
||||
PERSISTENCE_TYPE_DEFAULT, mQuotaInfo)
|
||||
.map([](const auto& res) { return res.first; }));
|
||||
|
||||
mState = STATE_RUN_ON_TARGET;
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL));
|
||||
|
||||
return Ok{};
|
||||
}();
|
||||
|
||||
if (res.isErr()) {
|
||||
resolver->Resolve(res.inspectErr());
|
||||
}
|
||||
|
||||
QuotaManager* qm = QuotaManager::Get();
|
||||
MOZ_DIAGNOSTIC_ASSERT(qm);
|
||||
|
||||
auto directoryOrErr = qm->EnsureStorageAndOriginIsInitialized(
|
||||
PERSISTENCE_TYPE_DEFAULT, mQuotaInfo);
|
||||
if (directoryOrErr.isErr()) {
|
||||
resolver->Resolve(directoryOrErr.inspectErr());
|
||||
break;
|
||||
}
|
||||
mQuotaInfo.mDir = directoryOrErr.unwrap();
|
||||
|
||||
mState = STATE_RUN_ON_TARGET;
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(mTarget->Dispatch(this, nsIThread::DISPATCH_NORMAL));
|
||||
break;
|
||||
}
|
||||
// -------------------
|
||||
|
|
|
@ -75,10 +75,16 @@ function resetTesting() {
|
|||
Services.prefs.clearUserPref("dom.quotaManager.testing");
|
||||
}
|
||||
|
||||
function reset() {
|
||||
let request = Services.qms.reset();
|
||||
function initStorage() {
|
||||
return Services.qms.init();
|
||||
}
|
||||
|
||||
return request;
|
||||
function initTemporaryStorage() {
|
||||
return Services.qms.initTemporaryStorage();
|
||||
}
|
||||
|
||||
function initTemporaryOrigin(principal) {
|
||||
return Services.qms.initializeTemporaryOrigin("default", principal);
|
||||
}
|
||||
|
||||
function clearOrigin(principal) {
|
||||
|
@ -87,14 +93,8 @@ function clearOrigin(principal) {
|
|||
return request;
|
||||
}
|
||||
|
||||
function initStorageAndOrigin(principal) {
|
||||
let request = Services.qms.initStorageAndOrigin(
|
||||
principal,
|
||||
"default",
|
||||
"cache"
|
||||
);
|
||||
|
||||
return request;
|
||||
function reset() {
|
||||
return Services.qms.reset();
|
||||
}
|
||||
|
||||
async function requestFinished(request) {
|
||||
|
|
|
@ -116,7 +116,13 @@ async function testSteps() {
|
|||
removeFile(cachesDatabase);
|
||||
}
|
||||
|
||||
let request = initStorageAndOrigin(principal);
|
||||
let request = initStorage();
|
||||
await requestFinished(request);
|
||||
|
||||
request = initTemporaryStorage();
|
||||
await requestFinished(request);
|
||||
|
||||
request = initTemporaryOrigin(principal);
|
||||
await requestFinished(request);
|
||||
|
||||
// After the origin is initialized, ".padding-tmp" should have always been
|
||||
|
|
Загрузка…
Ссылка в новой задаче