Bug 1874684 - Part 4: Prefer const references instead of copying Instant values....
[gecko.git] / dom / simpledb / ActorsChild.h
blob36a5cdef33e6a7e485f1dd9a179a4cd435eebdea
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
10 #include <cstdint>
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"
19 namespace mozilla {
20 namespace ipc {
22 class BackgroundChildImpl;
24 } // namespace ipc
26 namespace dom {
28 class SDBConnection;
29 class SDBRequest;
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)
39 public:
40 void AssertIsOnOwningThread() const {
41 NS_ASSERT_OWNINGTHREAD(SDBConnectionChild);
44 private:
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;
73 public:
74 void AssertIsOnOwningThread() const
75 #ifdef DEBUG
77 #else
80 #endif
82 private:
83 // Only created by SDBConnection.
84 explicit SDBRequestChild(SDBRequest* aRequest);
86 // Only destroyed by SDBConnectionChild.
87 ~SDBRequestChild();
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;
102 } // namespace dom
103 } // namespace mozilla
105 #endif // mozilla_dom_simpledb_ActorsChild_h