Bumping manifests a=b2g-bump
[gecko.git] / ipc / glue / BackgroundParent.h
blob7bb860264bc23ce7d07ed4aa695b0e5554b8dd68
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;
14 namespace mozilla {
15 namespace dom {
17 class ContentParent;
18 class FileImpl;
19 class PBlobParent;
21 } // namespace dom
23 namespace ipc {
25 class PBackgroundParent;
27 // This class is not designed for public consumption beyond the few static
28 // member functions.
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;
38 public:
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.
43 static bool
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,
59 FileImpl* aBlobImpl);
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.
65 static intptr_t
66 GetRawContentParentForComparison(PBackgroundParent* aBackgroundActor);
68 private:
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.
77 bool
78 IsOnBackgroundThread();
80 #ifdef DEBUG
82 // Implemented in BackgroundImpl.cpp.
83 void
84 AssertIsOnBackgroundThread();
86 #else
88 inline void
89 AssertIsOnBackgroundThread()
90 { }
92 #endif // DEBUG
94 } // namespace ipc
95 } // namespace mozilla
97 #endif // mozilla_ipc_backgroundparent_h__