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_nsiipcbackgroundchildcreatecallback_h
6 #define mozilla_ipc_nsiipcbackgroundchildcreatecallback_h
8 #include "mozilla/Attributes.h"
9 #include "nsISupports.h"
14 class PBackgroundChild
;
17 } // namespace mozilla
19 #define NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID \
20 {0x4de01707, 0x70e3, 0x4181, {0xbc, 0x9f, 0xa3, 0xec, 0xfe, 0x74, 0x1a, 0xe3}}
22 class NS_NO_VTABLE nsIIPCBackgroundChildCreateCallback
: public nsISupports
25 typedef mozilla::ipc::PBackgroundChild PBackgroundChild
;
27 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID
)
29 // This will be called upon successful creation of a PBackgroundChild actor.
30 // The actor is unique per-thread and must not be shared across threads. It
31 // may be saved and reused on the same thread for as long as the thread lives.
32 // After this callback BackgroundChild::GetForCurrentThread() will return the
35 ActorCreated(PBackgroundChild
*) = 0;
37 // This will be called if for some reason the PBackgroundChild actor cannot be
38 // created. This should never be called in child processes as the failure to
39 // create the actor should result in the termination of the child process
40 // first. This may be called for cross-thread actors in the main process.
45 NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCBackgroundChildCreateCallback
,
46 NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID
)
48 #define NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK \
50 ActorCreated(mozilla::ipc::PBackgroundChild*) MOZ_OVERRIDE; \
52 ActorFailed() MOZ_OVERRIDE;
54 #define NS_FORWARD_NSIIPCBACKGROUNDCHILDCREATECALLBACK(_to) \
56 ActorCreated(mozilla::ipc::PBackgroundChild* aActor) MOZ_OVERRIDE \
57 { _to ActorCreated(aActor); } \
59 ActorFailed() MOZ_OVERRIDE \
60 { _to ActorFailed(); }
62 #define NS_FORWARD_SAFE_NSIIPCBACKGROUNDCHILDCREATECALLBACK(_to) \
64 ActorCreated(mozilla::ipc::PBackgroundChild* aActor) MOZ_OVERRIDE \
65 { if (_to) { _to->ActorCreated(aActor); } } \
67 ActorFailed() MOZ_OVERRIDE \
68 { if (_to) { _to->ActorFailed(); } }
70 #endif // mozilla_ipc_nsiipcbackgroundchildcreatecallback_h