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/. */
7 #ifndef mozilla_dom_simpledb_ActorsChild_h
8 #define mozilla_dom_simpledb_ActorsChild_h
11 #include "ErrorList.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/dom/PBackgroundSDBConnectionChild.h"
14 #include "mozilla/dom/PBackgroundSDBRequestChild.h"
15 #include "mozilla/ipc/ProtocolUtils.h"
16 #include "nsISupports.h"
17 #include "nsStringFwd.h"
22 class BackgroundChildImpl
;
31 class SDBConnectionChild final
: public PBackgroundSDBConnectionChild
{
32 friend class mozilla::ipc::BackgroundChildImpl
;
33 friend class SDBConnection
;
35 SDBConnection
* mConnection
;
37 NS_INLINE_DECL_REFCOUNTING(SDBConnectionChild
, override
)
40 void AssertIsOnOwningThread() const {
41 NS_ASSERT_OWNINGTHREAD(SDBConnectionChild
);
45 // Only created by SDBConnection.
46 explicit SDBConnectionChild(SDBConnection
* aConnection
);
48 ~SDBConnectionChild();
50 void SendDeleteMeInternal();
52 // IPDL methods are only called by IPDL.
53 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
55 virtual PBackgroundSDBRequestChild
* AllocPBackgroundSDBRequestChild(
56 const SDBRequestParams
& aParams
) override
;
58 virtual bool DeallocPBackgroundSDBRequestChild(
59 PBackgroundSDBRequestChild
* aActor
) override
;
61 virtual mozilla::ipc::IPCResult
RecvAllowToClose() override
;
63 virtual mozilla::ipc::IPCResult
RecvClosed() override
;
66 class SDBRequestChild final
: public PBackgroundSDBRequestChild
{
67 friend class SDBConnectionChild
;
68 friend class SDBConnection
;
70 RefPtr
<SDBConnection
> mConnection
;
71 RefPtr
<SDBRequest
> mRequest
;
74 void AssertIsOnOwningThread() const
83 // Only created by SDBConnection.
84 explicit SDBRequestChild(SDBRequest
* aRequest
);
86 // Only destroyed by SDBConnectionChild.
89 void HandleResponse(nsresult aResponse
);
91 void HandleResponse();
93 void HandleResponse(const nsCString
& aResponse
);
95 // IPDL methods are only called by IPDL.
96 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
98 virtual mozilla::ipc::IPCResult
Recv__delete__(
99 const SDBRequestResponse
& aResponse
) override
;
103 } // namespace mozilla
105 #endif // mozilla_dom_simpledb_ActorsChild_h