michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_indexeddb_ipc_indexeddbchild_h__ michael@0: #define mozilla_dom_indexeddb_ipc_indexeddbchild_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/DebugOnly.h" michael@0: michael@0: #include "mozilla/dom/indexedDB/IndexedDatabase.h" michael@0: michael@0: #include "mozilla/dom/indexedDB/PIndexedDBChild.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBCursorChild.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBDatabaseChild.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBDeleteDatabaseRequestChild.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBIndexChild.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBObjectStoreChild.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBRequestChild.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBTransactionChild.h" michael@0: michael@0: BEGIN_INDEXEDDB_NAMESPACE michael@0: michael@0: class AsyncConnectionHelper; michael@0: class IDBCursor; michael@0: class IDBFactory; michael@0: class IDBIndex; michael@0: class IDBOpenDBRequest; michael@0: class IDBRequest; michael@0: class IDBTransactionListener; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBChild : public PIndexedDBChild michael@0: { michael@0: IDBFactory* mFactory; michael@0: nsCString mASCIIOrigin; michael@0: michael@0: #ifdef DEBUG michael@0: bool mDisconnected; michael@0: #endif michael@0: michael@0: public: michael@0: IndexedDBChild(const nsCString& aASCIIOrigin); michael@0: virtual ~IndexedDBChild(); michael@0: michael@0: const nsCString& michael@0: ASCIIOrigin() const michael@0: { michael@0: return mASCIIOrigin; michael@0: } michael@0: michael@0: void michael@0: SetFactory(IDBFactory* aFactory); michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: protected: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBDatabaseChild* michael@0: AllocPIndexedDBDatabaseChild(const nsString& aName, const uint64_t& aVersion, michael@0: const PersistenceType& aPersistenceType) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBDatabaseChild(PIndexedDBDatabaseChild* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBDeleteDatabaseRequestChild* michael@0: AllocPIndexedDBDeleteDatabaseRequestChild( michael@0: const nsString& aName, michael@0: const PersistenceType& aPersistenceType) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBDeleteDatabaseRequestChild( michael@0: PIndexedDBDeleteDatabaseRequestChild* aActor) michael@0: MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBDatabaseChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBDatabaseChild : public PIndexedDBDatabaseChild michael@0: { michael@0: IDBDatabase* mDatabase; michael@0: nsString mName; michael@0: uint64_t mVersion; michael@0: michael@0: nsRefPtr mRequest; michael@0: nsRefPtr mOpenHelper; michael@0: michael@0: // Only used during version change transactions and blocked events. michael@0: nsRefPtr mStrongDatabase; michael@0: michael@0: public: michael@0: IndexedDBDatabaseChild(const nsString& aName, uint64_t aVersion); michael@0: virtual ~IndexedDBDatabaseChild(); michael@0: michael@0: void michael@0: SetRequest(IDBOpenDBRequest* aRequest); michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: protected: michael@0: bool michael@0: EnsureDatabase(IDBOpenDBRequest* aRequest, michael@0: const DatabaseInfoGuts& aDBInfo, michael@0: const InfallibleTArray& aOSInfo); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvSuccess(const DatabaseInfoGuts& aDBInfo, michael@0: const InfallibleTArray& aOSInfo) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvError(const nsresult& aRv) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvBlocked(const uint64_t& aOldVersion) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvVersionChange(const uint64_t& aOldVersion, const uint64_t& aNewVersion) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvInvalidate() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBTransactionConstructor(PIndexedDBTransactionChild* aActor, michael@0: const TransactionParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBTransactionChild* michael@0: AllocPIndexedDBTransactionChild(const TransactionParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBTransactionChild(PIndexedDBTransactionChild* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBTransactionChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBTransactionChild : public PIndexedDBTransactionChild michael@0: { michael@0: IDBTransaction* mTransaction; michael@0: michael@0: nsRefPtr mStrongTransaction; michael@0: nsRefPtr mTransactionListener; michael@0: michael@0: public: michael@0: IndexedDBTransactionChild(); michael@0: virtual ~IndexedDBTransactionChild(); michael@0: michael@0: void michael@0: SetTransaction(IDBTransaction* aTransaction); michael@0: michael@0: IDBTransaction* michael@0: GetTransaction() const michael@0: { michael@0: return mTransaction; michael@0: } michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: protected: michael@0: void michael@0: FireCompleteEvent(nsresult aRv); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvComplete(const CompleteParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBObjectStoreChild* michael@0: AllocPIndexedDBObjectStoreChild(const ObjectStoreConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBObjectStoreChild(PIndexedDBObjectStoreChild* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBObjectStoreChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBObjectStoreChild : public PIndexedDBObjectStoreChild michael@0: { michael@0: IDBObjectStore* mObjectStore; michael@0: michael@0: public: michael@0: IndexedDBObjectStoreChild(IDBObjectStore* aObjectStore); michael@0: virtual ~IndexedDBObjectStoreChild(); michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: protected: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBCursorConstructor( michael@0: PIndexedDBCursorChild* aActor, michael@0: const ObjectStoreCursorConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBRequestChild* michael@0: AllocPIndexedDBRequestChild(const ObjectStoreRequestParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBIndexChild* michael@0: AllocPIndexedDBIndexChild(const IndexConstructorParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBIndexChild(PIndexedDBIndexChild* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBCursorChild* michael@0: AllocPIndexedDBCursorChild(const ObjectStoreCursorConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBIndexChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBIndexChild : public PIndexedDBIndexChild michael@0: { michael@0: IDBIndex* mIndex; michael@0: michael@0: public: michael@0: IndexedDBIndexChild(IDBIndex* aIndex); michael@0: virtual ~IndexedDBIndexChild(); michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: protected: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBCursorConstructor(PIndexedDBCursorChild* aActor, michael@0: const IndexCursorConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBRequestChild* michael@0: AllocPIndexedDBRequestChild(const IndexRequestParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBCursorChild* michael@0: AllocPIndexedDBCursorChild(const IndexCursorConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBCursorChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBCursorChild : public PIndexedDBCursorChild michael@0: { michael@0: IDBCursor* mCursor; michael@0: michael@0: nsRefPtr mStrongCursor; michael@0: michael@0: public: michael@0: IndexedDBCursorChild(); michael@0: virtual ~IndexedDBCursorChild(); michael@0: michael@0: void michael@0: SetCursor(IDBCursor* aCursor); michael@0: michael@0: already_AddRefed michael@0: ForgetStrongCursor() michael@0: { michael@0: return mStrongCursor.forget(); michael@0: } michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: protected: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBRequestChild* michael@0: AllocPIndexedDBRequestChild(const CursorRequestParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBRequestChildBase michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBRequestChildBase : public PIndexedDBRequestChild michael@0: { michael@0: protected: michael@0: nsRefPtr mHelper; michael@0: michael@0: public: michael@0: IDBRequest* michael@0: GetRequest() const; michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: protected: michael@0: IndexedDBRequestChildBase(AsyncConnectionHelper* aHelper); michael@0: virtual ~IndexedDBRequestChildBase(); michael@0: michael@0: virtual bool michael@0: Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBObjectStoreRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBObjectStoreRequestChild : public IndexedDBRequestChildBase michael@0: { michael@0: nsRefPtr mObjectStore; michael@0: michael@0: typedef ipc::ObjectStoreRequestParams ParamsUnionType; michael@0: typedef ParamsUnionType::Type RequestType; michael@0: DebugOnly mRequestType; michael@0: michael@0: public: michael@0: IndexedDBObjectStoreRequestChild(AsyncConnectionHelper* aHelper, michael@0: IDBObjectStore* aObjectStore, michael@0: RequestType aRequestType); michael@0: virtual ~IndexedDBObjectStoreRequestChild(); michael@0: michael@0: protected: michael@0: virtual bool michael@0: Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBIndexRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBIndexRequestChild : public IndexedDBRequestChildBase michael@0: { michael@0: nsRefPtr mIndex; michael@0: michael@0: typedef ipc::IndexRequestParams ParamsUnionType; michael@0: typedef ParamsUnionType::Type RequestType; michael@0: DebugOnly mRequestType; michael@0: michael@0: public: michael@0: IndexedDBIndexRequestChild(AsyncConnectionHelper* aHelper, IDBIndex* aIndex, michael@0: RequestType aRequestType); michael@0: virtual ~IndexedDBIndexRequestChild(); michael@0: michael@0: protected: michael@0: virtual bool michael@0: Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBCursorRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBCursorRequestChild : public IndexedDBRequestChildBase michael@0: { michael@0: nsRefPtr mCursor; michael@0: michael@0: typedef ipc::CursorRequestParams ParamsUnionType; michael@0: typedef ParamsUnionType::Type RequestType; michael@0: DebugOnly mRequestType; michael@0: michael@0: public: michael@0: IndexedDBCursorRequestChild(AsyncConnectionHelper* aHelper, michael@0: IDBCursor* aCursor, michael@0: RequestType aRequestType); michael@0: virtual ~IndexedDBCursorRequestChild(); michael@0: michael@0: protected: michael@0: virtual bool michael@0: Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBDeleteDatabaseRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBDeleteDatabaseRequestChild : michael@0: public PIndexedDBDeleteDatabaseRequestChild michael@0: { michael@0: nsRefPtr mFactory; michael@0: nsRefPtr mOpenRequest; michael@0: nsCString mDatabaseId; michael@0: michael@0: public: michael@0: IndexedDBDeleteDatabaseRequestChild(IDBFactory* aFactory, michael@0: IDBOpenDBRequest* aOpenRequest, michael@0: const nsACString& aDatabaseId); michael@0: virtual ~IndexedDBDeleteDatabaseRequestChild(); michael@0: michael@0: protected: michael@0: virtual bool michael@0: Recv__delete__(const nsresult& aRv) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvBlocked(const uint64_t& aCurrentVersion) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: END_INDEXEDDB_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_indexeddb_ipc_indexeddbchild_h__