dom/indexedDB/ipc/IndexedDBChild.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef mozilla_dom_indexeddb_ipc_indexeddbchild_h__
     6 #define mozilla_dom_indexeddb_ipc_indexeddbchild_h__
     8 #include "mozilla/Attributes.h"
     9 #include "mozilla/DebugOnly.h"
    11 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
    13 #include "mozilla/dom/indexedDB/PIndexedDBChild.h"
    14 #include "mozilla/dom/indexedDB/PIndexedDBCursorChild.h"
    15 #include "mozilla/dom/indexedDB/PIndexedDBDatabaseChild.h"
    16 #include "mozilla/dom/indexedDB/PIndexedDBDeleteDatabaseRequestChild.h"
    17 #include "mozilla/dom/indexedDB/PIndexedDBIndexChild.h"
    18 #include "mozilla/dom/indexedDB/PIndexedDBObjectStoreChild.h"
    19 #include "mozilla/dom/indexedDB/PIndexedDBRequestChild.h"
    20 #include "mozilla/dom/indexedDB/PIndexedDBTransactionChild.h"
    22 BEGIN_INDEXEDDB_NAMESPACE
    24 class AsyncConnectionHelper;
    25 class IDBCursor;
    26 class IDBFactory;
    27 class IDBIndex;
    28 class IDBOpenDBRequest;
    29 class IDBRequest;
    30 class IDBTransactionListener;
    32 /*******************************************************************************
    33  * IndexedDBChild
    34  ******************************************************************************/
    36 class IndexedDBChild : public PIndexedDBChild
    37 {
    38   IDBFactory* mFactory;
    39   nsCString mASCIIOrigin;
    41 #ifdef DEBUG
    42   bool mDisconnected;
    43 #endif
    45 public:
    46   IndexedDBChild(const nsCString& aASCIIOrigin);
    47   virtual ~IndexedDBChild();
    49   const nsCString&
    50   ASCIIOrigin() const
    51   {
    52     return mASCIIOrigin;
    53   }
    55   void
    56   SetFactory(IDBFactory* aFactory);
    58   void
    59   Disconnect();
    61 protected:
    62   virtual void
    63   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
    65   virtual PIndexedDBDatabaseChild*
    66   AllocPIndexedDBDatabaseChild(const nsString& aName, const uint64_t& aVersion,
    67                                const PersistenceType& aPersistenceType)
    68                                MOZ_OVERRIDE;
    70   virtual bool
    71   DeallocPIndexedDBDatabaseChild(PIndexedDBDatabaseChild* aActor) MOZ_OVERRIDE;
    73   virtual PIndexedDBDeleteDatabaseRequestChild*
    74   AllocPIndexedDBDeleteDatabaseRequestChild(
    75                                         const nsString& aName,
    76                                         const PersistenceType& aPersistenceType)
    77                                         MOZ_OVERRIDE;
    79   virtual bool
    80   DeallocPIndexedDBDeleteDatabaseRequestChild(
    81                                    PIndexedDBDeleteDatabaseRequestChild* aActor)
    82                                    MOZ_OVERRIDE;
    83 };
    85 /*******************************************************************************
    86  * IndexedDBDatabaseChild
    87  ******************************************************************************/
    89 class IndexedDBDatabaseChild : public PIndexedDBDatabaseChild
    90 {
    91   IDBDatabase* mDatabase;
    92   nsString mName;
    93   uint64_t mVersion;
    95   nsRefPtr<IDBOpenDBRequest> mRequest;
    96   nsRefPtr<AsyncConnectionHelper> mOpenHelper;
    98   // Only used during version change transactions and blocked events.
    99   nsRefPtr<IDBDatabase> mStrongDatabase;
   101 public:
   102   IndexedDBDatabaseChild(const nsString& aName, uint64_t aVersion);
   103   virtual ~IndexedDBDatabaseChild();
   105   void
   106   SetRequest(IDBOpenDBRequest* aRequest);
   108   void
   109   Disconnect();
   111 protected:
   112   bool
   113   EnsureDatabase(IDBOpenDBRequest* aRequest,
   114                  const DatabaseInfoGuts& aDBInfo,
   115                  const InfallibleTArray<ObjectStoreInfoGuts>& aOSInfo);
   117   virtual void
   118   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   120   virtual bool
   121   RecvSuccess(const DatabaseInfoGuts& aDBInfo,
   122               const InfallibleTArray<ObjectStoreInfoGuts>& aOSInfo)
   123               MOZ_OVERRIDE;
   125   virtual bool
   126   RecvError(const nsresult& aRv) MOZ_OVERRIDE;
   128   virtual bool
   129   RecvBlocked(const uint64_t& aOldVersion) MOZ_OVERRIDE;
   131   virtual bool
   132   RecvVersionChange(const uint64_t& aOldVersion, const uint64_t& aNewVersion)
   133                     MOZ_OVERRIDE;
   135   virtual bool
   136   RecvInvalidate() MOZ_OVERRIDE;
   138   virtual bool
   139   RecvPIndexedDBTransactionConstructor(PIndexedDBTransactionChild* aActor,
   140                                        const TransactionParams& aParams)
   141                                        MOZ_OVERRIDE;
   143   virtual PIndexedDBTransactionChild*
   144   AllocPIndexedDBTransactionChild(const TransactionParams& aParams) MOZ_OVERRIDE;
   146   virtual bool
   147   DeallocPIndexedDBTransactionChild(PIndexedDBTransactionChild* aActor) MOZ_OVERRIDE;
   148 };
   150 /*******************************************************************************
   151  * IndexedDBTransactionChild
   152  ******************************************************************************/
   154 class IndexedDBTransactionChild : public PIndexedDBTransactionChild
   155 {
   156   IDBTransaction* mTransaction;
   158   nsRefPtr<IDBTransaction> mStrongTransaction;
   159   nsRefPtr<IDBTransactionListener> mTransactionListener;
   161 public:
   162   IndexedDBTransactionChild();
   163   virtual ~IndexedDBTransactionChild();
   165   void
   166   SetTransaction(IDBTransaction* aTransaction);
   168   IDBTransaction*
   169   GetTransaction() const
   170   {
   171     return mTransaction;
   172   }
   174   void
   175   Disconnect();
   177 protected:
   178   void
   179   FireCompleteEvent(nsresult aRv);
   181   virtual void
   182   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   184   virtual bool
   185   RecvComplete(const CompleteParams& aParams) MOZ_OVERRIDE;
   187   virtual PIndexedDBObjectStoreChild*
   188   AllocPIndexedDBObjectStoreChild(const ObjectStoreConstructorParams& aParams)
   189                                   MOZ_OVERRIDE;
   191   virtual bool
   192   DeallocPIndexedDBObjectStoreChild(PIndexedDBObjectStoreChild* aActor) MOZ_OVERRIDE;
   193 };
   195 /*******************************************************************************
   196  * IndexedDBObjectStoreChild
   197  ******************************************************************************/
   199 class IndexedDBObjectStoreChild : public PIndexedDBObjectStoreChild
   200 {
   201   IDBObjectStore* mObjectStore;
   203 public:
   204   IndexedDBObjectStoreChild(IDBObjectStore* aObjectStore);
   205   virtual ~IndexedDBObjectStoreChild();
   207   void
   208   Disconnect();
   210 protected:
   211   virtual void
   212   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   214   virtual bool
   215   RecvPIndexedDBCursorConstructor(
   216                               PIndexedDBCursorChild* aActor,
   217                               const ObjectStoreCursorConstructorParams& aParams)
   218                               MOZ_OVERRIDE;
   220   virtual PIndexedDBRequestChild*
   221   AllocPIndexedDBRequestChild(const ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
   223   virtual bool
   224   DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
   226   virtual PIndexedDBIndexChild*
   227   AllocPIndexedDBIndexChild(const IndexConstructorParams& aParams) MOZ_OVERRIDE;
   229   virtual bool
   230   DeallocPIndexedDBIndexChild(PIndexedDBIndexChild* aActor) MOZ_OVERRIDE;
   232   virtual PIndexedDBCursorChild*
   233   AllocPIndexedDBCursorChild(const ObjectStoreCursorConstructorParams& aParams)
   234                              MOZ_OVERRIDE;
   236   virtual bool
   237   DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE;
   238 };
   240 /*******************************************************************************
   241  * IndexedDBIndexChild
   242  ******************************************************************************/
   244 class IndexedDBIndexChild : public PIndexedDBIndexChild
   245 {
   246   IDBIndex* mIndex;
   248 public:
   249   IndexedDBIndexChild(IDBIndex* aIndex);
   250   virtual ~IndexedDBIndexChild();
   252   void
   253   Disconnect();
   255 protected:
   256   virtual void
   257   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   259   virtual bool
   260   RecvPIndexedDBCursorConstructor(PIndexedDBCursorChild* aActor,
   261                                   const IndexCursorConstructorParams& aParams)
   262                                   MOZ_OVERRIDE;
   264   virtual PIndexedDBRequestChild*
   265   AllocPIndexedDBRequestChild(const IndexRequestParams& aParams) MOZ_OVERRIDE;
   267   virtual bool
   268   DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
   270   virtual PIndexedDBCursorChild*
   271   AllocPIndexedDBCursorChild(const IndexCursorConstructorParams& aParams)
   272                              MOZ_OVERRIDE;
   274   virtual bool
   275   DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE;
   276 };
   278 /*******************************************************************************
   279  * IndexedDBCursorChild
   280  ******************************************************************************/
   282 class IndexedDBCursorChild : public PIndexedDBCursorChild
   283 {
   284   IDBCursor* mCursor;
   286   nsRefPtr<IDBCursor> mStrongCursor;
   288 public:
   289   IndexedDBCursorChild();
   290   virtual ~IndexedDBCursorChild();
   292   void
   293   SetCursor(IDBCursor* aCursor);
   295   already_AddRefed<IDBCursor>
   296   ForgetStrongCursor()
   297   {
   298     return mStrongCursor.forget();
   299   }
   301   void
   302   Disconnect();
   304 protected:
   305   virtual void
   306   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   308   virtual PIndexedDBRequestChild*
   309   AllocPIndexedDBRequestChild(const CursorRequestParams& aParams) MOZ_OVERRIDE;
   311   virtual bool
   312   DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
   313 };
   315 /*******************************************************************************
   316  * IndexedDBRequestChildBase
   317  ******************************************************************************/
   319 class IndexedDBRequestChildBase : public PIndexedDBRequestChild
   320 {
   321 protected:
   322   nsRefPtr<AsyncConnectionHelper> mHelper;
   324 public:
   325   IDBRequest*
   326   GetRequest() const;
   328   void
   329   Disconnect();
   331 protected:
   332   IndexedDBRequestChildBase(AsyncConnectionHelper* aHelper);
   333   virtual ~IndexedDBRequestChildBase();
   335   virtual bool
   336   Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   337 };
   339 /*******************************************************************************
   340  * IndexedDBObjectStoreRequestChild
   341  ******************************************************************************/
   343 class IndexedDBObjectStoreRequestChild : public IndexedDBRequestChildBase
   344 {
   345   nsRefPtr<IDBObjectStore> mObjectStore;
   347   typedef ipc::ObjectStoreRequestParams ParamsUnionType;
   348   typedef ParamsUnionType::Type RequestType;
   349   DebugOnly<RequestType> mRequestType;
   351 public:
   352   IndexedDBObjectStoreRequestChild(AsyncConnectionHelper* aHelper,
   353                                    IDBObjectStore* aObjectStore,
   354                                    RequestType aRequestType);
   355   virtual ~IndexedDBObjectStoreRequestChild();
   357 protected:
   358   virtual bool
   359   Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   360 };
   362 /*******************************************************************************
   363  * IndexedDBIndexRequestChild
   364  ******************************************************************************/
   366 class IndexedDBIndexRequestChild : public IndexedDBRequestChildBase
   367 {
   368   nsRefPtr<IDBIndex> mIndex;
   370   typedef ipc::IndexRequestParams ParamsUnionType;
   371   typedef ParamsUnionType::Type RequestType;
   372   DebugOnly<RequestType> mRequestType;
   374 public:
   375   IndexedDBIndexRequestChild(AsyncConnectionHelper* aHelper, IDBIndex* aIndex,
   376                              RequestType aRequestType);
   377   virtual ~IndexedDBIndexRequestChild();
   379 protected:
   380   virtual bool
   381   Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   382 };
   384 /*******************************************************************************
   385  * IndexedDBCursorRequestChild
   386  ******************************************************************************/
   388 class IndexedDBCursorRequestChild : public IndexedDBRequestChildBase
   389 {
   390   nsRefPtr<IDBCursor> mCursor;
   392   typedef ipc::CursorRequestParams ParamsUnionType;
   393   typedef ParamsUnionType::Type RequestType;
   394   DebugOnly<RequestType> mRequestType;
   396 public:
   397   IndexedDBCursorRequestChild(AsyncConnectionHelper* aHelper,
   398                               IDBCursor* aCursor,
   399                               RequestType aRequestType);
   400   virtual ~IndexedDBCursorRequestChild();
   402 protected:
   403   virtual bool
   404   Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   405 };
   407 /*******************************************************************************
   408  * IndexedDBDeleteDatabaseRequestChild
   409  ******************************************************************************/
   411 class IndexedDBDeleteDatabaseRequestChild :
   412   public PIndexedDBDeleteDatabaseRequestChild
   413 {
   414   nsRefPtr<IDBFactory> mFactory;
   415   nsRefPtr<IDBOpenDBRequest> mOpenRequest;
   416   nsCString mDatabaseId;
   418 public:
   419   IndexedDBDeleteDatabaseRequestChild(IDBFactory* aFactory,
   420                                       IDBOpenDBRequest* aOpenRequest,
   421                                       const nsACString& aDatabaseId);
   422   virtual ~IndexedDBDeleteDatabaseRequestChild();
   424 protected:
   425   virtual bool
   426   Recv__delete__(const nsresult& aRv) MOZ_OVERRIDE;
   428   virtual bool
   429   RecvBlocked(const uint64_t& aCurrentVersion) MOZ_OVERRIDE;
   430 };
   432 END_INDEXEDDB_NAMESPACE
   434 #endif // mozilla_dom_indexeddb_ipc_indexeddbchild_h__

mercurial