Bumping manifests a=b2g-bump
[gecko.git] / ipc / glue / BackgroundParent.h
blob4e0a0f2d22491b119c0b25a6d9c0ed22fcb634a7
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;
19 } // namespace dom
21 namespace ipc {
23 class PBackgroundParent;
25 // This class is not designed for public consumption beyond the few static
26 // member functions.
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;
35 public:
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.
40 static bool
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);
54 private:
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.
63 bool
64 IsOnBackgroundThread();
66 #ifdef DEBUG
68 // Implemented in BackgroundImpl.cpp.
69 void
70 AssertIsOnBackgroundThread();
72 #else
74 inline void
75 AssertIsOnBackgroundThread()
76 { }
78 #endif // DEBUG
80 } // namespace ipc
81 } // namespace mozilla
83 #endif // mozilla_ipc_backgroundparent_h__