import changes from `dev' branch of rmottola/Arctic-Fox:

- Backed out changeset b7653e3d5f91 (bug 1174381) for widespread assertion failures. (f529b680d)
- Bug 1174381 - ServiceWorkerManager::TeardownRunnable should be called when xpcom-shutdown notification is received, r=nsm (c744d9a80)
- Bug 1134671 Keep sqlite connection open between Cache API operations. r=ehsan (43a57decc)
- Bug 1134671: Add 'override' keyword to method Context::Data::GetConnection() (in DOM Cache code). rs=ehsan (669c6eac3)
- Bug 1164100 P1 Cache API should use correct base dir even when reusing sqlite connection. r=ehsan (c1bdf85d3)
- Bug 1164100 P2 Fix defunct assertion in Cache API ActionRunnable. r=ehsan (e345b2a76)
- Bug 1161288 - Support app:// origins on Fetch API. r=baku,nsm (9c237bcdd)
- Bug 1168135 P1 Execute Cache init Action on same target thread used for other Actions. r=ehsan (30fcee443)
- Bug 1168135 P2 Add Cache Context::Init() method. r=ehsan (41dfd427a)
- Bug 1168135 P3 Cache Context should pass shared Data container to init Action. r=ehsan (2e8f19d7c)
- Bug 1169994 Fix Cache to close connection on right thread when init is canceled. r=ehsan (ca7b96b24)
- Bug 1174768 Cache should check if QuotaManager is shutting down before calling GetOrCreate. r=janv (7b06ad874)
- Bug 1110446 P1 Create marker files when Cache API context is open. r=ehsan (bb94b92ff)
- Bug 1146612 - Add a test to ensure that Cache.put() with an existing request will reorder it in the DB; r=bkelly (228ff808c)
- Bug 1162365 - Cache API does not calculate usage in QuotaClient::InitOrigin(). r=bkelly (3fa71ee24)
- Bug 1156033 - Add some missing error handling to the DOM Cache code; r=bkelly (67cd67987)
- Bug 1118298 - Client uses unknown command property session_id. r=ato (081eb8f2d)
This commit is contained in:
2021-02-20 12:01:33 +08:00
parent 3b1d2cdd8a
commit bb3b80359f
34 changed files with 959 additions and 135 deletions
+49 -20
View File
@@ -93,7 +93,7 @@ public:
}
virtual void
RunOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo) override
RunOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo, Data*) override
{
MOZ_ASSERT(aResolver);
MOZ_ASSERT(aQuotaInfo.mDir);
@@ -1303,12 +1303,13 @@ public:
// no outstanding references, delete immediately
nsRefPtr<Context> context = mManager->mContext;
// TODO: note that we need to check this cache for staleness on startup (bug 1110446)
if (!context->IsCanceled()) {
if (context->IsCanceled()) {
context->NoteOrphanedData();
} else {
context->CancelForCacheId(mCacheId);
nsRefPtr<Action> action =
new DeleteOrphanedCacheAction(mManager, mCacheId);
context->Dispatch(mManager->mIOThread, action);
context->Dispatch(action);
}
}
}
@@ -1457,9 +1458,26 @@ Manager::RemoveContext(Context* aContext)
// Whether the Context destruction was triggered from the Manager going
// idle or the underlying storage being invalidated, we should know we
// are closing before the Conext is destroyed.
// are closing before the Context is destroyed.
MOZ_ASSERT(mState == Closing);
// Before forgetting the Context, check to see if we have any outstanding
// cache or body objects waiting for deletion. If so, note that we've
// orphaned data so it will be cleaned up on the next open.
for (uint32_t i = 0; i < mCacheIdRefs.Length(); ++i) {
if (mCacheIdRefs[i].mOrphaned) {
aContext->NoteOrphanedData();
break;
}
}
for (uint32_t i = 0; i < mBodyIdRefs.Length(); ++i) {
if (mBodyIdRefs[i].mOrphaned) {
aContext->NoteOrphanedData();
break;
}
}
mContext = nullptr;
// Once the context is gone, we can immediately remove ourself from the
@@ -1511,13 +1529,18 @@ Manager::ReleaseCacheId(CacheId aCacheId)
if (mCacheIdRefs[i].mCount == 0) {
bool orphaned = mCacheIdRefs[i].mOrphaned;
mCacheIdRefs.RemoveElementAt(i);
// TODO: note that we need to check this cache for staleness on startup (bug 1110446)
nsRefPtr<Context> context = mContext;
if (orphaned && context && !context->IsCanceled()) {
context->CancelForCacheId(aCacheId);
nsRefPtr<Action> action = new DeleteOrphanedCacheAction(this,
aCacheId);
context->Dispatch(mIOThread, action);
// If the context is already gone, then orphan flag should have been
// set in RemoveContext().
if (orphaned && context) {
if (context->IsCanceled()) {
context->NoteOrphanedData();
} else {
context->CancelForCacheId(aCacheId);
nsRefPtr<Action> action = new DeleteOrphanedCacheAction(this,
aCacheId);
context->Dispatch(action);
}
}
}
MaybeAllowContextToClose();
@@ -1555,11 +1578,16 @@ Manager::ReleaseBodyId(const nsID& aBodyId)
if (mBodyIdRefs[i].mCount < 1) {
bool orphaned = mBodyIdRefs[i].mOrphaned;
mBodyIdRefs.RemoveElementAt(i);
// TODO: note that we need to check this body for staleness on startup (bug 1110446)
nsRefPtr<Context> context = mContext;
if (orphaned && context && !context->IsCanceled()) {
nsRefPtr<Action> action = new DeleteOrphanedBodyAction(aBodyId);
context->Dispatch(mIOThread, action);
// If the context is already gone, then orphan flag should have been
// set in RemoveContext().
if (orphaned && context) {
if (context->IsCanceled()) {
context->NoteOrphanedData();
} else {
nsRefPtr<Action> action = new DeleteOrphanedBodyAction(aBodyId);
context->Dispatch(action);
}
}
}
MaybeAllowContextToClose();
@@ -1635,7 +1663,7 @@ Manager::ExecuteCacheOp(Listener* aListener, CacheId aCacheId,
MOZ_CRASH("Unknown Cache operation!");
}
context->Dispatch(mIOThread, action);
context->Dispatch(action);
}
void
@@ -1682,7 +1710,7 @@ Manager::ExecuteStorageOp(Listener* aListener, Namespace aNamespace,
MOZ_CRASH("Unknown CacheStorage operation!");
}
context->Dispatch(mIOThread, action);
context->Dispatch(action);
}
void
@@ -1708,7 +1736,7 @@ Manager::ExecutePutAll(Listener* aListener, CacheId aCacheId,
aPutList, aRequestStreamList,
aResponseStreamList);
context->Dispatch(mIOThread, action);
context->Dispatch(action);
}
Manager::Manager(ManagerId* aManagerId, nsIThread* aIOThread)
@@ -1752,7 +1780,8 @@ Manager::Init(Manager* aOldManager)
// per Manager now, this lets us cleanly call Factory::Remove() once the
// Context goes away.
nsRefPtr<Action> setupAction = new SetupAction();
nsRefPtr<Context> ref = Context::Create(this, setupAction, oldContext);
nsRefPtr<Context> ref = Context::Create(this, mIOThread, setupAction,
oldContext);
mContext = ref;
}
@@ -1870,7 +1899,7 @@ Manager::NoteOrphanedBodyIdList(const nsTArray<nsID>& aDeletedBodyIdList)
nsRefPtr<Context> context = mContext;
if (!deleteNowList.IsEmpty() && context && !context->IsCanceled()) {
nsRefPtr<Action> action = new DeleteOrphanedBodyAction(deleteNowList);
context->Dispatch(mIOThread, action);
context->Dispatch(action);
}
}