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
;
25 class PBackgroundParent
;
27 // This class is not designed for public consumption beyond the few static
29 class BackgroundParent MOZ_FINAL
31 friend class mozilla::dom::ContentParent
;
33 typedef base::ProcessId ProcessId
;
34 typedef mozilla::dom::ContentParent ContentParent
;
35 typedef mozilla::dom::FileImpl FileImpl
;
36 typedef mozilla::ipc::Transport Transport
;
39 // This function allows the caller to determine if the given parent actor
40 // corresponds to a child actor from another process or a child actor from a
41 // different thread in the same process.
42 // This function may only be called on the background thread.
44 IsOtherProcessActor(PBackgroundParent
* aBackgroundActor
);
46 // This function returns the ContentParent associated with the parent actor if
47 // the parent actor corresponds to a child actor from another process. If the
48 // parent actor corresponds to a child actor from a different thread in the
49 // same process then this function returns null.
50 // This function may only be called on the background thread. However,
51 // ContentParent is not threadsafe and the returned pointer may not be used on
52 // any thread other than the main thread. Callers must take care to use (and
53 // release) the returned pointer appropriately.
54 static already_AddRefed
<ContentParent
>
55 GetContentParent(PBackgroundParent
* aBackgroundActor
);
57 static mozilla::dom::PBlobParent
*
58 GetOrCreateActorForBlobImpl(PBackgroundParent
* aBackgroundActor
,
61 // Get a value that represents the ContentParent associated with the parent
62 // actor for comparison. The value is not guaranteed to uniquely identify the
63 // ContentParent after the ContentParent has died. This function may only be
64 // called on the background thread.
66 GetRawContentParentForComparison(PBackgroundParent
* aBackgroundActor
);
69 // Only called by ContentParent for cross-process actors.
70 static PBackgroundParent
*
71 Alloc(ContentParent
* aContent
,
72 Transport
* aTransport
,
73 ProcessId aOtherProcess
);
76 // Implemented in BackgroundImpl.cpp.
78 IsOnBackgroundThread();
82 // Implemented in BackgroundImpl.cpp.
84 AssertIsOnBackgroundThread();
89 AssertIsOnBackgroundThread()
95 } // namespace mozilla
97 #endif // mozilla_ipc_backgroundparent_h__