diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 57fb9c8c1447..4ffa58ca012d 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -936,13 +936,13 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, mRemoteBrowser->SetBrowserDOMWindow(otherBrowserDOMWindow); // Native plugin windows used by this remote content need to be reparented. - const nsTArray& plugins = - aOther->mRemoteBrowser->ManagedPPluginWidgetParent(); nsPIDOMWindow* newWin = ourDoc->GetWindow(); if (newWin) { nsRefPtr newParent = ((nsGlobalWindow*)newWin)->GetMainWidget(); - for (uint32_t idx = 0; idx < plugins.Length(); ++idx) { - static_cast(plugins[idx])->SetParent(newParent); + const ManagedContainer& plugins = + aOther->mRemoteBrowser->ManagedPPluginWidgetParent(); + for (auto iter = plugins.ConstIter(); !iter.Done(); iter.Next()) { + static_cast(iter.Get()->GetKey())->SetParent(newParent); } } diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 39a22f6c716d..478048aeb10c 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -19888,7 +19888,7 @@ FactoryOp::CheckAtLeastOneAppHasPermission(ContentParent* aContentParent, MOZ_ASSERT(!aPermissionString.IsEmpty()); #ifdef MOZ_CHILD_PERMISSIONS - const nsTArray& browsers = + const ManagedContainer& browsers = aContentParent->ManagedPBrowserParent(); if (!browsers.IsEmpty()) { @@ -19912,11 +19912,9 @@ FactoryOp::CheckAtLeastOneAppHasPermission(ContentParent* aContentParent, const nsPromiseFlatCString permissionString = PromiseFlatCString(aPermissionString); - for (uint32_t index = 0, count = browsers.Length(); - index < count; - index++) { + for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) { uint32_t appId = - TabParent::GetFrom(browsers[index])->OwnOrContainingAppId(); + TabParent::GetFrom(iter.Get()->GetKey())->OwnOrContainingAppId(); MOZ_ASSERT(appId != nsIScriptSecurityManager::UNKNOWN_APP_ID && appId != nsIScriptSecurityManager::NO_APP_ID); diff --git a/dom/ipc/ContentBridgeParent.cpp b/dom/ipc/ContentBridgeParent.cpp index 8754f9b0beb2..5cfde1393c0a 100644 --- a/dom/ipc/ContentBridgeParent.cpp +++ b/dom/ipc/ContentBridgeParent.cpp @@ -166,7 +166,7 @@ ContentBridgeParent::DeallocPBrowserParent(PBrowserParent* aParent) void ContentBridgeParent::NotifyTabDestroyed() { - int32_t numLiveTabs = ManagedPBrowserParent().Length(); + int32_t numLiveTabs = ManagedPBrowserParent().Count(); if (numLiveTabs == 1) { MessageLoop::current()->PostTask( FROM_HERE, diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 4c5f4276d181..4e729e1b874e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -1279,7 +1279,7 @@ static void FirstIdle(void) mozilla::jsipc::PJavaScriptChild * ContentChild::AllocPJavaScriptChild() { - MOZ_ASSERT(!ManagedPJavaScriptChild().Length()); + MOZ_ASSERT(ManagedPJavaScriptChild().IsEmpty()); return nsIContentChild::AllocPJavaScriptChild(); } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 7352d9da646e..a52b73e13ce9 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1797,11 +1797,11 @@ ContentParent::ShutDownProcess(ShutDownMethod aMethod) } } - const InfallibleTArray& ocuParents = + const ManagedContainer& ocuParents = ManagedPOfflineCacheUpdateParent(); - for (uint32_t i = 0; i < ocuParents.Length(); ++i) { + for (auto iter = ocuParents.ConstIter(); !iter.Done(); iter.Next()) { nsRefPtr ocuParent = - static_cast(ocuParents[i]); + static_cast(iter.Get()->GetKey()); ocuParent->StopSendingMessagesToChild(); } @@ -3418,7 +3418,7 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline, mozilla::jsipc::PJavaScriptParent * ContentParent::AllocPJavaScriptParent() { - MOZ_ASSERT(!ManagedPJavaScriptParent().Length()); + MOZ_ASSERT(ManagedPJavaScriptParent().IsEmpty()); return nsIContentParent::AllocPJavaScriptParent(); } diff --git a/dom/ipc/ContentProcessManager.cpp b/dom/ipc/ContentProcessManager.cpp index 594975696c9e..403fbb852098 100644 --- a/dom/ipc/ContentProcessManager.cpp +++ b/dom/ipc/ContentProcessManager.cpp @@ -290,10 +290,9 @@ ContentProcessManager::GetTabParentByProcessAndTabId(const ContentParentId& aChi return nullptr; } - const InfallibleTArray& browsers = - iter->second.mCp->ManagedPBrowserParent(); - for (uint32_t i = 0; i < browsers.Length(); i++) { - nsRefPtr tab = TabParent::GetFrom(browsers[i]); + const ManagedContainer& browsers = iter->second.mCp->ManagedPBrowserParent(); + for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) { + nsRefPtr tab = TabParent::GetFrom(iter.Get()->GetKey()); if (tab->GetTabId() == aChildTabId) { return tab.forget(); } diff --git a/dom/ipc/CrashReporterChild.cpp b/dom/ipc/CrashReporterChild.cpp index bc6b94f24ab2..27d3dee2ddd2 100644 --- a/dom/ipc/CrashReporterChild.cpp +++ b/dom/ipc/CrashReporterChild.cpp @@ -17,7 +17,7 @@ namespace dom { PCrashReporterChild* CrashReporterChild::GetCrashReporter() { - const InfallibleTArray* reporters = nullptr; + const ManagedContainer* reporters = nullptr; switch (XRE_GetProcessType()) { case GeckoProcessType_Content: { ContentChild* child = ContentChild::GetSingleton(); diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index c3a489658385..ee2d7cda9c41 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -1041,11 +1041,11 @@ ParticularProcessPriorityManager::Notify(nsITimer* aTimer) bool ParticularProcessPriorityManager::HasAppType(const char* aAppType) { - const InfallibleTArray& browsers = + const ManagedContainer& browsers = mContentParent->ManagedPBrowserParent(); - for (uint32_t i = 0; i < browsers.Length(); i++) { + for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) { nsAutoString appType; - TabParent::GetFrom(browsers[i])->GetAppType(appType); + TabParent::GetFrom(iter.Get()->GetKey())->GetAppType(appType); if (appType.EqualsASCII(aAppType)) { return true; } @@ -1057,10 +1057,10 @@ ParticularProcessPriorityManager::HasAppType(const char* aAppType) bool ParticularProcessPriorityManager::IsExpectingSystemMessage() { - const InfallibleTArray& browsers = + const ManagedContainer& browsers = mContentParent->ManagedPBrowserParent(); - for (uint32_t i = 0; i < browsers.Length(); i++) { - TabParent* tp = TabParent::GetFrom(browsers[i]); + for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) { + TabParent* tp = TabParent::GetFrom(iter.Get()->GetKey()); nsCOMPtr bf = do_QueryInterface(tp->GetOwnerElement()); if (!bf) { continue; @@ -1089,10 +1089,10 @@ ParticularProcessPriorityManager::ComputePriority() } bool isVisible = false; - const InfallibleTArray& browsers = + const ManagedContainer& browsers = mContentParent->ManagedPBrowserParent(); - for (uint32_t i = 0; i < browsers.Length(); i++) { - if (TabParent::GetFrom(browsers[i])->IsVisible()) { + for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) { + if (TabParent::GetFrom(iter.Get()->GetKey())->IsVisible()) { isVisible = true; break; } diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index a35d74d5eee1..ffae8041a142 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -563,9 +563,11 @@ TabParent::DestroyInternal() // Let all PluginWidgets know we are tearing down. Prevents // these objects from sending async events after the child side // is shut down. - const nsTArray& kids = ManagedPPluginWidgetParent(); - for (uint32_t idx = 0; idx < kids.Length(); ++idx) { - static_cast(kids[idx])->ParentDestroy(); + const ManagedContainer& kids = + ManagedPPluginWidgetParent(); + for (auto iter = kids.ConstIter(); !iter.Done(); iter.Next()) { + static_cast( + iter.Get()->GetKey())->ParentDestroy(); } } @@ -1446,17 +1448,16 @@ TabParent::GetTopLevelDocAccessible() const #ifdef ACCESSIBILITY // XXX Consider managing non top level PDocAccessibles with their parent // document accessible. - const nsTArray& docs = ManagedPDocAccessibleParent(); - size_t docCount = docs.Length(); - for (size_t i = 0; i < docCount; i++) { - auto doc = static_cast(docs[i]); + const ManagedContainer& docs = ManagedPDocAccessibleParent(); + for (auto iter = docs.ConstIter(); !iter.Done(); iter.Next()) { + auto doc = static_cast(iter.Get()->GetKey()); if (!doc->ParentDoc()) { return doc; } } - MOZ_ASSERT(docCount == 0, "If there isn't a top level accessible doc " - "there shouldn't be an accessible doc at all!"); + MOZ_ASSERT(docs.Count() == 0, "If there isn't a top level accessible doc " + "there shouldn't be an accessible doc at all!"); #endif return nullptr; } diff --git a/dom/media/gmp/GMPContentChild.cpp b/dom/media/gmp/GMPContentChild.cpp index 4d9643fcd76d..8cb03e4a1272 100644 --- a/dom/media/gmp/GMPContentChild.cpp +++ b/dom/media/gmp/GMPContentChild.cpp @@ -181,28 +181,28 @@ void GMPContentChild::CloseActive() { // Invalidate and remove any remaining API objects. - const nsTArray& audioDecoders = + const ManagedContainer& audioDecoders = ManagedPGMPAudioDecoderChild(); - for (uint32_t i = audioDecoders.Length(); i > 0; i--) { - audioDecoders[i - 1]->SendShutdown(); + for (auto iter = audioDecoders.ConstIter(); !iter.Done(); iter.Next()) { + iter.Get()->GetKey()->SendShutdown(); } - const nsTArray& decryptors = + const ManagedContainer& decryptors = ManagedPGMPDecryptorChild(); - for (uint32_t i = decryptors.Length(); i > 0; i--) { - decryptors[i - 1]->SendShutdown(); + for (auto iter = decryptors.ConstIter(); !iter.Done(); iter.Next()) { + iter.Get()->GetKey()->SendShutdown(); } - const nsTArray& videoDecoders = + const ManagedContainer& videoDecoders = ManagedPGMPVideoDecoderChild(); - for (uint32_t i = videoDecoders.Length(); i > 0; i--) { - videoDecoders[i - 1]->SendShutdown(); + for (auto iter = videoDecoders.ConstIter(); !iter.Done(); iter.Next()) { + iter.Get()->GetKey()->SendShutdown(); } - const nsTArray& videoEncoders = + const ManagedContainer& videoEncoders = ManagedPGMPVideoEncoderChild(); - for (uint32_t i = videoEncoders.Length(); i > 0; i--) { - videoEncoders[i - 1]->SendShutdown(); + for (auto iter = videoEncoders.ConstIter(); !iter.Done(); iter.Next()) { + iter.Get()->GetKey()->SendShutdown(); } } diff --git a/gfx/layers/ipc/CompositorChild.cpp b/gfx/layers/ipc/CompositorChild.cpp index 655b2fab00fe..60c4bb7aa7c5 100644 --- a/gfx/layers/ipc/CompositorChild.cpp +++ b/gfx/layers/ipc/CompositorChild.cpp @@ -92,11 +92,11 @@ CompositorChild::Destroy() mLayerManager = nullptr; } - // start from the end of the array because Destroy() can cause the - // LayerTransactionChild to be removed from the array. - for (int i = ManagedPLayerTransactionChild().Length() - 1; i >= 0; --i) { + nsAutoTArray transactions; + ManagedPLayerTransactionChild(transactions); + for (int i = transactions.Length() - 1; i >= 0; --i) { RefPtr layers = - static_cast(ManagedPLayerTransactionChild()[i]); + static_cast(transactions[i]); layers->Destroy(); } diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index fa7749a31602..b4ac44acb968 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -612,7 +612,7 @@ CompositorParent::~CompositorParent() void CompositorParent::Destroy() { - MOZ_ASSERT(ManagedPLayerTransactionParent().Length() == 0, + MOZ_ASSERT(ManagedPLayerTransactionParent().Count() == 0, "CompositorParent destroyed before managed PLayerTransactionParent"); MOZ_ASSERT(mPaused); // Ensure RecvWillStop was called diff --git a/gfx/layers/ipc/LayerTransactionChild.cpp b/gfx/layers/ipc/LayerTransactionChild.cpp index c61c9c94e601..1e456c4a22db 100644 --- a/gfx/layers/ipc/LayerTransactionChild.cpp +++ b/gfx/layers/ipc/LayerTransactionChild.cpp @@ -33,11 +33,12 @@ LayerTransactionChild::Destroy() // When it happens, IPCOpen() is still true. // See bug 1004191. mDestroyed = true; - MOZ_ASSERT(0 == ManagedPLayerChild().Length(), + MOZ_ASSERT(0 == ManagedPLayerChild().Count(), "layers should have been cleaned up by now"); - for (size_t i = 0; i < ManagedPTextureChild().Length(); ++i) { - TextureClient* texture = TextureClient::AsTextureClient(ManagedPTextureChild()[i]); + const ManagedContainer& textures = ManagedPTextureChild(); + for (auto iter = textures.ConstIter(); !iter.Done(); iter.Next()) { + TextureClient* texture = TextureClient::AsTextureClient(iter.Get()->GetKey()); if (texture) { texture->ForceRemove(); } diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 7f30eeef5cff..eee59ae7f3f6 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -175,9 +175,10 @@ void LayerTransactionParent::Destroy() { mDestroyed = true; - for (size_t i = 0; i < ManagedPLayerParent().Length(); ++i) { + const ManagedContainer& layers = ManagedPLayerParent(); + for (auto iter = layers.ConstIter(); !iter.Done(); iter.Next()) { ShadowLayerParent* slp = - static_cast(ManagedPLayerParent()[i]); + static_cast(iter.Get()->GetKey()); slp->Destroy(); } } diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index b501682b69f4..c68990cedc10 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -28,6 +28,9 @@ #include #endif +template class nsTHashtable; +template class nsPtrHashKey; + // WARNING: this takes into account the private, special-message-type // enum in ipc_channel.h. They need to be kept in sync. namespace { @@ -328,14 +331,18 @@ DuplicateHandle(HANDLE aSourceHandle, } // namespace ipc +template +using ManagedContainer = nsTHashtable>; + template Protocol* -LoneManagedOrNull(const nsTArray& aManagees) +LoneManagedOrNull(const ManagedContainer& aManagees) { - if (aManagees.Length() == 0) { + if (aManagees.IsEmpty()) { return nullptr; } - return aManagees[0]; + MOZ_ASSERT(aManagees.Count() == 1); + return aManagees.ConstIter().Get()->GetKey(); } } // namespace mozilla diff --git a/ipc/ipdl/ipdl/builtin.py b/ipc/ipdl/ipdl/builtin.py index b141df9fb547..c9893566f6b4 100644 --- a/ipc/ipdl/ipdl/builtin.py +++ b/ipc/ipdl/ipdl/builtin.py @@ -50,6 +50,7 @@ HeaderIncludes = ( 'nsStringGlue.h', 'nsTArray.h', 'mozilla/ipc/ProtocolUtils.h', + 'nsTHashtable.h', ) CppIncludes = ( diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 6f32e2c93707..3b49dde4a7e4 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -335,6 +335,10 @@ def _refptrTake(expr): def _cxxArrayType(basetype, const=0, ref=0): return Type('nsTArray', T=basetype, const=const, ref=ref, hasimplicitcopyctor=False) +def _cxxManagedContainerType(basetype, const=0, ref=0): + return Type('ManagedContainer', T=basetype, + const=const, ref=ref, hasimplicitcopyctor=False) + def _cxxFallibleArrayType(basetype, const=0, ref=0): return Type('FallibleTArray', T=basetype, const=const, ref=ref) @@ -353,20 +357,18 @@ def _callCxxSwapArrayElements(arr1, arr2, sel='.'): args=[ arr2 ]) def _callInsertManagedActor(managees, actor): - return ExprCall(ExprSelect(managees, '.', 'InsertElementSorted'), + return ExprCall(ExprSelect(managees, '.', 'PutEntry'), args=[ actor ]) def _callRemoveManagedActor(managees, actor): - return ExprCall(ExprSelect(managees, '.', 'RemoveElementSorted'), + return ExprCall(ExprSelect(managees, '.', 'RemoveEntry'), args=[ actor ]) def _callClearManagedActors(managees): return ExprCall(ExprSelect(managees, '.', 'Clear')) def _callHasManagedActor(managees, actor): - return ExprBinary( - ExprSelect(managees, '.', 'NoIndex'), '!=', - ExprCall(ExprSelect(managees, '.', 'BinaryIndexOf'), args=[ actor ])) + return ExprCall(ExprSelect(managees, '.', 'Contains'), args=[ actor ]) def _otherSide(side): if side == 'child': return 'parent' @@ -1266,8 +1268,8 @@ class Protocol(ipdl.ast.Protocol): def managedVarType(self, actortype, side, const=0, ref=0): assert self.decl.type.isManagerOf(actortype) - return _cxxArrayType(self.managedCxxType(actortype, side), - const=const, ref=ref) + return _cxxManagedContainerType(Type(_actorName(actortype.name(), side)), + const=const, ref=ref) def managerArrayExpr(self, thisvar, side): """The member var my manager keeps of actors of my type.""" @@ -3054,17 +3056,41 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): self.cls.addstmts([ managermeth, Whitespace.NL ]) + def actorFromIter(itervar): + return ExprCall(ExprSelect(ExprCall(ExprSelect(itervar, '.', 'Get')), + '->', 'GetKey')) + def forLoopOverHashtable(hashtable, itervar, const=False): + return StmtFor( + init=Param(Type.AUTO, itervar.name, + ExprCall(ExprSelect(hashtable, '.', 'ConstIter' if const else 'Iter'))), + cond=ExprNot(ExprCall(ExprSelect(itervar, '.', 'Done'))), + update=ExprCall(ExprSelect(itervar, '.', 'Next'))) + ## Managed[T](Array& inout) const ## const Array& Managed() const for managed in ptype.manages: arrvar = ExprVar('aArr') meth = MethodDefn(MethodDecl( p.managedMethod(managed, self.side).name, - params=[ Decl(p.managedVarType(managed, self.side, ref=1), + params=[ Decl(_cxxArrayType(p.managedCxxType(managed, self.side), ref=1), arrvar.name) ], const=1)) - meth.addstmt(StmtExpr(ExprAssn( - arrvar, p.managedVar(managed, self.side)))) + ivar = ExprVar('i') + elementsvar = ExprVar('elements') + itervar = ExprVar('iter') + meth.addstmt(StmtDecl(Decl(Type.UINT32, ivar.name), + init=ExprLiteral.ZERO)) + meth.addstmt(StmtDecl(Decl(Type(_actorName(managed.name(), self.side), ptrptr=1), elementsvar.name), + init=ExprCall(ExprSelect(arrvar, '.', 'AppendElements'), + args=[ ExprCall(ExprSelect(p.managedVar(managed, self.side), + '.', 'Count')) ]))) + foreachaccumulate = forLoopOverHashtable(p.managedVar(managed, self.side), + itervar, const=True) + foreachaccumulate.addstmt(StmtExpr( + ExprAssn(ExprIndex(elementsvar, ivar), + actorFromIter(itervar)))) + foreachaccumulate.addstmt(StmtExpr(ExprPrefixUnop(ivar, '++'))) + meth.addstmt(foreachaccumulate) refmeth = MethodDefn(MethodDecl( p.managedMethod(managed, self.side).name, @@ -3404,6 +3430,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): subtreewhyvar = ExprVar('subtreewhy') kidsvar = ExprVar('kids') ivar = ExprVar('i') + itervar = ExprVar('iter') ithkid = ExprIndex(kidsvar, ivar) destroysubtree = MethodDefn(MethodDecl( @@ -3433,6 +3460,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): ]) for managed in ptype.manages: + managedVar = p.managedVar(managed, self.side) + foreachdestroy = StmtFor( init=Param(Type.UINT32, ivar.name, ExprLiteral.ZERO), cond=ExprBinary(ivar, '<', _callCxxArrayLength(kidsvar)), @@ -3471,20 +3500,16 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): ## DeallocSubtree() deallocsubtree = MethodDefn(MethodDecl(deallocsubtreevar.name)) for managed in ptype.manages: - foreachrecurse = StmtFor( - init=Param(Type.UINT32, ivar.name, ExprLiteral.ZERO), - cond=ExprBinary(ivar, '<', _callCxxArrayLength(kidsvar)), - update=ExprPrefixUnop(ivar, '++')) - foreachrecurse.addstmt(StmtExpr(ExprCall( - ExprSelect(ithkid, '->', deallocsubtreevar.name)))) + managedVar = p.managedVar(managed, self.side) - foreachdealloc = StmtFor( - init=Param(Type.UINT32, ivar.name, ExprLiteral.ZERO), - cond=ExprBinary(ivar, '<', _callCxxArrayLength(kidsvar)), - update=ExprPrefixUnop(ivar, '++')) + foreachrecurse = forLoopOverHashtable(managedVar, itervar) + foreachrecurse.addstmt(StmtExpr(ExprCall( + ExprSelect(actorFromIter(itervar), '->', deallocsubtreevar.name)))) + + foreachdealloc = forLoopOverHashtable(managedVar, itervar) foreachdealloc.addstmts([ StmtExpr(ExprCall(_deallocMethod(managed, self.side), - args=[ ithkid ])) + args=[ actorFromIter(itervar) ])) ]) block = StmtBlock() @@ -3492,17 +3517,10 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): Whitespace( '// Recursively deleting %s kids\n'% (managed.name()), indent=1), - StmtDecl( - Decl(p.managedVarType(managed, self.side, ref=1), - kidsvar.name), - init=p.managedVar(managed, self.side)), foreachrecurse, Whitespace.NL, - # no need to copy |kids| here; we're the ones deleting - # stragglers, no outside C++ is being invoked (except - # Dealloc(subactor)) foreachdealloc, - StmtExpr(_callClearManagedActors(p.managedVar(managed, self.side))), + StmtExpr(_callClearManagedActors(managedVar)), ]) deallocsubtree.addstmt(block) @@ -3561,7 +3579,6 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): for managed in ptype.manages: self.cls.addstmts([ - Whitespace('// Sorted by pointer value\n', indent=1), StmtDecl(Decl( p.managedVarType(managed, self.side), p.managedVar(managed, self.side).name)) ]) diff --git a/ipc/ipdl/test/cxx/TestSelfManageRoot.cpp b/ipc/ipdl/test/cxx/TestSelfManageRoot.cpp index 564bc814df46..e8b2330ba1f5 100644 --- a/ipc/ipdl/test/cxx/TestSelfManageRoot.cpp +++ b/ipc/ipdl/test/cxx/TestSelfManageRoot.cpp @@ -22,21 +22,21 @@ TestSelfManageRootParent::Main() if (!a) fail("constructing PTestSelfManage"); - ASSERT(1 == ManagedPTestSelfManageParent().Length()); + ASSERT(1 == ManagedPTestSelfManageParent().Count()); TestSelfManageParent* aa = static_cast(a->SendPTestSelfManageConstructor()); if (!aa) fail("constructing PTestSelfManage"); - ASSERT(1 == ManagedPTestSelfManageParent().Length() && - 1 == a->ManagedPTestSelfManageParent().Length()); + ASSERT(1 == ManagedPTestSelfManageParent().Count() && + 1 == a->ManagedPTestSelfManageParent().Count()); if (!PTestSelfManageParent::Send__delete__(aa)) fail("destroying PTestSelfManage"); ASSERT(Deletion == aa->mWhy && - 1 == ManagedPTestSelfManageParent().Length() && - 0 == a->ManagedPTestSelfManageParent().Length()); + 1 == ManagedPTestSelfManageParent().Count() && + 0 == a->ManagedPTestSelfManageParent().Count()); delete aa; aa = @@ -44,15 +44,15 @@ TestSelfManageRootParent::Main() if (!aa) fail("constructing PTestSelfManage"); - ASSERT(1 == ManagedPTestSelfManageParent().Length() && - 1 == a->ManagedPTestSelfManageParent().Length()); + ASSERT(1 == ManagedPTestSelfManageParent().Count() && + 1 == a->ManagedPTestSelfManageParent().Count()); if (!PTestSelfManageParent::Send__delete__(a)) fail("destroying PTestSelfManage"); ASSERT(Deletion == a->mWhy && AncestorDeletion == aa->mWhy && - 0 == ManagedPTestSelfManageParent().Length() && - 0 == a->ManagedPTestSelfManageParent().Length()); + 0 == ManagedPTestSelfManageParent().Count() && + 0 == a->ManagedPTestSelfManageParent().Count()); delete a; delete aa; diff --git a/ipc/ipdl/test/cxx/TestShutdown.cpp b/ipc/ipdl/test/cxx/TestShutdown.cpp index 217aabc851a5..95a242bff384 100644 --- a/ipc/ipdl/test/cxx/TestShutdown.cpp +++ b/ipc/ipdl/test/cxx/TestShutdown.cpp @@ -26,7 +26,7 @@ TestShutdownParent::ActorDestroy(ActorDestroyReason why) void TestShutdownSubParent::ActorDestroy(ActorDestroyReason why) { - if (Manager()->ManagedPTestShutdownSubParent().Length() == 0) + if (Manager()->ManagedPTestShutdownSubParent().Count() == 0) fail("manager should still have managees!"); if (mExpectCrash && AbnormalShutdown != why) @@ -34,14 +34,14 @@ TestShutdownSubParent::ActorDestroy(ActorDestroyReason why) else if (!mExpectCrash && AbnormalShutdown == why) fail("wasn't expecting crash!"); - if (mExpectCrash && 0 == ManagedPTestShutdownSubsubParent().Length()) + if (mExpectCrash && 0 == ManagedPTestShutdownSubsubParent().Count()) fail("expected to *still* have kids"); } void TestShutdownSubsubParent::ActorDestroy(ActorDestroyReason why) { - if (Manager()->ManagedPTestShutdownSubsubParent().Length() == 0) + if (Manager()->ManagedPTestShutdownSubsubParent().Count() == 0) fail("manager should still have managees!"); if (mExpectParentDeleted && AncestorDeletion != why) @@ -206,7 +206,7 @@ TestShutdownSubChild::AnswerStackFrame() void TestShutdownSubChild::ActorDestroy(ActorDestroyReason why) { - if (Manager()->ManagedPTestShutdownSubChild().Length() == 0) + if (Manager()->ManagedPTestShutdownSubChild().Count() == 0) fail("manager should still have managees!"); if (mExpectCrash && AbnormalShutdown != why) @@ -214,14 +214,14 @@ TestShutdownSubChild::ActorDestroy(ActorDestroyReason why) else if (!mExpectCrash && AbnormalShutdown == why) fail("wasn't expecting crash!"); - if (mExpectCrash && 0 == ManagedPTestShutdownSubsubChild().Length()) + if (mExpectCrash && 0 == ManagedPTestShutdownSubsubChild().Count()) fail("expected to *still* have kids"); } void TestShutdownSubsubChild::ActorDestroy(ActorDestroyReason why) { - if (Manager()->ManagedPTestShutdownSubsubChild().Length() == 0) + if (Manager()->ManagedPTestShutdownSubsubChild().Count() == 0) fail("manager should still have managees!"); if (mExpectParentDeleted && AncestorDeletion != why) diff --git a/widget/gonk/GonkPermission.cpp b/widget/gonk/GonkPermission.cpp index a456d07f9c52..e72aaabab103 100644 --- a/widget/gonk/GonkPermission.cpp +++ b/widget/gonk/GonkPermission.cpp @@ -90,9 +90,11 @@ GonkPermissionChecker::Run() } // Now iterate its apps... - for (uint32_t i = 0; i < contentParent->ManagedPBrowserParent().Length(); i++) { + const ManagedContainer& browsers = + contentParent->ManagedPBrowserParent(); + for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) { dom::TabParent *tabParent = - static_cast(contentParent->ManagedPBrowserParent()[i]); + static_cast(iter.Get()->GetKey()); nsCOMPtr mozApp = tabParent->GetOwnOrContainingApp(); if (!mozApp) { continue;