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_indexeddbparent_h__ michael@0: #define mozilla_dom_indexeddb_ipc_indexeddbparent_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/PIndexedDBParent.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBCursorParent.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBDatabaseParent.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBDeleteDatabaseRequestParent.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBIndexParent.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBObjectStoreParent.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBRequestParent.h" michael@0: #include "mozilla/dom/indexedDB/PIndexedDBTransactionParent.h" michael@0: michael@0: #include "nsIDOMEventListener.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: class ContentParent; michael@0: class PBlobParent; michael@0: class TabParent; michael@0: } michael@0: } michael@0: michael@0: class nsIDOMBlob; michael@0: class nsIDOMEvent; michael@0: michael@0: BEGIN_INDEXEDDB_NAMESPACE michael@0: michael@0: class IDBCursor; michael@0: class IDBDatabase; michael@0: class IDBFactory; michael@0: class IDBIndex; michael@0: class IDBObjectStore; michael@0: class IDBOpenDBRequest; michael@0: class IDBTransaction; michael@0: michael@0: class IndexedDBCursorParent; michael@0: class IndexedDBDatabaseParent; michael@0: class IndexedDBDeleteDatabaseRequestParent; michael@0: class IndexedDBIndexParent; michael@0: class IndexedDBObjectStoreParent; michael@0: class IndexedDBTransactionParent; michael@0: class IndexedDBVersionChangeTransactionParent; michael@0: class IndexedDBVersionChangeObjectStoreParent; michael@0: michael@0: /******************************************************************************* michael@0: * AutoSetCurrentTransaction michael@0: ******************************************************************************/ michael@0: michael@0: class AutoSetCurrentTransaction michael@0: { michael@0: public: michael@0: AutoSetCurrentTransaction(IDBTransaction* aTransaction); michael@0: ~AutoSetCurrentTransaction(); michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * WeakEventListener michael@0: ******************************************************************************/ michael@0: michael@0: class WeakEventListenerBase : public nsIDOMEventListener michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIDOMEVENTLISTENER michael@0: michael@0: protected: michael@0: WeakEventListenerBase() michael@0: { } michael@0: michael@0: virtual ~WeakEventListenerBase() michael@0: { } michael@0: }; michael@0: michael@0: template michael@0: class WeakEventListener : public WeakEventListenerBase michael@0: { michael@0: T* mActor; michael@0: michael@0: public: michael@0: WeakEventListener(T* aActor) michael@0: : mActor(aActor) michael@0: { } michael@0: michael@0: void michael@0: NoteDyingActor() michael@0: { michael@0: mActor = nullptr; michael@0: } michael@0: michael@0: NS_IMETHOD michael@0: HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE michael@0: { michael@0: return mActor ? mActor->HandleEvent(aEvent) : NS_OK; michael@0: } michael@0: michael@0: protected: michael@0: virtual ~WeakEventListener() michael@0: { } michael@0: }; michael@0: michael@0: template michael@0: class AutoWeakEventListener michael@0: { michael@0: nsRefPtr > mEventListener; michael@0: michael@0: public: michael@0: AutoWeakEventListener(T* aActor) michael@0: { michael@0: mEventListener = new WeakEventListener(aActor); michael@0: } michael@0: michael@0: ~AutoWeakEventListener() michael@0: { michael@0: mEventListener->NoteDyingActor(); michael@0: } michael@0: michael@0: template michael@0: operator U*() michael@0: { michael@0: return mEventListener; michael@0: } michael@0: michael@0: T* michael@0: operator ->() michael@0: { michael@0: return mEventListener; michael@0: } michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBParent : private PIndexedDBParent michael@0: { michael@0: friend class mozilla::dom::ContentParent; michael@0: friend class mozilla::dom::TabParent; michael@0: friend class IndexedDBDatabaseParent; michael@0: friend class IndexedDBDeleteDatabaseRequestParent; michael@0: michael@0: nsRefPtr mFactory; michael@0: nsCString mASCIIOrigin; michael@0: michael@0: ContentParent* mManagerContent; michael@0: TabParent* mManagerTab; michael@0: michael@0: bool mDisconnected; michael@0: michael@0: public: michael@0: IndexedDBParent(ContentParent* aContentParent); michael@0: IndexedDBParent(TabParent* aTabParent); michael@0: michael@0: virtual ~IndexedDBParent(); michael@0: michael@0: const nsCString& michael@0: GetASCIIOrigin() const michael@0: { michael@0: return mASCIIOrigin; michael@0: } michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: return mDisconnected; michael@0: } michael@0: michael@0: ContentParent* michael@0: GetManagerContent() const michael@0: { michael@0: return mManagerContent; michael@0: } michael@0: michael@0: TabParent* michael@0: GetManagerTab() const michael@0: { michael@0: return mManagerTab; michael@0: } michael@0: michael@0: bool michael@0: CheckReadPermission(const nsAString& aDatabaseName); michael@0: michael@0: bool michael@0: CheckWritePermission(const nsAString& aDatabaseName); michael@0: michael@0: mozilla::ipc::IProtocol* michael@0: CloneProtocol(Channel* aChannel, michael@0: mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: bool michael@0: CheckPermissionInternal(const nsAString& aDatabaseName, michael@0: const nsACString& aPermission); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBDatabaseConstructor(PIndexedDBDatabaseParent* aActor, michael@0: const nsString& aName, michael@0: const uint64_t& aVersion, michael@0: const PersistenceType& aPersistenceType) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBDeleteDatabaseRequestConstructor( michael@0: PIndexedDBDeleteDatabaseRequestParent* aActor, michael@0: const nsString& aName, michael@0: const PersistenceType& aPersistenceType) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBDatabaseParent* michael@0: AllocPIndexedDBDatabaseParent(const nsString& aName, const uint64_t& aVersion, michael@0: const PersistenceType& aPersistenceType) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBDatabaseParent(PIndexedDBDatabaseParent* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBDeleteDatabaseRequestParent* michael@0: AllocPIndexedDBDeleteDatabaseRequestParent( michael@0: const nsString& aName, michael@0: const PersistenceType& aPersistenceType) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBDeleteDatabaseRequestParent( michael@0: PIndexedDBDeleteDatabaseRequestParent* aActor) michael@0: MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBDatabaseParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBDatabaseParent : private PIndexedDBDatabaseParent michael@0: { michael@0: friend class IndexedDBParent; michael@0: friend class IndexedDBTransactionParent; michael@0: friend class IndexedDBVersionChangeTransactionParent; michael@0: michael@0: AutoWeakEventListener mEventListener; michael@0: michael@0: nsRefPtr mOpenRequest; michael@0: nsRefPtr mDatabase; michael@0: michael@0: public: michael@0: IndexedDBDatabaseParent(); michael@0: virtual ~IndexedDBDatabaseParent(); michael@0: michael@0: nsresult michael@0: SetOpenRequest(IDBOpenDBRequest* aRequest); michael@0: michael@0: nsresult michael@0: HandleEvent(nsIDOMEvent* aEvent); michael@0: michael@0: void michael@0: Disconnect(); michael@0: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: return static_cast(Manager())->IsDisconnected(); michael@0: } michael@0: michael@0: bool michael@0: CheckWritePermission(const nsAString& aDatabaseName); michael@0: michael@0: void michael@0: Invalidate(); michael@0: michael@0: protected: michael@0: nsresult michael@0: HandleRequestEvent(nsIDOMEvent* aEvent, const nsAString& aType); michael@0: michael@0: nsresult michael@0: HandleDatabaseEvent(nsIDOMEvent* aEvent, const nsAString& aType); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvClose(const bool& aUnlinked) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBTransactionConstructor(PIndexedDBTransactionParent* aActor, michael@0: const TransactionParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBTransactionParent* michael@0: AllocPIndexedDBTransactionParent(const TransactionParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBTransactionParent(PIndexedDBTransactionParent* aActor) michael@0: MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBTransactionParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBTransactionParent : protected PIndexedDBTransactionParent michael@0: { michael@0: friend class IndexedDBCursorParent; michael@0: friend class IndexedDBDatabaseParent; michael@0: friend class IndexedDBObjectStoreParent; michael@0: michael@0: protected: michael@0: AutoWeakEventListener mEventListener; michael@0: michael@0: nsRefPtr mTransaction; michael@0: michael@0: bool mArtificialRequestCount; michael@0: michael@0: public: michael@0: IndexedDBTransactionParent(); michael@0: virtual ~IndexedDBTransactionParent(); michael@0: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: return static_cast(Manager())->IsDisconnected(); michael@0: } michael@0: michael@0: nsresult 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: nsresult michael@0: HandleEvent(nsIDOMEvent* aEvent); michael@0: michael@0: protected: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvAbort(const nsresult& aAbortCode) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvAllRequestsFinished() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvDeleteObjectStore(const nsString& aName) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBObjectStoreConstructor( michael@0: PIndexedDBObjectStoreParent* aActor, michael@0: const ObjectStoreConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBObjectStoreParent* michael@0: AllocPIndexedDBObjectStoreParent(const ObjectStoreConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBObjectStoreParent(PIndexedDBObjectStoreParent* aActor) michael@0: MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBVersionChangeTransactionParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBVersionChangeTransactionParent : michael@0: public IndexedDBTransactionParent michael@0: { michael@0: friend class IndexedDBVersionChangeObjectStoreParent; michael@0: michael@0: public: michael@0: IndexedDBVersionChangeTransactionParent(); michael@0: virtual ~IndexedDBVersionChangeTransactionParent(); michael@0: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: return static_cast(Manager())->IsDisconnected(); michael@0: } michael@0: michael@0: protected: michael@0: virtual bool michael@0: RecvDeleteObjectStore(const nsString& aName) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBObjectStoreConstructor( michael@0: PIndexedDBObjectStoreParent* aActor, michael@0: const ObjectStoreConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBObjectStoreParent* michael@0: AllocPIndexedDBObjectStoreParent(const ObjectStoreConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBCursorParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBCursorParent : private PIndexedDBCursorParent michael@0: { michael@0: friend class IndexedDBIndexParent; michael@0: friend class IndexedDBObjectStoreParent; michael@0: michael@0: nsRefPtr mCursor; michael@0: michael@0: public: michael@0: IDBCursor* michael@0: GetCursor() const michael@0: { michael@0: return mCursor; michael@0: } michael@0: michael@0: bool michael@0: IsDisconnected() const; michael@0: michael@0: protected: michael@0: IndexedDBCursorParent(IDBCursor* aCursor); michael@0: virtual ~IndexedDBCursorParent(); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor, michael@0: const CursorRequestParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBRequestParent* michael@0: AllocPIndexedDBRequestParent(const CursorRequestParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBObjectStoreParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBObjectStoreParent : protected PIndexedDBObjectStoreParent michael@0: { michael@0: friend class IndexedDBIndexParent; michael@0: friend class IndexedDBTransactionParent; michael@0: friend class IndexedDBVersionChangeTransactionParent; michael@0: michael@0: typedef mozilla::dom::indexedDB::ipc::OpenCursorResponse OpenCursorResponse; michael@0: michael@0: protected: michael@0: nsRefPtr mObjectStore; michael@0: michael@0: public: michael@0: IndexedDBObjectStoreParent(); michael@0: virtual ~IndexedDBObjectStoreParent(); michael@0: michael@0: void michael@0: SetObjectStore(IDBObjectStore* aObjectStore); michael@0: michael@0: IDBObjectStore* michael@0: GetObjectStore() const michael@0: { michael@0: return mObjectStore; michael@0: } michael@0: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: IndexedDBTransactionParent* manager = michael@0: static_cast(Manager()); michael@0: return manager->IsDisconnected(); michael@0: } michael@0: michael@0: // Ordinarily callers could just do this manually using michael@0: // PIndexedDBObjectStoreParent::SendPIndexedDBCursorConstructor but we're michael@0: // inheriting the abstract protocol class privately to prevent outside code michael@0: // from sending messages without checking the disconnected state. Therefore michael@0: // we need a helper method. michael@0: bool michael@0: OpenCursor(IDBCursor* aCursor, michael@0: const ObjectStoreCursorConstructorParams& aParams, michael@0: OpenCursorResponse& aResponse) NS_WARN_UNUSED_RESULT michael@0: { michael@0: if (IsDisconnected()) { michael@0: return true; michael@0: } michael@0: michael@0: IndexedDBCursorParent* cursorActor = new IndexedDBCursorParent(aCursor); michael@0: michael@0: if (!SendPIndexedDBCursorConstructor(cursorActor, aParams)) { michael@0: return false; michael@0: } michael@0: michael@0: aResponse = cursorActor; michael@0: return true; michael@0: } michael@0: michael@0: protected: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvDeleteIndex(const nsString& aName) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor, michael@0: const ObjectStoreRequestParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBIndexConstructor(PIndexedDBIndexParent* aActor, michael@0: const IndexConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBRequestParent* michael@0: AllocPIndexedDBRequestParent(const ObjectStoreRequestParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBIndexParent* michael@0: AllocPIndexedDBIndexParent(const IndexConstructorParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBIndexParent(PIndexedDBIndexParent* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBCursorParent* michael@0: AllocPIndexedDBCursorParent(const ObjectStoreCursorConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBCursorParent(PIndexedDBCursorParent* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBVersionChangeObjectStoreParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBVersionChangeObjectStoreParent : michael@0: public IndexedDBObjectStoreParent michael@0: { michael@0: friend class IndexedDBVersionChangeTransactionParent; michael@0: michael@0: public: michael@0: IndexedDBVersionChangeObjectStoreParent(); michael@0: virtual ~IndexedDBVersionChangeObjectStoreParent(); michael@0: michael@0: protected: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: IndexedDBVersionChangeTransactionParent* manager = michael@0: static_cast(Manager()); michael@0: return manager->IsDisconnected(); michael@0: } michael@0: michael@0: virtual bool michael@0: RecvDeleteIndex(const nsString& aName) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBIndexConstructor(PIndexedDBIndexParent* aActor, michael@0: const IndexConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBIndexParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBIndexParent : private PIndexedDBIndexParent michael@0: { michael@0: friend class IndexedDBObjectStoreParent; michael@0: friend class IndexedDBVersionChangeObjectStoreParent; michael@0: michael@0: typedef mozilla::dom::indexedDB::ipc::OpenCursorResponse OpenCursorResponse; michael@0: michael@0: nsRefPtr mIndex; michael@0: michael@0: public: michael@0: IndexedDBIndexParent(); michael@0: virtual ~IndexedDBIndexParent(); michael@0: michael@0: void michael@0: SetIndex(IDBIndex* aObjectStore); michael@0: michael@0: IDBIndex* michael@0: GetIndex() const michael@0: { michael@0: return mIndex; michael@0: } michael@0: michael@0: // Ordinarily callers could just do this manually using michael@0: // PIndexedDBIndexParent::SendPIndexedDBCursorConstructor but we're michael@0: // inheriting the abstract protocol class privately to prevent outside code michael@0: // from sending messages without checking the disconnected state. Therefore michael@0: // we need a helper method. michael@0: bool michael@0: OpenCursor(IDBCursor* aCursor, const IndexCursorConstructorParams& aParams, michael@0: OpenCursorResponse& aResponse) NS_WARN_UNUSED_RESULT michael@0: { michael@0: if (IsDisconnected()) { michael@0: return true; michael@0: } michael@0: michael@0: IndexedDBCursorParent* cursorActor = new IndexedDBCursorParent(aCursor); michael@0: michael@0: if (!SendPIndexedDBCursorConstructor(cursorActor, aParams)) { michael@0: return false; michael@0: } michael@0: michael@0: aResponse = cursorActor; michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: IndexedDBObjectStoreParent* manager = michael@0: static_cast(Manager()); michael@0: return manager->IsDisconnected(); michael@0: } michael@0: michael@0: protected: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor, michael@0: const IndexRequestParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBRequestParent* michael@0: AllocPIndexedDBRequestParent(const IndexRequestParams& aParams) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual PIndexedDBCursorParent* michael@0: AllocPIndexedDBCursorParent(const IndexCursorConstructorParams& aParams) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPIndexedDBCursorParent(PIndexedDBCursorParent* aActor) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBRequestParentBase michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBRequestParentBase : public PIndexedDBRequestParent michael@0: { michael@0: public: michael@0: bool michael@0: SendResponse(const ResponseValue& aResponse) NS_WARN_UNUSED_RESULT michael@0: { michael@0: if (IsDisconnected()) { michael@0: return true; michael@0: } michael@0: michael@0: return Send__delete__(this, aResponse); michael@0: } michael@0: michael@0: protected: michael@0: // Don't let anyone call this directly, instead go through SendResponse. michael@0: using PIndexedDBRequestParent::Send__delete__; michael@0: michael@0: typedef ipc::ResponseValue ResponseValue; michael@0: typedef PIndexedDBRequestParent::PBlobParent PBlobParent; michael@0: michael@0: nsRefPtr mRequest; michael@0: michael@0: IndexedDBRequestParentBase(); michael@0: virtual ~IndexedDBRequestParentBase(); michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: IsDisconnected() = 0; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBObjectStoreRequestParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBObjectStoreRequestParent : public IndexedDBRequestParentBase michael@0: { michael@0: friend class IndexedDBObjectStoreParent; 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: typedef ipc::AddParams AddParams; michael@0: typedef ipc::PutParams PutParams; michael@0: typedef ipc::ClearParams ClearParams; michael@0: typedef ipc::DeleteParams DeleteParams; michael@0: typedef ipc::GetParams GetParams; michael@0: typedef ipc::GetAllParams GetAllParams; michael@0: typedef ipc::GetAllKeysParams GetAllKeysParams; michael@0: typedef ipc::CountParams CountParams; michael@0: typedef ipc::OpenCursorParams OpenCursorParams; michael@0: typedef ipc::OpenKeyCursorParams OpenKeyCursorParams; michael@0: michael@0: public: michael@0: IndexedDBObjectStoreRequestParent(IDBObjectStore* aObjectStore, michael@0: RequestType aRequestType); michael@0: virtual ~IndexedDBObjectStoreRequestParent(); michael@0: michael@0: bool michael@0: Get(const GetParams& aParams); michael@0: michael@0: bool michael@0: GetAll(const GetAllParams& aParams); michael@0: michael@0: bool michael@0: GetAllKeys(const GetAllKeysParams& aParams); michael@0: michael@0: bool michael@0: Add(const AddParams& aParams); michael@0: michael@0: bool michael@0: Put(const PutParams& aParams); michael@0: michael@0: bool michael@0: Delete(const DeleteParams& aParams); michael@0: michael@0: bool michael@0: Clear(const ClearParams& aParams); michael@0: michael@0: bool michael@0: Count(const CountParams& aParams); michael@0: michael@0: bool michael@0: OpenCursor(const OpenCursorParams& aParams); michael@0: michael@0: bool michael@0: OpenKeyCursor(const OpenKeyCursorParams& aParams); michael@0: michael@0: protected: michael@0: void michael@0: ConvertBlobActors(const InfallibleTArray& aActors, michael@0: nsTArray >& aBlobs); michael@0: michael@0: private: michael@0: virtual bool michael@0: IsDisconnected() MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBIndexRequestParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBIndexRequestParent : public IndexedDBRequestParentBase michael@0: { michael@0: friend class IndexedDBIndexParent; 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: typedef ipc::GetKeyParams GetKeyParams; michael@0: typedef ipc::GetAllKeysParams GetAllKeysParams; michael@0: typedef ipc::OpenKeyCursorParams OpenKeyCursorParams; michael@0: typedef ipc::GetParams GetParams; michael@0: typedef ipc::GetAllParams GetAllParams; michael@0: typedef ipc::CountParams CountParams; michael@0: typedef ipc::OpenCursorParams OpenCursorParams; michael@0: michael@0: public: michael@0: IndexedDBIndexRequestParent(IDBIndex* aIndex, RequestType aRequestType); michael@0: virtual ~IndexedDBIndexRequestParent(); michael@0: michael@0: bool michael@0: Get(const GetParams& aParams); michael@0: michael@0: bool michael@0: GetKey(const GetKeyParams& aParams); michael@0: michael@0: bool michael@0: GetAll(const GetAllParams& aParams); michael@0: michael@0: bool michael@0: GetAllKeys(const GetAllKeysParams& aParams); michael@0: michael@0: bool michael@0: Count(const CountParams& aParams); michael@0: michael@0: bool michael@0: OpenCursor(const OpenCursorParams& aParams); michael@0: michael@0: bool michael@0: OpenKeyCursor(const OpenKeyCursorParams& aParams); michael@0: michael@0: private: michael@0: virtual bool michael@0: IsDisconnected() MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBCursorRequestParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBCursorRequestParent : public IndexedDBRequestParentBase michael@0: { michael@0: friend class IndexedDBCursorParent; 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: typedef ipc::ContinueParams ContinueParams; michael@0: michael@0: public: michael@0: IndexedDBCursorRequestParent(IDBCursor* aCursor, RequestType aRequestType); michael@0: virtual ~IndexedDBCursorRequestParent(); michael@0: michael@0: bool michael@0: Continue(const ContinueParams& aParams); michael@0: michael@0: private: michael@0: virtual bool michael@0: IsDisconnected() MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBDeleteDatabaseRequestParent michael@0: ******************************************************************************/ michael@0: michael@0: class IndexedDBDeleteDatabaseRequestParent : michael@0: private PIndexedDBDeleteDatabaseRequestParent michael@0: { michael@0: friend class IndexedDBParent; michael@0: michael@0: AutoWeakEventListener mEventListener; michael@0: michael@0: nsRefPtr mFactory; michael@0: nsRefPtr mOpenRequest; michael@0: michael@0: public: michael@0: nsresult michael@0: HandleEvent(nsIDOMEvent* aEvent); michael@0: michael@0: protected: michael@0: IndexedDBDeleteDatabaseRequestParent(IDBFactory* aFactory); michael@0: virtual ~IndexedDBDeleteDatabaseRequestParent(); michael@0: michael@0: nsresult michael@0: SetOpenRequest(IDBOpenDBRequest* aOpenRequest); michael@0: michael@0: bool michael@0: IsDisconnected() const michael@0: { michael@0: return static_cast(Manager())->IsDisconnected(); michael@0: } michael@0: }; michael@0: michael@0: END_INDEXEDDB_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_indexeddb_ipc_indexeddbparent_h__