|
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/. */ |
|
4 |
|
5 #ifndef mozilla_ipc_nsiipcbackgroundchildcreatecallback_h |
|
6 #define mozilla_ipc_nsiipcbackgroundchildcreatecallback_h |
|
7 |
|
8 #include "mozilla/Attributes.h" |
|
9 #include "nsISupports.h" |
|
10 |
|
11 namespace mozilla { |
|
12 namespace ipc { |
|
13 |
|
14 class PBackgroundChild; |
|
15 |
|
16 } // namespace ipc |
|
17 } // namespace mozilla |
|
18 |
|
19 #define NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID \ |
|
20 {0x4de01707, 0x70e3, 0x4181, {0xbc, 0x9f, 0xa3, 0xec, 0xfe, 0x74, 0x1a, 0xe3}} |
|
21 |
|
22 class NS_NO_VTABLE nsIIPCBackgroundChildCreateCallback : public nsISupports |
|
23 { |
|
24 public: |
|
25 typedef mozilla::ipc::PBackgroundChild PBackgroundChild; |
|
26 |
|
27 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID) |
|
28 |
|
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 |
|
33 // same actor. |
|
34 virtual void |
|
35 ActorCreated(PBackgroundChild*) = 0; |
|
36 |
|
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. |
|
41 virtual void |
|
42 ActorFailed() = 0; |
|
43 }; |
|
44 |
|
45 NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCBackgroundChildCreateCallback, |
|
46 NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID) |
|
47 |
|
48 #define NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK \ |
|
49 virtual void \ |
|
50 ActorCreated(mozilla::ipc::PBackgroundChild*) MOZ_OVERRIDE; \ |
|
51 virtual void \ |
|
52 ActorFailed() MOZ_OVERRIDE; |
|
53 |
|
54 #define NS_FORWARD_NSIIPCBACKGROUNDCHILDCREATECALLBACK(_to) \ |
|
55 virtual void \ |
|
56 ActorCreated(mozilla::ipc::PBackgroundChild* aActor) MOZ_OVERRIDE \ |
|
57 { _to ActorCreated(aActor); } \ |
|
58 virtual void \ |
|
59 ActorFailed() MOZ_OVERRIDE \ |
|
60 { _to ActorFailed(); } |
|
61 |
|
62 #define NS_FORWARD_SAFE_NSIIPCBACKGROUNDCHILDCREATECALLBACK(_to) \ |
|
63 virtual void \ |
|
64 ActorCreated(mozilla::ipc::PBackgroundChild* aActor) MOZ_OVERRIDE \ |
|
65 { if (_to) { _to->ActorCreated(aActor); } } \ |
|
66 virtual void \ |
|
67 ActorFailed() MOZ_OVERRIDE \ |
|
68 { if (_to) { _to->ActorFailed(); } } |
|
69 |
|
70 #endif // mozilla_ipc_nsiipcbackgroundchildcreatecallback_h |