diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/components/processtools/ProcInfo_common.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/processtools/ProcInfo_common.cpp')
-rw-r--r-- | toolkit/components/processtools/ProcInfo_common.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/toolkit/components/processtools/ProcInfo_common.cpp b/toolkit/components/processtools/ProcInfo_common.cpp new file mode 100644 index 0000000000..ee64b157e0 --- /dev/null +++ b/toolkit/components/processtools/ProcInfo_common.cpp @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/ProcInfo.h" + +#include "mozilla/UniquePtr.h" +#include "nsNetCID.h" +#include "nsServiceManagerUtils.h" +#include "nsThreadUtils.h" + +namespace mozilla { + +RefPtr<ProcInfoPromise> GetProcInfo(nsTArray<ProcInfoRequest>&& aRequests) { + auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>(); + RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__); + + nsresult rv = NS_OK; + nsCOMPtr<nsIEventTarget> target = + do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to get stream transport service"); + holder->Reject(rv, __func__); + return promise; + } + + RefPtr<nsIRunnable> r = NS_NewRunnableFunction( + __func__, + [holder = std::move(holder), + requests = std::move(aRequests)]() mutable -> void { + holder->ResolveOrReject(GetProcInfoSync(std::move(requests)), __func__); + }); + + rv = target->Dispatch(r.forget(), NS_DISPATCH_NORMAL); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch the LoadDataRunnable."); + } + + return promise; +} + +nsCString GetUtilityActorName(const UtilityActorName aActorName) { + switch (aActorName) { + case UtilityActorName::Unknown: + return "unknown"_ns; + case UtilityActorName::AudioDecoder_Generic: + return "audio-decoder-generic"_ns; + case UtilityActorName::AudioDecoder_AppleMedia: + return "audio-decoder-applemedia"_ns; + case UtilityActorName::AudioDecoder_WMF: + return "audio-decoder-wmf"_ns; + case UtilityActorName::MfMediaEngineCDM: + return "mf-media-engine"_ns; + case UtilityActorName::JSOracle: + return "js-oracle"_ns; + case UtilityActorName::WindowsUtils: + return "windows-utils"_ns; + default: + return "unknown"_ns; + } +} + +} // namespace mozilla |