Bug 1700051: part 31.4) Move `mSoftTextValid` to `SoftText`. r=smaug
[gecko.git] / ipc / glue / BackgroundChild.h
blobc1206ece22ecac2e689d02843c397bcce0d7aad0
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_ipc_backgroundchild_h__
8 #define mozilla_ipc_backgroundchild_h__
10 #include "mozilla/Attributes.h"
11 #include "mozilla/ipc/Transport.h"
13 class nsIEventTarget;
15 namespace mozilla {
16 namespace dom {
18 class BlobImpl;
19 class ContentChild;
20 class ContentParent;
22 } // namespace dom
24 namespace net {
26 class SocketProcessImpl;
27 class SocketProcessChild;
29 } // namespace net
31 namespace ipc {
33 class PBackgroundChild;
35 // This class allows access to the PBackground protocol. PBackground allows
36 // communication between any thread (in the parent or a child process) and a
37 // single background thread in the parent process. Each PBackgroundChild
38 // instance is tied to the thread on which it is created and must not be shared
39 // across threads. Each PBackgroundChild is unique and valid as long as its
40 // designated thread lives.
42 // Creation of PBackground is synchronous. GetOrCreateForCurrentThread will
43 // create the actor if it doesn't exist yet. Thereafter (assuming success)
44 // GetForCurrentThread() will return the same actor every time.
46 // GetOrCreateSocketActorForCurrentThread, which is like
47 // GetOrCreateForCurrentThread, is used to get or create PBackground actor
48 // between child process and socket process.
50 // CloseForCurrentThread() will close the current PBackground actor. Subsequent
51 // calls to GetForCurrentThread will return null. CloseForCurrentThread() may
52 // only be called exactly once for each thread-specific actor. Currently it is
53 // illegal to call this before the PBackground actor has been created.
55 // The PBackgroundChild actor and all its sub-protocol actors will be
56 // automatically destroyed when its designated thread completes.
57 class BackgroundChild final {
58 friend class mozilla::dom::ContentChild;
59 friend class mozilla::dom::ContentParent;
60 friend class mozilla::net::SocketProcessImpl;
61 friend class mozilla::net::SocketProcessChild;
63 typedef mozilla::ipc::Transport Transport;
65 public:
66 // See above.
67 static PBackgroundChild* GetForCurrentThread();
69 // See above.
70 static PBackgroundChild* GetOrCreateForCurrentThread(
71 nsIEventTarget* aMainEventTarget = nullptr);
73 // See above.
74 static void CloseForCurrentThread();
76 // See above.
77 static PBackgroundChild* GetOrCreateSocketActorForCurrentThread(
78 nsIEventTarget* aMainEventTarget = nullptr);
80 // See above.
81 static PBackgroundChild* GetOrCreateForSocketParentBridgeForCurrentThread(
82 nsIEventTarget* aMainEventTarget = nullptr);
84 private:
85 // Only called by ContentChild or ContentParent.
86 static void Startup();
89 } // namespace ipc
90 } // namespace mozilla
92 #endif // mozilla_ipc_backgroundchild_h__