Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_ipc_nsiipcbackgroundchildcreatecallback_h
8 : #define mozilla_ipc_nsiipcbackgroundchildcreatecallback_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsISupports.h"
12 :
13 : namespace mozilla {
14 : namespace ipc {
15 :
16 : class PBackgroundChild;
17 :
18 : } // namespace ipc
19 : } // namespace mozilla
20 :
21 : #define NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID \
22 : {0x4de01707, 0x70e3, 0x4181, {0xbc, 0x9f, 0xa3, 0xec, 0xfe, 0x74, 0x1a, 0xe3}}
23 :
24 10 : class NS_NO_VTABLE nsIIPCBackgroundChildCreateCallback : public nsISupports
25 : {
26 : public:
27 : typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
28 :
29 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID)
30 :
31 : // This will be called upon successful creation of a PBackgroundChild actor.
32 : // The actor is unique per-thread and must not be shared across threads. It
33 : // may be saved and reused on the same thread for as long as the thread lives.
34 : // After this callback BackgroundChild::GetForCurrentThread() will return the
35 : // same actor.
36 : virtual void
37 : ActorCreated(PBackgroundChild*) = 0;
38 :
39 : // This will be called if for some reason the PBackgroundChild actor cannot be
40 : // created. This should never be called in child processes as the failure to
41 : // create the actor should result in the termination of the child process
42 : // first. This may be called for cross-thread actors in the main process.
43 : virtual void
44 : ActorFailed() = 0;
45 : };
46 :
47 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCBackgroundChildCreateCallback,
48 : NS_IIPCBACKGROUNDCHILDCREATECALLBACK_IID)
49 :
50 : #define NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK \
51 : virtual void \
52 : ActorCreated(mozilla::ipc::PBackgroundChild*) override; \
53 : virtual void \
54 : ActorFailed() override;
55 :
56 : #define NS_FORWARD_NSIIPCBACKGROUNDCHILDCREATECALLBACK(_to) \
57 : virtual void \
58 : ActorCreated(mozilla::ipc::PBackgroundChild* aActor) override \
59 : { _to ActorCreated(aActor); } \
60 : virtual void \
61 : ActorFailed() override \
62 : { _to ActorFailed(); }
63 :
64 : #define NS_FORWARD_SAFE_NSIIPCBACKGROUNDCHILDCREATECALLBACK(_to) \
65 : virtual void \
66 : ActorCreated(mozilla::ipc::PBackgroundChild* aActor) override \
67 : { if (_to) { _to->ActorCreated(aActor); } } \
68 : virtual void \
69 : ActorFailed() override \
70 : { if (_to) { _to->ActorFailed(); } }
71 :
72 : #endif // mozilla_ipc_nsiipcbackgroundchildcreatecallback_h
|