Bug 708901 - Migrate to nsTHashSet in docshell. r=smaug,geckoview-reviewers,aklotz
Differential Revision: https://phabricator.services.mozilla.com/D108591
This commit is contained in:
@@ -49,7 +49,7 @@ bool BaseHistory::CanStore(nsIURI* aURI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseHistory::ScheduleVisitedQuery(nsIURI* aURI) {
|
void BaseHistory::ScheduleVisitedQuery(nsIURI* aURI) {
|
||||||
mPendingQueries.PutEntry(aURI);
|
mPendingQueries.Insert(aURI);
|
||||||
if (mStartPendingVisitedQueriesScheduled) {
|
if (mStartPendingVisitedQueriesScheduled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ void BaseHistory::ScheduleVisitedQuery(nsIURI* aURI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseHistory::CancelVisitedQueryIfPossible(nsIURI* aURI) {
|
void BaseHistory::CancelVisitedQueryIfPossible(nsIURI* aURI) {
|
||||||
mPendingQueries.RemoveEntry(aURI);
|
mPendingQueries.Remove(aURI);
|
||||||
// TODO(bug 1591393): It could be worth to make this virtual and allow places
|
// TODO(bug 1591393): It could be worth to make this virtual and allow places
|
||||||
// to stop the existing database query? Needs some measurement.
|
// to stop the existing database query? Needs some measurement.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "IHistory.h"
|
#include "IHistory.h"
|
||||||
#include "mozilla/dom/ContentParent.h"
|
#include "mozilla/dom/ContentParent.h"
|
||||||
|
#include "nsTHashSet.h"
|
||||||
|
|
||||||
/* A base class for history implementations that implement link coloring. */
|
/* A base class for history implementations that implement link coloring. */
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ class BaseHistory : public IHistory {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using PendingVisitedQueries = nsTHashtable<nsURIHashKey>;
|
using PendingVisitedQueries = nsTHashSet<nsURIHashKey>;
|
||||||
using PendingVisitedResults = nsTArray<mozilla::dom::VisitedQueryResult>;
|
using PendingVisitedResults = nsTArray<mozilla::dom::VisitedQueryResult>;
|
||||||
|
|
||||||
// Starts all the queries in the pending queries list, potentially at the same
|
// Starts all the queries in the pending queries list, potentially at the same
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ BrowsingContextGroup::BrowsingContextGroup(uint64_t aId) : mId(aId) {
|
|||||||
void BrowsingContextGroup::Register(nsISupports* aContext) {
|
void BrowsingContextGroup::Register(nsISupports* aContext) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
|
MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
|
||||||
MOZ_DIAGNOSTIC_ASSERT(aContext);
|
MOZ_DIAGNOSTIC_ASSERT(aContext);
|
||||||
mContexts.PutEntry(aContext);
|
mContexts.Insert(aContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowsingContextGroup::Unregister(nsISupports* aContext) {
|
void BrowsingContextGroup::Unregister(nsISupports* aContext) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
|
MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
|
||||||
MOZ_DIAGNOSTIC_ASSERT(aContext);
|
MOZ_DIAGNOSTIC_ASSERT(aContext);
|
||||||
mContexts.RemoveEntry(aContext);
|
mContexts.Remove(aContext);
|
||||||
|
|
||||||
MaybeDestroy();
|
MaybeDestroy();
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ void BrowsingContextGroup::Subscribe(ContentParent* aProcess) {
|
|||||||
void BrowsingContextGroup::Unsubscribe(ContentParent* aProcess) {
|
void BrowsingContextGroup::Unsubscribe(ContentParent* aProcess) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(aProcess);
|
MOZ_DIAGNOSTIC_ASSERT(aProcess);
|
||||||
MOZ_DIAGNOSTIC_ASSERT(aProcess->GetRemoteType() != PREALLOC_REMOTE_TYPE);
|
MOZ_DIAGNOSTIC_ASSERT(aProcess->GetRemoteType() != PREALLOC_REMOTE_TYPE);
|
||||||
mSubscribers.RemoveEntry(aProcess);
|
mSubscribers.Remove(aProcess);
|
||||||
aProcess->RemoveBrowsingContextGroup(this);
|
aProcess->RemoveBrowsingContextGroup(this);
|
||||||
|
|
||||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||||
@@ -237,8 +237,8 @@ void BrowsingContextGroup::Destroy() {
|
|||||||
for (auto& entry : mHosts.Values()) {
|
for (auto& entry : mHosts.Values()) {
|
||||||
entry->RemoveBrowsingContextGroup(this);
|
entry->RemoveBrowsingContextGroup(this);
|
||||||
}
|
}
|
||||||
for (auto& entry : mSubscribers) {
|
for (const auto& key : mSubscribers) {
|
||||||
entry.GetKey()->RemoveBrowsingContextGroup(this);
|
key->RemoveBrowsingContextGroup(this);
|
||||||
}
|
}
|
||||||
mHosts.Clear();
|
mHosts.Clear();
|
||||||
mSubscribers.Clear();
|
mSubscribers.Clear();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "nsRefPtrHashtable.h"
|
#include "nsRefPtrHashtable.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsTHashtable.h"
|
#include "nsTHashSet.h"
|
||||||
#include "nsWrapperCache.h"
|
#include "nsWrapperCache.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
|
|
||||||
@@ -105,9 +105,9 @@ class BrowsingContextGroup final : public nsWrapperCache {
|
|||||||
template <typename Func>
|
template <typename Func>
|
||||||
void EachOtherParent(ContentParent* aExcludedParent, Func&& aCallback) {
|
void EachOtherParent(ContentParent* aExcludedParent, Func&& aCallback) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
||||||
for (auto iter = mSubscribers.Iter(); !iter.Done(); iter.Next()) {
|
for (const auto& key : mSubscribers) {
|
||||||
if (iter.Get()->GetKey() != aExcludedParent) {
|
if (key != aExcludedParent) {
|
||||||
aCallback(iter.Get()->GetKey());
|
aCallback(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,8 +117,8 @@ class BrowsingContextGroup final : public nsWrapperCache {
|
|||||||
template <typename Func>
|
template <typename Func>
|
||||||
void EachParent(Func&& aCallback) {
|
void EachParent(Func&& aCallback) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
||||||
for (auto iter = mSubscribers.Iter(); !iter.Done(); iter.Next()) {
|
for (const auto& key : mSubscribers) {
|
||||||
aCallback(iter.Get()->GetKey());
|
aCallback(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ class BrowsingContextGroup final : public nsWrapperCache {
|
|||||||
// non-discarded contexts within discarded contexts alive. It should be
|
// non-discarded contexts within discarded contexts alive. It should be
|
||||||
// removed in the future.
|
// removed in the future.
|
||||||
// FIXME: Consider introducing a better common base than `nsISupports`?
|
// FIXME: Consider introducing a better common base than `nsISupports`?
|
||||||
nsTHashtable<nsRefPtrHashKey<nsISupports>> mContexts;
|
nsTHashSet<nsRefPtrHashKey<nsISupports>> mContexts;
|
||||||
|
|
||||||
// The set of toplevel browsing contexts in the current BrowsingContextGroup.
|
// The set of toplevel browsing contexts in the current BrowsingContextGroup.
|
||||||
nsTArray<RefPtr<BrowsingContext>> mToplevels;
|
nsTArray<RefPtr<BrowsingContext>> mToplevels;
|
||||||
@@ -206,7 +206,7 @@ class BrowsingContextGroup final : public nsWrapperCache {
|
|||||||
// process.
|
// process.
|
||||||
nsRefPtrHashtable<nsCStringHashKey, ContentParent> mHosts;
|
nsRefPtrHashtable<nsCStringHashKey, ContentParent> mHosts;
|
||||||
|
|
||||||
nsTHashtable<nsRefPtrHashKey<ContentParent>> mSubscribers;
|
nsTHashSet<nsRefPtrHashKey<ContentParent>> mSubscribers;
|
||||||
|
|
||||||
// A queue to store postMessage events during page load, the queue will be
|
// A queue to store postMessage events during page load, the queue will be
|
||||||
// flushed once the page is loaded
|
// flushed once the page is loaded
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "nsQueryObject.h"
|
#include "nsQueryObject.h"
|
||||||
#include "nsBrowserStatusFilter.h"
|
#include "nsBrowserStatusFilter.h"
|
||||||
#include "nsIBrowser.h"
|
#include "nsIBrowser.h"
|
||||||
|
#include "nsTHashSet.h"
|
||||||
|
|
||||||
using namespace mozilla::ipc;
|
using namespace mozilla::ipc;
|
||||||
|
|
||||||
@@ -931,7 +932,7 @@ void CanonicalBrowsingContext::NotifyMediaMutedChanged(bool aMuted,
|
|||||||
uint32_t CanonicalBrowsingContext::CountSiteOrigins(
|
uint32_t CanonicalBrowsingContext::CountSiteOrigins(
|
||||||
GlobalObject& aGlobal,
|
GlobalObject& aGlobal,
|
||||||
const Sequence<OwningNonNull<BrowsingContext>>& aRoots) {
|
const Sequence<OwningNonNull<BrowsingContext>>& aRoots) {
|
||||||
nsTHashtable<nsCStringHashKey> uniqueSiteOrigins;
|
nsTHashSet<nsCString> uniqueSiteOrigins;
|
||||||
|
|
||||||
for (const auto& root : aRoots) {
|
for (const auto& root : aRoots) {
|
||||||
root->PreOrderWalk([&](BrowsingContext* aContext) {
|
root->PreOrderWalk([&](BrowsingContext* aContext) {
|
||||||
@@ -945,7 +946,7 @@ uint32_t CanonicalBrowsingContext::CountSiteOrigins(
|
|||||||
if (isContentPrincipal) {
|
if (isContentPrincipal) {
|
||||||
nsCString siteOrigin;
|
nsCString siteOrigin;
|
||||||
documentPrincipal->GetSiteOrigin(siteOrigin);
|
documentPrincipal->GetSiteOrigin(siteOrigin);
|
||||||
uniqueSiteOrigins.PutEntry(siteOrigin);
|
uniqueSiteOrigins.Insert(siteOrigin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ void GeckoViewHistory::QueryVisitedStateInContentProcess(
|
|||||||
// nsTArray<URIParams>` instead, but, since we don't expect to have many tab
|
// nsTArray<URIParams>` instead, but, since we don't expect to have many tab
|
||||||
// children, we can avoid the cost of hashing.
|
// children, we can avoid the cost of hashing.
|
||||||
AutoTArray<NewURIEntry, 8> newEntries;
|
AutoTArray<NewURIEntry, 8> newEntries;
|
||||||
for (auto query = aQueries.ConstIter(); !query.Done(); query.Next()) {
|
for (nsIURI* uri : aQueries) {
|
||||||
nsIURI* uri = query.Get()->GetKey();
|
|
||||||
auto entry = mTrackedURIs.Lookup(uri);
|
auto entry = mTrackedURIs.Lookup(uri);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
continue;
|
continue;
|
||||||
@@ -143,8 +142,7 @@ void GeckoViewHistory::QueryVisitedStateInParentProcess(
|
|||||||
MOZ_ASSERT(XRE_IsParentProcess());
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
|
|
||||||
nsTArray<NewURIEntry> newEntries;
|
nsTArray<NewURIEntry> newEntries;
|
||||||
for (auto query = aQueries.ConstIter(); !query.Done(); query.Next()) {
|
for (nsIURI* uri : aQueries) {
|
||||||
nsIURI* uri = query.Get()->GetKey();
|
|
||||||
auto entry = mTrackedURIs.Lookup(uri);
|
auto entry = mTrackedURIs.Lookup(uri);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
continue; // Nobody cares about this uri anymore.
|
continue; // Nobody cares about this uri anymore.
|
||||||
|
|||||||
@@ -2095,18 +2095,15 @@ History::IsURIVisited(nsIURI* aURI, mozIVisitedStatusCallback* aCallback) {
|
|||||||
void History::StartPendingVisitedQueries(
|
void History::StartPendingVisitedQueries(
|
||||||
const PendingVisitedQueries& aQueries) {
|
const PendingVisitedQueries& aQueries) {
|
||||||
if (XRE_IsContentProcess()) {
|
if (XRE_IsContentProcess()) {
|
||||||
nsTArray<RefPtr<nsIURI>> uris(aQueries.Count());
|
const auto uris = ToTArray<nsTArray<RefPtr<nsIURI>>>(aQueries);
|
||||||
for (auto iter = aQueries.ConstIter(); !iter.Done(); iter.Next()) {
|
|
||||||
uris.AppendElement(iter.Get()->GetKey());
|
|
||||||
}
|
|
||||||
auto* cpc = mozilla::dom::ContentChild::GetSingleton();
|
auto* cpc = mozilla::dom::ContentChild::GetSingleton();
|
||||||
MOZ_ASSERT(cpc, "Content Protocol is NULL!");
|
MOZ_ASSERT(cpc, "Content Protocol is NULL!");
|
||||||
Unused << cpc->SendStartVisitedQueries(uris);
|
Unused << cpc->SendStartVisitedQueries(uris);
|
||||||
} else {
|
} else {
|
||||||
// TODO(bug 1594368): We could do a single query, as long as we can
|
// TODO(bug 1594368): We could do a single query, as long as we can
|
||||||
// then notify each URI individually.
|
// then notify each URI individually.
|
||||||
for (auto iter = aQueries.ConstIter(); !iter.Done(); iter.Next()) {
|
for (const auto& key : aQueries) {
|
||||||
nsresult queryStatus = VisitedQuery::Start(iter.Get()->GetKey());
|
nsresult queryStatus = VisitedQuery::Start(key);
|
||||||
Unused << NS_WARN_IF(NS_FAILED(queryStatus));
|
Unused << NS_WARN_IF(NS_FAILED(queryStatus));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user