diff options
Diffstat (limited to 'ipc/glue/test/utility_process_xpcom/UtilityProcessTest.cpp')
-rw-r--r-- | ipc/glue/test/utility_process_xpcom/UtilityProcessTest.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/ipc/glue/test/utility_process_xpcom/UtilityProcessTest.cpp b/ipc/glue/test/utility_process_xpcom/UtilityProcessTest.cpp index 6c084a3153..9d22d60d0f 100644 --- a/ipc/glue/test/utility_process_xpcom/UtilityProcessTest.cpp +++ b/ipc/glue/test/utility_process_xpcom/UtilityProcessTest.cpp @@ -7,6 +7,7 @@ #if defined(ENABLE_TESTS) # include "mozilla/ipc/UtilityProcessManager.h" # include "mozilla/ipc/UtilityProcessTest.h" +# include "mozilla/dom/ChromeUtilsBinding.h" # include "mozilla/dom/Promise.h" # include "mozilla/ProcInfo.h" # include "mozilla/IntentionalCrash.h" @@ -26,23 +27,17 @@ namespace mozilla::ipc { static UtilityActorName UtilityActorNameFromString( const nsACString& aStringName) { using namespace mozilla::dom; - - // We use WebIDLUtilityActorNames because UtilityActorNames is not designed - // for iteration. - for (size_t i = 0; i < WebIDLUtilityActorNameValues::Count; ++i) { - auto idlName = static_cast<UtilityActorName>(i); - const nsDependentCSubstring idlNameString( - WebIDLUtilityActorNameValues::GetString(idlName)); - if (idlNameString.Equals(aStringName)) { - return idlName; - } + auto idlName = StringToEnum<UtilityActorName>(aStringName); + if (idlName.isSome()) { + return idlName.value(); } MOZ_CRASH("Unknown utility actor name"); } // Find the utility process with the given actor or any utility process if -// the actor is UtilityActorName::EndGuard_. -static SandboxingKind FindUtilityProcessWithActor(UtilityActorName aActorName) { +// aActorName is Nothing(). +static SandboxingKind FindUtilityProcessWithActor( + const Maybe<UtilityActorName>& aActorName) { RefPtr<UtilityProcessManager> utilityProc = UtilityProcessManager::GetSingleton(); MOZ_ASSERT(utilityProc, "No UtilityprocessManager?"); @@ -52,11 +47,11 @@ static SandboxingKind FindUtilityProcessWithActor(UtilityActorName aActorName) { if (!utilityProc->Process(sbKind)) { continue; } - if (aActorName == UtilityActorName::EndGuard_) { + if (aActorName.isNothing()) { return sbKind; } for (auto actor : utilityProc->GetActors(sbKind)) { - if (actor == aActorName) { + if (actor == aActorName.ref()) { return sbKind; } } @@ -236,9 +231,9 @@ UtilityProcessTest::StopProcess(const char* aActorName) { if (aActorName) { const nsDependentCString actorStringName(aActorName); UtilityActorName actorName = UtilityActorNameFromString(actorStringName); - sbKind = FindUtilityProcessWithActor(actorName); + sbKind = FindUtilityProcessWithActor(Some(actorName)); } else { - sbKind = FindUtilityProcessWithActor(UtilityActorName::EndGuard_); + sbKind = FindUtilityProcessWithActor(Nothing()); } if (sbKind == SandboxingKind::COUNT) { |