Bug 1895215 - [devtools] Display cookie's partitionKey in storage panel. r=timhuang...
[gecko.git] / gfx / vr / ipc / VRProcessManager.h
blob0464033d866040a8fedfe1806a10f23ff0255422
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/. */
6 #ifndef GFX_VR_PROCESS_MANAGER_H
7 #define GFX_VR_PROCESS_MANAGER_H
9 #include "VRProcessParent.h"
11 #include "mozilla/ipc/ProtocolUtils.h"
12 #include "nsIObserver.h"
14 namespace mozilla {
15 class MemoryReportingProcess;
16 namespace ipc {
17 template <typename T>
18 class Endpoint;
20 namespace gfx {
22 class VRManagerChild;
23 class PVRGPUChild;
24 class VRChild;
26 // The VRProcessManager is a singleton responsible for creating VR-bound
27 // objects that may live in another process.
28 class VRProcessManager final : public VRProcessParent::Listener {
29 public:
30 static VRProcessManager* Get();
31 static void Initialize();
32 static void Shutdown();
34 ~VRProcessManager();
36 // If not using a VR process, launch a new VR process asynchronously.
37 void LaunchVRProcess();
39 // Ensure that VR-bound methods can be used. If no VR process is being
40 // used, or one is launched and ready, this function returns immediately.
41 // Otherwise it blocks until the VR process has finished launching.
42 bool EnsureVRReady();
44 bool CreateGPUBridges(mozilla::ipc::EndpointProcInfo aOtherProcess,
45 mozilla::ipc::Endpoint<PVRGPUChild>* aOutVRBridge);
47 VRChild* GetVRChild();
48 // If a VR process is present, create a MemoryReportingProcess object.
49 // Otherwise, return null.
50 RefPtr<MemoryReportingProcess> GetProcessMemoryReporter();
52 virtual void OnProcessLaunchComplete(VRProcessParent* aParent) override;
53 virtual void OnProcessUnexpectedShutdown(VRProcessParent* aParent) override;
55 private:
56 VRProcessManager();
58 DISALLOW_COPY_AND_ASSIGN(VRProcessManager);
60 bool CreateGPUVRManager(mozilla::ipc::EndpointProcInfo aOtherProcess,
61 mozilla::ipc::Endpoint<PVRGPUChild>* aOutEndpoint);
62 void OnXPCOMShutdown();
63 void OnPreferenceChange(const char16_t* aData);
64 void CleanShutdown();
65 void DestroyProcess();
67 // Permanently disable the VR process and record a message why.
68 void DisableVRProcess(const char* aMessage);
70 class Observer final : public nsIObserver {
71 public:
72 NS_DECL_ISUPPORTS
73 NS_DECL_NSIOBSERVER
74 explicit Observer(VRProcessManager* aManager);
76 protected:
77 ~Observer() = default;
79 VRProcessManager* mManager;
81 friend class Observer;
83 RefPtr<Observer> mObserver;
84 VRProcessParent* mProcess;
85 VRChild* mVRChild;
86 // Collects any pref changes that occur during process launch (after
87 // the initial map is passed in command-line arguments) to be sent
88 // when the process can receive IPC messages.
89 nsTArray<mozilla::dom::Pref> mQueuedPrefs;
92 } // namespace gfx
93 } // namespace mozilla
95 #endif // GFX_VR_PROCESS_MANAGER_H