Bug 1795172 [wpt PR 36447] - Disallow culled inlines in repeated content., a=testonly
[gecko.git] / dom / ipc / PreallocatedProcessManager.h
blob9dea534dbdc85edf5dfce963c05cb3f49003bed6
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_PreallocatedProcessManager_h
8 #define mozilla_PreallocatedProcessManager_h
10 #include "base/basictypes.h"
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "nsStringFwd.h"
14 namespace mozilla {
15 namespace dom {
16 class ContentParent;
17 } // namespace dom
19 /**
20 * This class manages a ContentParent that it starts up ahead of any particular
21 * need. You can then call Take() to get this process and use it. Since we
22 * already started it up, it should be ready for use faster than if you'd
23 * created the process when you needed it.
25 * This class watches the dom.ipc.processPrelaunch.enabled pref. If it changes
26 * from false to true, it preallocates a process. If it changes from true to
27 * false, it kills the preallocated process, if any.
29 * We don't expect this pref to flip between true and false in production, but
30 * flipping the pref is important for tests.
32 class PreallocatedProcessManagerImpl;
34 class PreallocatedProcessManager final {
35 typedef mozilla::dom::ContentParent ContentParent;
37 public:
38 static PreallocatedProcessManagerImpl* GetPPMImpl();
40 static bool Enabled();
42 /**
43 * Before first paint we don't want to allocate any processes in the
44 * background. To avoid that, the PreallocatedProcessManager won't start up
45 * any processes while there is a blocker active.
47 static void AddBlocker(const nsACString& aRemoteType, ContentParent* aParent);
48 static void RemoveBlocker(const nsACString& aRemoteType,
49 ContentParent* aParent);
51 /**
52 * Take a preallocated process, if we have one. If we don't have a
53 * preallocated process to return, this returns null.
55 * If we use a preallocated process, it will schedule the start of
56 * another on Idle (AllocateOnIdle()).
58 static already_AddRefed<ContentParent> Take(const nsACString& aRemoteType);
60 /**
61 * Note that a process was shut down, and should no longer be tracked as a
62 * preallocated process.
64 static void Erase(ContentParent* aParent);
66 private:
67 PreallocatedProcessManager();
68 DISALLOW_EVIL_CONSTRUCTORS(PreallocatedProcessManager);
71 } // namespace mozilla
73 #endif // defined mozilla_PreallocatedProcessManager_h