Bug 1655413 [wpt PR 24763] - Make CSP default-src without 'unsafe-eval' block eval...
[gecko.git] / dom / simpledb / SDBConnection.h
blobf5e7babe936cf4fd2560db811844927b4ea8ab11
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"
13 #include "nsTArray.h"
15 #define NS_SDBCONNECTION_CONTRACTID "@mozilla.org/dom/sdb-connection;1"
17 class nsISDBCloseCallback;
19 namespace mozilla {
21 namespace ipc {
23 class PBackgroundChild;
24 class PrincipalInfo;
26 } // namespace ipc
28 namespace dom {
30 class SDBConnectionChild;
31 class SDBRequest;
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;
46 bool mRunningRequest;
47 bool mOpen;
48 bool mAllowedToClose;
50 public:
51 static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
53 void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(SDBConnection); }
55 void ClearBackgroundActor();
57 void OnNewRequest();
59 void OnRequestFinished();
61 void OnOpen();
63 void OnClose(bool aAbnormal);
65 void AllowToClose();
67 private:
68 SDBConnection();
70 ~SDBConnection();
72 nsresult CheckState();
74 nsresult EnsureBackgroundActor();
76 nsresult InitiateRequest(SDBRequest* aRequest,
77 const SDBRequestParams& aParams);
79 NS_DECL_ISUPPORTS
80 NS_DECL_NSISDBCONNECTION
83 } // namespace dom
84 } // namespace mozilla
86 #endif /* mozilla_dom_simpledb_SDBConnection_h */