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_SDBConnection_h
8 #define mozilla_dom_simpledb_SDBConnection_h
11 #include "ErrorList.h"
12 #include "mozilla/UniquePtr.h"
13 #include "mozilla/dom/quota/PersistenceType.h"
16 #include "nsISDBConnection.h"
17 #include "nsISupports.h"
19 #define NS_SDBCONNECTION_CONTRACTID "@mozilla.org/dom/sdb-connection;1"
21 class nsISDBCloseCallback
;
27 class PBackgroundChild
;
34 class SDBConnectionChild
;
36 class SDBRequestParams
;
38 class SDBConnection final
: public nsISDBConnection
{
39 using PersistenceType
= mozilla::dom::quota::PersistenceType
;
40 using PBackgroundChild
= mozilla::ipc::PBackgroundChild
;
41 using PrincipalInfo
= mozilla::ipc::PrincipalInfo
;
43 nsCOMPtr
<nsISDBCloseCallback
> mCloseCallback
;
45 UniquePtr
<PrincipalInfo
> mPrincipalInfo
;
47 SDBConnectionChild
* mBackgroundActor
;
49 PersistenceType mPersistenceType
;
55 static nsresult
Create(REFNSIID aIID
, void** aResult
);
57 void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(SDBConnection
); }
59 void ClearBackgroundActor();
63 void OnRequestFinished();
67 void OnClose(bool aAbnormal
);
76 nsresult
CheckState();
78 nsresult
EnsureBackgroundActor();
80 nsresult
InitiateRequest(SDBRequest
* aRequest
,
81 const SDBRequestParams
& aParams
);
84 NS_DECL_NSISDBCONNECTION
88 } // namespace mozilla
90 #endif /* mozilla_dom_simpledb_SDBConnection_h */