Bug 1842773 - Part 5: Add ArrayBuffer.prototype.{maxByteLength,resizable} getters...
[gecko.git] / dom / media / gmp / GMPProcessParent.h
blobbf16a96380cd9902f5fb96d3fa2995bbe26edaf9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=4 et :
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 GMPProcessParent_h
8 #define GMPProcessParent_h 1
10 #include "mozilla/Attributes.h"
11 #include "base/basictypes.h"
12 #include "base/file_path.h"
13 #include "base/thread.h"
14 #include "mozilla/ipc/GeckoChildProcessHost.h"
15 #include "nsIFile.h"
17 class nsIRunnable;
19 namespace mozilla::gmp {
21 class GMPProcessParent final : public mozilla::ipc::GeckoChildProcessHost {
22 public:
23 explicit GMPProcessParent(const std::string& aGMPPath);
25 // Synchronously launch the plugin process. If the process fails to launch
26 // after timeoutMs, this method will return false.
27 bool Launch(int32_t aTimeoutMs);
29 void Delete(nsCOMPtr<nsIRunnable> aCallback = nullptr);
31 bool CanShutdown() override { return true; }
32 const std::string& GetPluginFilePath() { return mGMPPath; }
33 bool UseXPCOM() const { return mUseXpcom; }
35 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
36 // Init static members on the main thread
37 static void InitStaticMainThread();
39 // Read prefs and environment variables to determine
40 // when and if to start the Mac sandbox for the child
41 // process. Starting the sandbox at launch is the new
42 // preferred method. Code to support starting the sandbox
43 // later at plugin start time should be removed once
44 // starting at launch is stable and shipping.
45 bool IsMacSandboxLaunchEnabled() override;
47 // For process sandboxing purposes, set whether or not this
48 // instance of the GMP process requires access to the macOS
49 // window server. At present, Widevine requires window server
50 // access, but OpenH264 decoding does not.
51 void SetRequiresWindowServer(bool aRequiresWindowServer);
53 // Return the sandbox type to be used with this process type.
54 static MacSandboxType GetMacSandboxType() { return MacSandboxType_GMP; };
55 #endif
57 using mozilla::ipc::GeckoChildProcessHost::GetChildProcessHandle;
59 private:
60 ~GMPProcessParent();
62 void DoDelete();
64 std::string mGMPPath;
65 nsCOMPtr<nsIRunnable> mDeletedCallback;
67 // Whether or not XPCOM is enabled in the GMP process.
68 bool mUseXpcom;
70 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
71 // Indicates whether we'll start the Mac GMP sandbox during
72 // process launch (earlyinit) which is the new preferred method
73 // or later in the process lifetime.
74 static bool sLaunchWithMacSandbox;
76 // Whether or not Mac sandbox violation logging is enabled.
77 static bool sMacSandboxGMPLogging;
79 // Override so we can set GMP-specific sandbox parameters
80 bool FillMacSandboxInfo(MacSandboxInfo& aInfo) override;
82 // Controls whether or not the sandbox will be configured with
83 // window service access.
84 bool mRequiresWindowServer;
86 # if defined(DEBUG)
87 // Used to assert InitStaticMainThread() is called before the constructor.
88 static bool sIsMainThreadInitDone;
89 # endif
90 #endif
92 // For normalizing paths to be compatible with sandboxing.
93 // We use normalized paths to generate the sandbox ruleset. Once
94 // the sandbox has been started, resolving symlinks that point to
95 // allowed directories could require reading paths not allowed by
96 // the sandbox, so we should only attempt to load plugin libraries
97 // using normalized paths.
98 static nsresult NormalizePath(const char* aPath, PathString& aNormalizedPath);
100 DISALLOW_COPY_AND_ASSIGN(GMPProcessParent);
103 } // namespace mozilla::gmp
105 #endif // ifndef GMPProcessParent_h