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
10 #include "mozilla/dom/quota/PersistenceType.h"
11 #include "mozilla/UniquePtr.h"
12 #include "nsISDBConnection.h"
15 #define NS_SDBCONNECTION_CONTRACTID "@mozilla.org/dom/sdb-connection;1"
17 class nsISDBCloseCallback
;
23 class PBackgroundChild
;
30 class SDBConnectionChild
;
32 class SDBRequestParams
;
34 class SDBConnection final
: public nsISDBConnection
{
35 typedef mozilla::dom::quota::PersistenceType PersistenceType
;
36 typedef mozilla::ipc::PBackgroundChild PBackgroundChild
;
37 typedef mozilla::ipc::PrincipalInfo PrincipalInfo
;
39 nsCOMPtr
<nsISDBCloseCallback
> mCloseCallback
;
41 UniquePtr
<PrincipalInfo
> mPrincipalInfo
;
43 SDBConnectionChild
* mBackgroundActor
;
45 PersistenceType mPersistenceType
;
51 static nsresult
Create(nsISupports
* aOuter
, REFNSIID aIID
, void** aResult
);
53 void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(SDBConnection
); }
55 void ClearBackgroundActor();
59 void OnRequestFinished();
63 void OnClose(bool aAbnormal
);
72 nsresult
CheckState();
74 nsresult
EnsureBackgroundActor();
76 nsresult
InitiateRequest(SDBRequest
* aRequest
,
77 const SDBRequestParams
& aParams
);
80 NS_DECL_NSISDBCONNECTION
84 } // namespace mozilla
86 #endif /* mozilla_dom_simpledb_SDBConnection_h */