mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 708901 - Migrate to nsTHashSet in ipc. r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D109322
This commit is contained in:
parent
c206bea1c1
commit
4a308827e3
@ -1501,12 +1501,12 @@ static bool VisitDocAccessibleParentDescendantsAtTopLevelInContentProcess(
|
||||
// We can't use BrowserBridgeParent::VisitAllDescendants because it doesn't
|
||||
// provide a way to stop the search.
|
||||
const auto& bridges = aBrowser->ManagedPBrowserBridgeParent();
|
||||
for (auto iter = bridges.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
auto bridge = static_cast<dom::BrowserBridgeParent*>(iter.Get()->GetKey());
|
||||
return std::all_of(bridges.cbegin(), bridges.cend(), [&](const auto& key) {
|
||||
auto* bridge = static_cast<dom::BrowserBridgeParent*>(key);
|
||||
dom::BrowserParent* childBrowser = bridge->GetBrowserParent();
|
||||
DocAccessibleParent* childDocAcc = childBrowser->GetTopLevelDocAccessible();
|
||||
if (!childDocAcc || childDocAcc->IsShutdown()) {
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
if (!aCallback(childDocAcc)) {
|
||||
return false; // Stop traversal.
|
||||
@ -1515,8 +1515,8 @@ static bool VisitDocAccessibleParentDescendantsAtTopLevelInContentProcess(
|
||||
childBrowser, aCallback)) {
|
||||
return false; // Stop traversal.
|
||||
}
|
||||
}
|
||||
return true; // Continue traversal.
|
||||
return true; // Continue traversal.
|
||||
});
|
||||
}
|
||||
|
||||
already_AddRefed<IAccessible> AccessibleWrap::GetRemoteIAccessibleFor(
|
||||
|
@ -963,14 +963,14 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
|
||||
|
||||
// Attach DOM window information to the process.
|
||||
nsTArray<WindowInfo> windows;
|
||||
for (const auto& browserParentWrapper :
|
||||
for (const auto& browserParentWrapperKey :
|
||||
contentParent->ManagedPBrowserParent()) {
|
||||
for (const auto& windowGlobalParentWrapper :
|
||||
browserParentWrapper.GetKey()->ManagedPWindowGlobalParent()) {
|
||||
for (const auto& windowGlobalParentWrapperKey :
|
||||
browserParentWrapperKey->ManagedPWindowGlobalParent()) {
|
||||
// WindowGlobalParent is the only immediate subclass of
|
||||
// PWindowGlobalParent.
|
||||
auto* windowGlobalParent = static_cast<WindowGlobalParent*>(
|
||||
windowGlobalParentWrapper.GetKey());
|
||||
auto* windowGlobalParent =
|
||||
static_cast<WindowGlobalParent*>(windowGlobalParentWrapperKey);
|
||||
|
||||
nsString documentTitle;
|
||||
windowGlobalParent->GetDocumentTitle(documentTitle);
|
||||
|
@ -1299,9 +1299,9 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader(
|
||||
nsGlobalWindowOuter::Cast(newWin)->GetMainWidget();
|
||||
const ManagedContainer<mozilla::plugins::PPluginWidgetParent>& plugins =
|
||||
otherBrowserParent->ManagedPPluginWidgetParent();
|
||||
for (auto iter = plugins.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
static_cast<mozilla::plugins::PluginWidgetParent*>(iter.Get()->GetKey())
|
||||
->SetParent(newParent);
|
||||
for (auto* key : plugins) {
|
||||
static_cast<mozilla::plugins::PluginWidgetParent*>(key)->SetParent(
|
||||
newParent);
|
||||
}
|
||||
}
|
||||
#endif // XP_WIN
|
||||
|
@ -429,8 +429,8 @@ a11y::DocAccessibleParent* BrowserParent::GetTopLevelDocAccessible() const {
|
||||
// document accessible.
|
||||
const ManagedContainer<PDocAccessibleParent>& docs =
|
||||
ManagedPDocAccessibleParent();
|
||||
for (auto iter = docs.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
auto doc = static_cast<a11y::DocAccessibleParent*>(iter.Get()->GetKey());
|
||||
for (auto* key : docs) {
|
||||
auto* doc = static_cast<a11y::DocAccessibleParent*>(key);
|
||||
// We want the document for this BrowserParent even if it's for an
|
||||
// embedded out-of-process iframe. Therefore, we use
|
||||
// IsTopLevelInContentProcess. In contrast, using IsToplevel would only
|
||||
@ -630,9 +630,8 @@ void BrowserParent::DestroyInternal() {
|
||||
// is shut down.
|
||||
const ManagedContainer<PPluginWidgetParent>& kids =
|
||||
ManagedPPluginWidgetParent();
|
||||
for (auto iter = kids.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
static_cast<mozilla::plugins::PluginWidgetParent*>(iter.Get()->GetKey())
|
||||
->ParentDestroy();
|
||||
for (const auto& key : kids) {
|
||||
static_cast<mozilla::plugins::PluginWidgetParent*>(key)->ParentDestroy();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -214,9 +214,9 @@ class BrowserParent final : public PBrowserParent,
|
||||
template <typename Callback>
|
||||
void VisitAllDescendants(Callback aCallback) {
|
||||
const auto& browserBridges = ManagedPBrowserBridgeParent();
|
||||
for (auto iter = browserBridges.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
for (const auto& key : browserBridges) {
|
||||
BrowserBridgeParent* browserBridge =
|
||||
static_cast<BrowserBridgeParent*>(iter.Get()->GetKey());
|
||||
static_cast<BrowserBridgeParent*>(key);
|
||||
BrowserParent* browserParent = browserBridge->GetBrowserParent();
|
||||
|
||||
aCallback(browserParent);
|
||||
@ -230,9 +230,9 @@ class BrowserParent final : public PBrowserParent,
|
||||
template <typename Callback>
|
||||
void VisitChildren(Callback aCallback) {
|
||||
const auto& browserBridges = ManagedPBrowserBridgeParent();
|
||||
for (auto iter = browserBridges.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
for (const auto& key : browserBridges) {
|
||||
BrowserBridgeParent* browserBridge =
|
||||
static_cast<BrowserBridgeParent*>(iter.Get()->GetKey());
|
||||
static_cast<BrowserBridgeParent*>(key);
|
||||
aCallback(browserBridge);
|
||||
}
|
||||
}
|
||||
|
@ -1819,7 +1819,7 @@ void ContentParent::ShutDownProcess(ShutDownMethod aMethod) {
|
||||
|
||||
const ManagedContainer<POfflineCacheUpdateParent>& ocuParents =
|
||||
ManagedPOfflineCacheUpdateParent();
|
||||
for (auto* key : ocuParents.Keys()) {
|
||||
for (auto* key : ocuParents) {
|
||||
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> ocuParent =
|
||||
static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(key);
|
||||
ocuParent->StopSendingMessagesToChild();
|
||||
|
@ -128,26 +128,26 @@ void JSActorService::UnregisterWindowActor(const nsACString& aName) {
|
||||
if (XRE_IsParentProcess()) {
|
||||
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
||||
Unused << cp->SendUnregisterJSWindowActor(name);
|
||||
for (auto& bp : cp->ManagedPBrowserParent()) {
|
||||
for (auto& wgp : bp.GetKey()->ManagedPWindowGlobalParent()) {
|
||||
managers.AppendElement(
|
||||
static_cast<WindowGlobalParent*>(wgp.GetKey()));
|
||||
for (const auto& bp : cp->ManagedPBrowserParent()) {
|
||||
for (const auto& wgp : bp->ManagedPWindowGlobalParent()) {
|
||||
managers.AppendElement(static_cast<WindowGlobalParent*>(wgp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& wgp :
|
||||
for (const auto& wgp :
|
||||
InProcessParent::Singleton()->ManagedPWindowGlobalParent()) {
|
||||
managers.AppendElement(static_cast<WindowGlobalParent*>(wgp.GetKey()));
|
||||
managers.AppendElement(static_cast<WindowGlobalParent*>(wgp));
|
||||
}
|
||||
for (auto& wgc :
|
||||
for (const auto& wgc :
|
||||
InProcessChild::Singleton()->ManagedPWindowGlobalChild()) {
|
||||
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc.GetKey()));
|
||||
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc));
|
||||
}
|
||||
} else {
|
||||
for (auto& bc : ContentChild::GetSingleton()->ManagedPBrowserChild()) {
|
||||
for (auto& wgc : bc.GetKey()->ManagedPWindowGlobalChild()) {
|
||||
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc.GetKey()));
|
||||
for (const auto& bc :
|
||||
ContentChild::GetSingleton()->ManagedPBrowserChild()) {
|
||||
for (const auto& wgc : bc->ManagedPWindowGlobalChild()) {
|
||||
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,19 +98,19 @@ void GMPContentChild::CloseActive() {
|
||||
// Invalidate and remove any remaining API objects.
|
||||
const ManagedContainer<PGMPVideoDecoderChild>& videoDecoders =
|
||||
ManagedPGMPVideoDecoderChild();
|
||||
for (auto iter = videoDecoders.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
iter.Get()->GetKey()->SendShutdown();
|
||||
for (const auto& key : videoDecoders) {
|
||||
key->SendShutdown();
|
||||
}
|
||||
|
||||
const ManagedContainer<PGMPVideoEncoderChild>& videoEncoders =
|
||||
ManagedPGMPVideoEncoderChild();
|
||||
for (auto iter = videoEncoders.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
iter.Get()->GetKey()->SendShutdown();
|
||||
for (const auto& key : videoEncoders) {
|
||||
key->SendShutdown();
|
||||
}
|
||||
|
||||
const ManagedContainer<PChromiumCDMChild>& cdms = ManagedPChromiumCDMChild();
|
||||
for (auto iter = cdms.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
iter.Get()->GetKey()->SendShutdown();
|
||||
for (const auto& key : cdms) {
|
||||
key->SendShutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,9 +207,8 @@ void CompositorBridgeChild::Destroy() {
|
||||
}
|
||||
|
||||
const ManagedContainer<PTextureChild>& textures = ManagedPTextureChild();
|
||||
for (auto iter = textures.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
RefPtr<TextureClient> texture =
|
||||
TextureClient::AsTextureClient(iter.Get()->GetKey());
|
||||
for (const auto& key : textures) {
|
||||
RefPtr<TextureClient> texture = TextureClient::AsTextureClient(key);
|
||||
|
||||
if (texture) {
|
||||
texture->Destroy();
|
||||
|
@ -233,14 +233,9 @@ void SentinelReadError(const char* aClassName) {
|
||||
MOZ_CRASH_UNSAFE_PRINTF("incorrect sentinel when reading %s", aClassName);
|
||||
}
|
||||
|
||||
void TableToArray(const nsTHashtable<nsPtrHashKey<void>>& aTable,
|
||||
nsTArray<void*>& aArray) {
|
||||
uint32_t i = 0;
|
||||
void** elements = aArray.AppendElements(aTable.Count());
|
||||
for (auto iter = aTable.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
elements[i] = iter.Get()->GetKey();
|
||||
++i;
|
||||
}
|
||||
void TableToArray(const nsTHashSet<void*>& aTable, nsTArray<void*>& aArray) {
|
||||
MOZ_ASSERT(aArray.IsEmpty());
|
||||
aArray = ToArray(aTable);
|
||||
}
|
||||
|
||||
ActorLifecycleProxy::ActorLifecycleProxy(IProtocol* aActor) : mActor(aActor) {
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "nsDebug.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsTHashSet.h"
|
||||
|
||||
// XXX Things that could be replaced by a forward header
|
||||
#include "mozilla/ipc/Transport.h" // for Transport
|
||||
@ -727,8 +727,7 @@ class WeakActorLifecycleProxy final {
|
||||
const nsCOMPtr<nsISerialEventTarget> mActorEventTarget;
|
||||
};
|
||||
|
||||
void TableToArray(const nsTHashtable<nsPtrHashKey<void>>& aTable,
|
||||
nsTArray<void*>& aArray);
|
||||
void TableToArray(const nsTHashSet<void*>& aTable, nsTArray<void*>& aArray);
|
||||
|
||||
class IPDLResolverInner final {
|
||||
public:
|
||||
@ -756,8 +755,8 @@ class IPDLResolverInner final {
|
||||
} // namespace ipc
|
||||
|
||||
template <typename Protocol>
|
||||
class ManagedContainer : public nsTHashtable<nsPtrHashKey<Protocol>> {
|
||||
typedef nsTHashtable<nsPtrHashKey<Protocol>> BaseClass;
|
||||
class ManagedContainer : public nsTHashSet<Protocol*> {
|
||||
typedef nsTHashSet<Protocol*> BaseClass;
|
||||
|
||||
public:
|
||||
// Having the core logic work on void pointers, rather than typed pointers,
|
||||
@ -768,10 +767,9 @@ class ManagedContainer : public nsTHashtable<nsPtrHashKey<Protocol>> {
|
||||
// functions.) We do have to pay for it with some eye-bleedingly bad casts,
|
||||
// though.
|
||||
void ToArray(nsTArray<Protocol*>& aArray) const {
|
||||
::mozilla::ipc::TableToArray(
|
||||
*reinterpret_cast<const nsTHashtable<nsPtrHashKey<void>>*>(
|
||||
static_cast<const BaseClass*>(this)),
|
||||
reinterpret_cast<nsTArray<void*>&>(aArray));
|
||||
::mozilla::ipc::TableToArray(*reinterpret_cast<const nsTHashSet<void*>*>(
|
||||
static_cast<const BaseClass*>(this)),
|
||||
reinterpret_cast<nsTArray<void*>&>(aArray));
|
||||
}
|
||||
};
|
||||
|
||||
@ -782,7 +780,7 @@ Protocol* LoneManagedOrNullAsserts(
|
||||
return nullptr;
|
||||
}
|
||||
MOZ_ASSERT(aManagees.Count() == 1);
|
||||
return aManagees.ConstIter().Get()->GetKey();
|
||||
return *aManagees.cbegin();
|
||||
}
|
||||
|
||||
template <typename Protocol>
|
||||
@ -790,7 +788,7 @@ Protocol* SingleManagedOrNull(const ManagedContainer<Protocol>& aManagees) {
|
||||
if (aManagees.Count() != 1) {
|
||||
return nullptr;
|
||||
}
|
||||
return aManagees.ConstIter().Get()->GetKey();
|
||||
return *aManagees.cbegin();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -3962,8 +3962,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
for managed in ptype.manages:
|
||||
managedmeth.addcode(
|
||||
"""
|
||||
for (auto it = ${container}.ConstIter(); !it.Done(); it.Next()) {
|
||||
arr__.AppendElement(it.Get()->GetKey()->GetLifecycleProxy());
|
||||
for (auto* key : ${container}) {
|
||||
arr__.AppendElement(key->GetLifecycleProxy());
|
||||
}
|
||||
|
||||
""",
|
||||
@ -4172,12 +4172,12 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
for managed in ptype.manages:
|
||||
clearsubtree.addcode(
|
||||
"""
|
||||
for (auto it = ${container}.Iter(); !it.Done(); it.Next()) {
|
||||
it.Get()->GetKey()->ClearSubtree();
|
||||
for (auto* key : ${container}) {
|
||||
key->ClearSubtree();
|
||||
}
|
||||
for (auto it = ${container}.Iter(); !it.Done(); it.Next()) {
|
||||
for (auto* key : ${container}) {
|
||||
// Recursively releasing ${container} kids.
|
||||
auto* proxy = it.Get()->GetKey()->GetLifecycleProxy();
|
||||
auto* proxy = key->GetLifecycleProxy();
|
||||
NS_IF_RELEASE(proxy);
|
||||
}
|
||||
${container}.Clear();
|
||||
@ -4657,7 +4657,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
}
|
||||
|
||||
${actor}->SetManagerAndRegister($,{setManagerArgs});
|
||||
${container}.PutEntry(${actor});
|
||||
${container}.Insert(${actor});
|
||||
""",
|
||||
actor=actordecl.var(),
|
||||
actorname=actorproto.name() + self.side.capitalize(),
|
||||
|
@ -135,9 +135,8 @@ struct PerfStatsCollector {
|
||||
aParent->ManagedPBrowserParent();
|
||||
|
||||
writer.StartArrayProperty("urls");
|
||||
for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
RefPtr<BrowserParent> parent =
|
||||
BrowserParent::GetFrom(iter.Get()->GetKey());
|
||||
for (const auto& key : browsers) {
|
||||
RefPtr<BrowserParent> parent = BrowserParent::GetFrom(key);
|
||||
|
||||
CanonicalBrowsingContext* ctx = parent->GetBrowsingContext();
|
||||
if (!ctx) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user