Bug 1942239 - Add option to explicitly enable incremental origin initialization in...
[gecko.git] / toolkit / components / processtools / ProcInfo_common.cpp
blob1c5ade172eadd6102b0d7e50c9b46442bcdacd6b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/ProcInfo.h"
9 #include "mozilla/UniquePtr.h"
10 #include "nsNetCID.h"
11 #include "nsServiceManagerUtils.h"
12 #include "nsThreadUtils.h"
14 namespace mozilla {
16 RefPtr<ProcInfoPromise> GetProcInfo(nsTArray<ProcInfoRequest>&& aRequests) {
17 auto holder = MakeUnique<MozPromiseHolder<ProcInfoPromise>>();
18 RefPtr<ProcInfoPromise> promise = holder->Ensure(__func__);
20 nsresult rv = NS_OK;
21 nsCOMPtr<nsIEventTarget> target =
22 do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
23 if (NS_FAILED(rv)) {
24 NS_WARNING("Failed to get stream transport service");
25 holder->Reject(rv, __func__);
26 return promise;
29 RefPtr<nsIRunnable> r = NS_NewRunnableFunction(
30 __func__,
31 [holder = std::move(holder),
32 requests = std::move(aRequests)]() mutable -> void {
33 holder->ResolveOrReject(GetProcInfoSync(std::move(requests)), __func__);
34 });
36 rv = target->Dispatch(r.forget(), NS_DISPATCH_NORMAL);
37 if (NS_FAILED(rv)) {
38 NS_WARNING("Failed to dispatch the LoadDataRunnable.");
41 return promise;
44 nsCString GetUtilityActorName(const UtilityActorName aActorName) {
45 switch (aActorName) {
46 case UtilityActorName::Unknown:
47 return "unknown"_ns;
48 case UtilityActorName::AudioDecoder_Generic:
49 return "audio-decoder-generic"_ns;
50 case UtilityActorName::AudioDecoder_AppleMedia:
51 return "audio-decoder-applemedia"_ns;
52 case UtilityActorName::AudioDecoder_WMF:
53 return "audio-decoder-wmf"_ns;
54 case UtilityActorName::MfMediaEngineCDM:
55 return "mf-media-engine"_ns;
56 case UtilityActorName::JSOracle:
57 return "js-oracle"_ns;
58 case UtilityActorName::WindowsUtils:
59 return "windows-utils"_ns;
60 case UtilityActorName::WindowsFileDialog:
61 return "windows-file-dialog"_ns;
62 default:
63 return "unknown"_ns;
67 } // namespace mozilla