tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SDBConnection.h (2085B)


      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/. */
      6 
      7 #ifndef mozilla_dom_simpledb_SDBConnection_h
      8 #define mozilla_dom_simpledb_SDBConnection_h
      9 
     10 #include "ErrorList.h"
     11 #include "mozilla/UniquePtr.h"
     12 #include "mozilla/dom/quota/PersistenceType.h"
     13 #include "nsCOMPtr.h"
     14 #include "nsID.h"
     15 #include "nsISDBConnection.h"
     16 #include "nsISupports.h"
     17 
     18 #define NS_SDBCONNECTION_CONTRACTID "@mozilla.org/dom/sdb-connection;1"
     19 
     20 class nsISDBCloseCallback;
     21 
     22 namespace mozilla {
     23 
     24 namespace ipc {
     25 
     26 class PBackgroundChild;
     27 class PrincipalInfo;
     28 
     29 }  // namespace ipc
     30 
     31 namespace dom {
     32 
     33 class SDBConnectionChild;
     34 class SDBRequest;
     35 class SDBRequestParams;
     36 
     37 class SDBConnection final : public nsISDBConnection {
     38  using PersistenceType = mozilla::dom::quota::PersistenceType;
     39  using PBackgroundChild = mozilla::ipc::PBackgroundChild;
     40  using PrincipalInfo = mozilla::ipc::PrincipalInfo;
     41 
     42  nsCOMPtr<nsISDBCloseCallback> mCloseCallback;
     43 
     44  UniquePtr<PrincipalInfo> mPrincipalInfo;
     45 
     46  SDBConnectionChild* mBackgroundActor;
     47 
     48  PersistenceType mPersistenceType;
     49  bool mRunningRequest;
     50  bool mOpen;
     51  bool mAllowedToClose;
     52 
     53 public:
     54  static nsresult Create(REFNSIID aIID, void** aResult);
     55 
     56  void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(SDBConnection); }
     57 
     58  void ClearBackgroundActor();
     59 
     60  void OnNewRequest();
     61 
     62  void OnRequestFinished();
     63 
     64  void OnOpen();
     65 
     66  void OnClose(bool aAbnormal);
     67 
     68  bool IsAllowedToClose() const;
     69 
     70  void AllowToClose();
     71 
     72 private:
     73  SDBConnection();
     74 
     75  ~SDBConnection();
     76 
     77  nsresult CheckState();
     78 
     79  nsresult EnsureBackgroundActor();
     80 
     81  nsresult InitiateRequest(SDBRequest* aRequest,
     82                           const SDBRequestParams& aParams);
     83 
     84  NS_DECL_ISUPPORTS
     85  NS_DECL_NSISDBCONNECTION
     86 };
     87 
     88 }  // namespace dom
     89 }  // namespace mozilla
     90 
     91 #endif /* mozilla_dom_simpledb_SDBConnection_h */