1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_ipc_backgroundparent_h__
6 #define mozilla_ipc_backgroundparent_h__
8 #include "base/process.h"
9 #include "mozilla/Attributes.h"
10 #include "mozilla/ipc/Transport.h"
12 template <class> struct already_AddRefed
;
23 class PBackgroundParent
;
25 // This class is not designed for public consumption beyond the few static
27 class BackgroundParent MOZ_FINAL
29 friend class mozilla::dom::ContentParent
;
31 typedef base::ProcessId ProcessId
;
32 typedef mozilla::dom::ContentParent ContentParent
;
33 typedef mozilla::ipc::Transport Transport
;
36 // This function allows the caller to determine if the given parent actor
37 // corresponds to a child actor from another process or a child actor from a
38 // different thread in the same process.
39 // This function may only be called on the background thread.
41 IsOtherProcessActor(PBackgroundParent
* aBackgroundActor
);
43 // This function returns the ContentParent associated with the parent actor if
44 // the parent actor corresponds to a child actor from another process. If the
45 // parent actor corresponds to a child actor from a different thread in the
46 // same process then this function returns null.
47 // This function may only be called on the background thread. However,
48 // ContentParent is not threadsafe and the returned pointer may not be used on
49 // any thread other than the main thread. Callers must take care to use (and
50 // release) the returned pointer appropriately.
51 static already_AddRefed
<ContentParent
>
52 GetContentParent(PBackgroundParent
* aBackgroundActor
);
55 // Only called by ContentParent for cross-process actors.
56 static PBackgroundParent
*
57 Alloc(ContentParent
* aContent
,
58 Transport
* aTransport
,
59 ProcessId aOtherProcess
);
62 // Implemented in BackgroundImpl.cpp.
64 IsOnBackgroundThread();
68 // Implemented in BackgroundImpl.cpp.
70 AssertIsOnBackgroundThread();
75 AssertIsOnBackgroundThread()
81 } // namespace mozilla
83 #endif // mozilla_ipc_backgroundparent_h__