Bug 1732409 let fake:true getUserMedia() parameter override loopback prefs r=jib
[gecko.git] / dom / simpledb / SDBConnection.h
blobe29b288eb80a6d09b33275371773c2887b0bcf01
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 <cstdint>
11 #include "ErrorList.h"
12 #include "mozilla/UniquePtr.h"
13 #include "mozilla/dom/quota/PersistenceType.h"
14 #include "nsCOMPtr.h"
15 #include "nsID.h"
16 #include "nsISDBConnection.h"
17 #include "nsISupports.h"
19 #define NS_SDBCONNECTION_CONTRACTID "@mozilla.org/dom/sdb-connection;1"
21 class nsISDBCloseCallback;
23 namespace mozilla {
25 namespace ipc {
27 class PBackgroundChild;
28 class PrincipalInfo;
30 } // namespace ipc
32 namespace dom {
34 class SDBConnectionChild;
35 class SDBRequest;
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;
50 bool mRunningRequest;
51 bool mOpen;
52 bool mAllowedToClose;
54 public:
55 static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
57 void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(SDBConnection); }
59 void ClearBackgroundActor();
61 void OnNewRequest();
63 void OnRequestFinished();
65 void OnOpen();
67 void OnClose(bool aAbnormal);
69 void AllowToClose();
71 private:
72 SDBConnection();
74 ~SDBConnection();
76 nsresult CheckState();
78 nsresult EnsureBackgroundActor();
80 nsresult InitiateRequest(SDBRequest* aRequest,
81 const SDBRequestParams& aParams);
83 NS_DECL_ISUPPORTS
84 NS_DECL_NSISDBCONNECTION
87 } // namespace dom
88 } // namespace mozilla
90 #endif /* mozilla_dom_simpledb_SDBConnection_h */