author John Dai <>
Tue, 26 Mar 2019 15:19:56 +0000
changeset 466115 06a189e6b675149d77a254e6e4678c9c898d3158
parent 448966 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Bug 1523982 - Part 3: Don't raise an error in observe if creation of our actor was vetoed, r=nika Depends on D24204 Differential Revision:

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at */

#ifndef mozilla_dom_simpledb_SDBConnection_h
#define mozilla_dom_simpledb_SDBConnection_h

#include "nsAutoPtr.h"
#include "nsISDBConnection.h"
#include "nsTArray.h"


class nsISDBCloseCallback;

namespace mozilla {

namespace ipc {

class PBackgroundChild;
class PrincipalInfo;

}  // namespace ipc

namespace dom {

class SDBConnectionChild;
class SDBRequest;
class SDBRequestParams;

class SDBConnection final : public nsISDBConnection {
  typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
  typedef mozilla::ipc::PrincipalInfo PrincipalInfo;

  nsCOMPtr<nsISDBCloseCallback> mCloseCallback;

  nsAutoPtr<PrincipalInfo> mPrincipalInfo;

  SDBConnectionChild* mBackgroundActor;

  bool mRunningRequest;
  bool mOpen;
  bool mAllowedToClose;

  static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);

  void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(SDBConnection); }

  void ClearBackgroundActor();

  void OnNewRequest();

  void OnRequestFinished();

  void OnOpen();

  void OnClose(bool aAbnormal);

  void AllowToClose();



  nsresult CheckState();

  nsresult EnsureBackgroundActor();

  nsresult InitiateRequest(SDBRequest* aRequest,
                           const SDBRequestParams& aParams);


}  // namespace dom
}  // namespace mozilla

#endif /* mozilla_dom_simpledb_SDBConnection_h */