зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1626570 - Improve handling of copying arrays in dom/cache/. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D73643
This commit is contained in:
Родитель
dbf542e979
Коммит
daf66e3fc8
|
@ -167,12 +167,13 @@ class SetupAction final : public SyncDBAction {
|
||||||
// a body file that has been orphaned.
|
// a body file that has been orphaned.
|
||||||
class DeleteOrphanedBodyAction final : public Action {
|
class DeleteOrphanedBodyAction final : public Action {
|
||||||
public:
|
public:
|
||||||
explicit DeleteOrphanedBodyAction(const nsTArray<nsID>& aDeletedBodyIdList)
|
using DeletedBodyIdList = AutoTArray<nsID, 64>;
|
||||||
: mDeletedBodyIdList(aDeletedBodyIdList) {}
|
|
||||||
|
|
||||||
explicit DeleteOrphanedBodyAction(const nsID& aBodyId) {
|
explicit DeleteOrphanedBodyAction(DeletedBodyIdList&& aDeletedBodyIdList)
|
||||||
mDeletedBodyIdList.AppendElement(aBodyId);
|
: mDeletedBodyIdList(std::move(aDeletedBodyIdList)) {}
|
||||||
}
|
|
||||||
|
explicit DeleteOrphanedBodyAction(const nsID& aBodyId)
|
||||||
|
: mDeletedBodyIdList{aBodyId} {}
|
||||||
|
|
||||||
void RunOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo,
|
void RunOnTarget(Resolver* aResolver, const QuotaInfo& aQuotaInfo,
|
||||||
Data*) override {
|
Data*) override {
|
||||||
|
@ -202,7 +203,7 @@ class DeleteOrphanedBodyAction final : public Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsTArray<nsID> mDeletedBodyIdList;
|
DeletedBodyIdList mDeletedBodyIdList;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IsHeadRequest(const CacheRequest& aRequest,
|
bool IsHeadRequest(const CacheRequest& aRequest,
|
||||||
|
@ -2028,7 +2029,10 @@ bool Manager::SetBodyIdOrphanedIfRefed(const nsID& aBodyId) {
|
||||||
void Manager::NoteOrphanedBodyIdList(const nsTArray<nsID>& aDeletedBodyIdList) {
|
void Manager::NoteOrphanedBodyIdList(const nsTArray<nsID>& aDeletedBodyIdList) {
|
||||||
NS_ASSERT_OWNINGTHREAD(Manager);
|
NS_ASSERT_OWNINGTHREAD(Manager);
|
||||||
|
|
||||||
AutoTArray<nsID, 64> deleteNowList;
|
// XXX TransformIfIntoNewArray might be generalized to allow specifying the
|
||||||
|
// type of nsTArray to create, so that it can create an AutoTArray as well; an
|
||||||
|
// TransformIf (without AbortOnErr) might be added, which could be used here.
|
||||||
|
DeleteOrphanedBodyAction::DeletedBodyIdList deleteNowList;
|
||||||
deleteNowList.SetCapacity(aDeletedBodyIdList.Length());
|
deleteNowList.SetCapacity(aDeletedBodyIdList.Length());
|
||||||
|
|
||||||
for (uint32_t i = 0; i < aDeletedBodyIdList.Length(); ++i) {
|
for (uint32_t i = 0; i < aDeletedBodyIdList.Length(); ++i) {
|
||||||
|
@ -2041,7 +2045,8 @@ void Manager::NoteOrphanedBodyIdList(const nsTArray<nsID>& aDeletedBodyIdList) {
|
||||||
// 1110446)
|
// 1110446)
|
||||||
RefPtr<Context> context = mContext;
|
RefPtr<Context> context = mContext;
|
||||||
if (!deleteNowList.IsEmpty() && context && !context->IsCanceled()) {
|
if (!deleteNowList.IsEmpty() && context && !context->IsCanceled()) {
|
||||||
RefPtr<Action> action = new DeleteOrphanedBodyAction(deleteNowList);
|
RefPtr<Action> action =
|
||||||
|
new DeleteOrphanedBodyAction(std::move(deleteNowList));
|
||||||
context->Dispatch(action);
|
context->Dispatch(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ void StreamControl::CloseAllReadStreams() {
|
||||||
// transitively)
|
// transitively)
|
||||||
// 2. the this pointer is deleted by CacheStreamControlParent::Shutdown
|
// 2. the this pointer is deleted by CacheStreamControlParent::Shutdown
|
||||||
// (called transitively)
|
// (called transitively)
|
||||||
auto readStreamList = mReadStreamList;
|
auto readStreamList = mReadStreamList.Clone();
|
||||||
ReadStreamList::ForwardIterator iter(readStreamList);
|
ReadStreamList::ForwardIterator iter(readStreamList);
|
||||||
while (iter.HasMore()) {
|
while (iter.HasMore()) {
|
||||||
iter.GetNext()->CloseStream();
|
iter.GetNext()->CloseStream();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче