Bug 1796811 - Update in-tree zlib to version 1.2.13. r=aosmond
[gecko.git] / ipc / mscom / ProcessRuntime.h
blob7b52a56b8a6fab6611805ae6daa6af3c263d5179
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 #ifndef mozilla_mscom_ProcessRuntime_h
8 #define mozilla_mscom_ProcessRuntime_h
10 #include "mozilla/Attributes.h"
11 #if defined(ACCESSIBILITY)
12 # include "mozilla/mscom/ActivationContext.h"
13 # include "mozilla/Maybe.h"
14 #endif // defined(ACCESSIBILITY)
15 #include "mozilla/mscom/ApartmentRegion.h"
16 #include "nsWindowsHelpers.h"
17 #if defined(MOZILLA_INTERNAL_API)
18 # include "nsXULAppAPI.h"
19 #endif // defined(MOZILLA_INTERNAL_API)
21 namespace mozilla {
22 namespace mscom {
24 class MOZ_NON_TEMPORARY_CLASS ProcessRuntime final {
25 #if !defined(MOZILLA_INTERNAL_API)
26 public:
27 #endif // defined(MOZILLA_INTERNAL_API)
28 enum class ProcessCategory {
29 GeckoBrowserParent,
30 // We give Launcher its own process category, but internally to this class
31 // it should be treated identically to GeckoBrowserParent.
32 Launcher = GeckoBrowserParent,
33 GeckoChild,
34 Service,
37 // This constructor is only public when compiled outside of XUL
38 explicit ProcessRuntime(const ProcessCategory aProcessCategory);
40 public:
41 #if defined(MOZILLA_INTERNAL_API)
42 ProcessRuntime();
43 ~ProcessRuntime();
44 #else
45 ~ProcessRuntime() = default;
46 #endif // defined(MOZILLA_INTERNAL_API)
48 explicit operator bool() const { return SUCCEEDED(mInitResult); }
49 HRESULT GetHResult() const { return mInitResult; }
51 ProcessRuntime(const ProcessRuntime&) = delete;
52 ProcessRuntime(ProcessRuntime&&) = delete;
53 ProcessRuntime& operator=(const ProcessRuntime&) = delete;
54 ProcessRuntime& operator=(ProcessRuntime&&) = delete;
56 /**
57 * @return 0 if call is in-process or resolving the calling thread failed,
58 * otherwise contains the thread id of the calling thread.
60 static DWORD GetClientThreadId();
62 private:
63 #if defined(MOZILLA_INTERNAL_API)
64 explicit ProcessRuntime(const GeckoProcessType aProcessType);
65 # if defined(MOZ_SANDBOX)
66 void InitUsingPersistentMTAThread(const nsAutoHandle& aCurThreadToken);
67 # endif // defined(MOZ_SANDBOX)
68 #endif // defined(MOZILLA_INTERNAL_API)
69 void InitInsideApartment();
71 #if defined(MOZILLA_INTERNAL_API)
72 static void PostInit();
73 #endif // defined(MOZILLA_INTERNAL_API)
74 static HRESULT InitializeSecurity(const ProcessCategory aProcessCategory);
75 static COINIT GetDesiredApartmentType(const ProcessCategory aProcessCategory);
77 private:
78 HRESULT mInitResult;
79 const ProcessCategory mProcessCategory;
80 #if defined(ACCESSIBILITY) && \
81 (defined(MOZILLA_INTERNAL_API) || defined(MOZ_HAS_MOZGLUE))
82 Maybe<ActivationContextRegion> mActCtxRgn;
83 #endif // defined(ACCESSIBILITY) && (defined(MOZILLA_INTERNAL_API) ||
84 // defined(MOZ_HAS_MOZGLUE))
85 ApartmentRegion mAptRegion;
87 private:
88 #if defined(MOZILLA_INTERNAL_API)
89 static ProcessRuntime* sInstance;
90 #endif // defined(MOZILLA_INTERNAL_API)
93 } // namespace mscom
94 } // namespace mozilla
96 #endif // mozilla_mscom_ProcessRuntime_h