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: #include "base/basictypes.h" michael@0: michael@0: #include "IndexedDBChild.h" michael@0: michael@0: #include "nsIInputStream.h" michael@0: michael@0: #include "mozilla/Assertions.h" michael@0: #include "mozilla/dom/ContentChild.h" michael@0: #include "mozilla/dom/quota/Client.h" michael@0: #include "mozilla/dom/quota/QuotaManager.h" michael@0: michael@0: #include "AsyncConnectionHelper.h" michael@0: #include "DatabaseInfo.h" michael@0: #include "IDBEvents.h" michael@0: #include "IDBFactory.h" michael@0: #include "IDBIndex.h" michael@0: #include "IDBObjectStore.h" michael@0: #include "IDBTransaction.h" michael@0: michael@0: USING_INDEXEDDB_NAMESPACE michael@0: michael@0: using namespace mozilla::dom; michael@0: using mozilla::dom::quota::Client; michael@0: using mozilla::dom::quota::QuotaManager; michael@0: michael@0: namespace { michael@0: michael@0: class IPCOpenDatabaseHelper : public AsyncConnectionHelper michael@0: { michael@0: public: michael@0: IPCOpenDatabaseHelper(IDBDatabase* aDatabase, IDBOpenDBRequest* aRequest) michael@0: : AsyncConnectionHelper(aDatabase, aRequest) michael@0: { michael@0: MOZ_ASSERT(aRequest); michael@0: } michael@0: michael@0: virtual nsresult UnpackResponseFromParentProcess( michael@0: const ResponseValue& aResponseValue) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual ChildProcessSendResult michael@0: SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: GetSuccessResult(JSContext* aCx, JS::MutableHandle aVal) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: OnSuccess() MOZ_OVERRIDE michael@0: { michael@0: static_cast(mRequest.get())->SetTransaction(nullptr); michael@0: return AsyncConnectionHelper::OnSuccess(); michael@0: } michael@0: michael@0: virtual void michael@0: OnError() MOZ_OVERRIDE michael@0: { michael@0: static_cast(mRequest.get())->SetTransaction(nullptr); michael@0: AsyncConnectionHelper::OnError(); michael@0: } michael@0: michael@0: virtual nsresult michael@0: DoDatabaseWork(mozIStorageConnection* aConnection) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: class IPCSetVersionHelper : public AsyncConnectionHelper michael@0: { michael@0: nsRefPtr mOpenRequest; michael@0: uint64_t mOldVersion; michael@0: uint64_t mRequestedVersion; michael@0: michael@0: public: michael@0: IPCSetVersionHelper(IDBTransaction* aTransaction, IDBOpenDBRequest* aRequest, michael@0: uint64_t aOldVersion, uint64_t aRequestedVersion) michael@0: : AsyncConnectionHelper(aTransaction, aRequest), michael@0: mOpenRequest(aRequest), mOldVersion(aOldVersion), michael@0: mRequestedVersion(aRequestedVersion) michael@0: { michael@0: MOZ_ASSERT(aTransaction); michael@0: MOZ_ASSERT(aRequest); michael@0: } michael@0: michael@0: virtual nsresult UnpackResponseFromParentProcess( michael@0: const ResponseValue& aResponseValue) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual ChildProcessSendResult michael@0: SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: DoDatabaseWork(mozIStorageConnection* aConnection) MOZ_OVERRIDE; michael@0: michael@0: virtual already_AddRefed michael@0: CreateSuccessEvent(mozilla::dom::EventTarget* aOwner) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: GetSuccessResult(JSContext* aCx, JS::MutableHandle aVal) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: class IPCDeleteDatabaseHelper : public AsyncConnectionHelper michael@0: { michael@0: public: michael@0: IPCDeleteDatabaseHelper(IDBRequest* aRequest) michael@0: : AsyncConnectionHelper(static_cast(nullptr), aRequest) michael@0: { } michael@0: michael@0: virtual nsresult UnpackResponseFromParentProcess( michael@0: const ResponseValue& aResponseValue) michael@0: MOZ_OVERRIDE; michael@0: michael@0: virtual ChildProcessSendResult michael@0: SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: GetSuccessResult(JSContext* aCx, JS::MutableHandle aVal) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: DoDatabaseWork(mozIStorageConnection* aConnection) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: class VersionChangeRunnable : public nsRunnable michael@0: { michael@0: nsRefPtr mDatabase; michael@0: uint64_t mOldVersion; michael@0: uint64_t mNewVersion; michael@0: michael@0: public: michael@0: VersionChangeRunnable(IDBDatabase* aDatabase, const uint64_t& aOldVersion, michael@0: const uint64_t& aNewVersion) michael@0: : mDatabase(aDatabase), mOldVersion(aOldVersion), mNewVersion(aNewVersion) michael@0: { michael@0: MOZ_ASSERT(aDatabase); michael@0: } michael@0: michael@0: NS_IMETHOD Run() MOZ_OVERRIDE michael@0: { michael@0: if (mDatabase->IsClosed()) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsRefPtr event = michael@0: IDBVersionChangeEvent::Create(mDatabase, mOldVersion, mNewVersion); michael@0: MOZ_ASSERT(event); michael@0: michael@0: bool dummy; michael@0: nsresult rv = mDatabase->DispatchEvent(event, &dummy); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: return NS_OK; michael@0: } michael@0: }; michael@0: michael@0: } // anonymous namespace michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBChild::IndexedDBChild(const nsCString& aASCIIOrigin) michael@0: : mFactory(nullptr), mASCIIOrigin(aASCIIOrigin) michael@0: #ifdef DEBUG michael@0: , mDisconnected(false) michael@0: #endif michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBChild); michael@0: } michael@0: michael@0: IndexedDBChild::~IndexedDBChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBChild); michael@0: MOZ_ASSERT(!mFactory); michael@0: } michael@0: michael@0: void michael@0: IndexedDBChild::SetFactory(IDBFactory* aFactory) michael@0: { michael@0: MOZ_ASSERT(aFactory); michael@0: MOZ_ASSERT(!mFactory); michael@0: michael@0: aFactory->SetActor(this); michael@0: mFactory = aFactory; michael@0: } michael@0: michael@0: void michael@0: IndexedDBChild::Disconnect() michael@0: { michael@0: #ifdef DEBUG michael@0: MOZ_ASSERT(!mDisconnected); michael@0: mDisconnected = true; michael@0: #endif michael@0: michael@0: const InfallibleTArray& databases = michael@0: ManagedPIndexedDBDatabaseChild(); michael@0: for (uint32_t i = 0; i < databases.Length(); ++i) { michael@0: static_cast(databases[i])->Disconnect(); michael@0: } michael@0: } michael@0: michael@0: void michael@0: IndexedDBChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: if (mFactory) { michael@0: mFactory->SetActor(static_cast(nullptr)); michael@0: #ifdef DEBUG michael@0: mFactory = nullptr; michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: PIndexedDBDatabaseChild* michael@0: IndexedDBChild::AllocPIndexedDBDatabaseChild( michael@0: const nsString& aName, michael@0: const uint64_t& aVersion, michael@0: const PersistenceType& aPersistenceType) michael@0: { michael@0: return new IndexedDBDatabaseChild(aName, aVersion); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBChild::DeallocPIndexedDBDatabaseChild(PIndexedDBDatabaseChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: PIndexedDBDeleteDatabaseRequestChild* michael@0: IndexedDBChild::AllocPIndexedDBDeleteDatabaseRequestChild( michael@0: const nsString& aName, michael@0: const PersistenceType& aPersistenceType) michael@0: { michael@0: MOZ_CRASH("Caller is supposed to manually construct a request!"); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBChild::DeallocPIndexedDBDeleteDatabaseRequestChild( michael@0: PIndexedDBDeleteDatabaseRequestChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBDatabaseChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBDatabaseChild::IndexedDBDatabaseChild(const nsString& aName, michael@0: uint64_t aVersion) michael@0: : mDatabase(nullptr), mName(aName), mVersion(aVersion) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBDatabaseChild); michael@0: } michael@0: michael@0: IndexedDBDatabaseChild::~IndexedDBDatabaseChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBDatabaseChild); michael@0: MOZ_ASSERT(!mDatabase); michael@0: MOZ_ASSERT(!mStrongDatabase); michael@0: } michael@0: michael@0: void michael@0: IndexedDBDatabaseChild::SetRequest(IDBOpenDBRequest* aRequest) michael@0: { michael@0: MOZ_ASSERT(aRequest); michael@0: MOZ_ASSERT(!mRequest); michael@0: michael@0: mRequest = aRequest; michael@0: } michael@0: michael@0: void michael@0: IndexedDBDatabaseChild::Disconnect() michael@0: { michael@0: const InfallibleTArray& transactions = michael@0: ManagedPIndexedDBTransactionChild(); michael@0: for (uint32_t i = 0; i < transactions.Length(); ++i) { michael@0: static_cast(transactions[i])->Disconnect(); michael@0: } michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::EnsureDatabase( michael@0: IDBOpenDBRequest* aRequest, michael@0: const DatabaseInfoGuts& aDBInfo, michael@0: const InfallibleTArray& aOSInfo) michael@0: { michael@0: nsCString databaseId; michael@0: if (mDatabase) { michael@0: databaseId = mDatabase->Id(); michael@0: } michael@0: else { michael@0: QuotaManager::GetStorageId(aDBInfo.persistenceType, aDBInfo.origin, michael@0: Client::IDB, aDBInfo.name, databaseId); michael@0: } michael@0: MOZ_ASSERT(!databaseId.IsEmpty()); michael@0: michael@0: nsRefPtr dbInfo; michael@0: if (DatabaseInfo::Get(databaseId, getter_AddRefs(dbInfo))) { michael@0: dbInfo->version = aDBInfo.version; michael@0: } michael@0: else { michael@0: nsRefPtr newInfo = new DatabaseInfo(); michael@0: michael@0: *static_cast(newInfo.get()) = aDBInfo; michael@0: newInfo->id = databaseId; michael@0: michael@0: if (!DatabaseInfo::Put(newInfo)) { michael@0: NS_WARNING("Out of memory!"); michael@0: return false; michael@0: } michael@0: michael@0: newInfo.swap(dbInfo); michael@0: michael@0: // This is more or less copied from IDBFactory::SetDatabaseMetadata. michael@0: for (uint32_t i = 0; i < aOSInfo.Length(); i++) { michael@0: nsRefPtr newInfo = new ObjectStoreInfo(); michael@0: *static_cast(newInfo.get()) = aOSInfo[i]; michael@0: michael@0: if (!dbInfo->PutObjectStore(newInfo)) { michael@0: NS_WARNING("Out of memory!"); michael@0: return false; michael@0: } michael@0: } michael@0: } michael@0: michael@0: if (!mDatabase) { michael@0: nsRefPtr database = michael@0: IDBDatabase::Create(aRequest, aRequest->Factory(), dbInfo.forget(), michael@0: aDBInfo.origin, nullptr, nullptr); michael@0: if (!database) { michael@0: NS_WARNING("Failed to create database!"); michael@0: return false; michael@0: } michael@0: michael@0: database->SetActor(this); michael@0: michael@0: mDatabase = database; michael@0: mStrongDatabase = database.forget(); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: void michael@0: IndexedDBDatabaseChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: if (mDatabase) { michael@0: mDatabase->SetActor(static_cast(nullptr)); michael@0: #ifdef DEBUG michael@0: mDatabase = nullptr; michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::RecvSuccess( michael@0: const DatabaseInfoGuts& aDBInfo, michael@0: const InfallibleTArray& aOSInfo) michael@0: { michael@0: #ifdef DEBUG michael@0: { michael@0: IndexedDBChild* manager = static_cast(Manager()); michael@0: MOZ_ASSERT(aDBInfo.origin == manager->ASCIIOrigin()); michael@0: MOZ_ASSERT(aDBInfo.name == mName); michael@0: MOZ_ASSERT(!mVersion || aDBInfo.version == mVersion); michael@0: } michael@0: #endif michael@0: michael@0: MOZ_ASSERT(mRequest); michael@0: michael@0: nsRefPtr request; michael@0: mRequest.swap(request); michael@0: michael@0: nsRefPtr openHelper; michael@0: mOpenHelper.swap(openHelper); michael@0: michael@0: if (!EnsureDatabase(request, aDBInfo, aOSInfo)) { michael@0: return false; michael@0: } michael@0: michael@0: MOZ_ASSERT(mStrongDatabase); michael@0: nsRefPtr database; michael@0: mStrongDatabase.swap(database); michael@0: michael@0: if (openHelper) { michael@0: request->Reset(); michael@0: } michael@0: else { michael@0: openHelper = new IPCOpenDatabaseHelper(mDatabase, request); michael@0: } michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(openHelper->Dispatch(&target))) { michael@0: NS_WARNING("Dispatch of IPCOpenDatabaseHelper failed!"); michael@0: return false; michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::RecvError(const nsresult& aRv) michael@0: { michael@0: MOZ_ASSERT(mRequest); michael@0: michael@0: nsRefPtr request; michael@0: mRequest.swap(request); michael@0: michael@0: nsRefPtr database; michael@0: mStrongDatabase.swap(database); michael@0: michael@0: nsRefPtr openHelper; michael@0: mOpenHelper.swap(openHelper); michael@0: michael@0: if (openHelper) { michael@0: request->Reset(); michael@0: } michael@0: else { michael@0: openHelper = new IPCOpenDatabaseHelper(nullptr, request); michael@0: } michael@0: michael@0: openHelper->SetError(aRv); michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(openHelper->Dispatch(&target))) { michael@0: NS_WARNING("Dispatch of IPCOpenDatabaseHelper failed!"); michael@0: return false; michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::RecvBlocked(const uint64_t& aOldVersion) michael@0: { michael@0: MOZ_ASSERT(mRequest); michael@0: MOZ_ASSERT(!mDatabase); michael@0: michael@0: nsCOMPtr runnable = michael@0: IDBVersionChangeEvent::CreateBlockedRunnable(mRequest, aOldVersion, mVersion); michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(target.Dispatch(runnable, NS_DISPATCH_NORMAL))) { michael@0: NS_WARNING("Dispatch of blocked event failed!"); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::RecvVersionChange(const uint64_t& aOldVersion, michael@0: const uint64_t& aNewVersion) michael@0: { michael@0: MOZ_ASSERT(mDatabase); michael@0: michael@0: nsCOMPtr runnable = michael@0: new VersionChangeRunnable(mDatabase, aOldVersion, aNewVersion); michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(target.Dispatch(runnable, NS_DISPATCH_NORMAL))) { michael@0: NS_WARNING("Dispatch of versionchange event failed!"); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::RecvInvalidate() michael@0: { michael@0: if (mDatabase) { michael@0: mDatabase->Invalidate(); michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::RecvPIndexedDBTransactionConstructor( michael@0: PIndexedDBTransactionChild* aActor, michael@0: const TransactionParams& aParams) michael@0: { michael@0: // This only happens when the parent has created a version-change transaction michael@0: // for us. michael@0: michael@0: IndexedDBTransactionChild* actor = michael@0: static_cast(aActor); michael@0: MOZ_ASSERT(!actor->GetTransaction()); michael@0: michael@0: MOZ_ASSERT(aParams.type() == michael@0: TransactionParams::TVersionChangeTransactionParams); michael@0: michael@0: const VersionChangeTransactionParams& params = michael@0: aParams.get_VersionChangeTransactionParams(); michael@0: michael@0: const DatabaseInfoGuts& dbInfo = params.dbInfo(); michael@0: const InfallibleTArray& osInfo = params.osInfo(); michael@0: uint64_t oldVersion = params.oldVersion(); michael@0: michael@0: MOZ_ASSERT(dbInfo.origin == michael@0: static_cast(Manager())->ASCIIOrigin()); michael@0: MOZ_ASSERT(dbInfo.name == mName); michael@0: MOZ_ASSERT(!mVersion || dbInfo.version == mVersion); michael@0: MOZ_ASSERT(!mVersion || oldVersion < mVersion); michael@0: michael@0: MOZ_ASSERT(mRequest); michael@0: MOZ_ASSERT(!mDatabase); michael@0: MOZ_ASSERT(!mOpenHelper); michael@0: michael@0: if (!EnsureDatabase(mRequest, dbInfo, osInfo)) { michael@0: return false; michael@0: } michael@0: michael@0: nsRefPtr helper = michael@0: new IPCOpenDatabaseHelper(mDatabase, mRequest); michael@0: michael@0: Sequence storesToOpen; michael@0: nsRefPtr transaction = michael@0: IDBTransaction::CreateInternal(mDatabase, storesToOpen, michael@0: IDBTransaction::VERSION_CHANGE, false, true); michael@0: NS_ENSURE_TRUE(transaction, false); michael@0: michael@0: nsRefPtr versionHelper = michael@0: new IPCSetVersionHelper(transaction, mRequest, oldVersion, mVersion); michael@0: michael@0: mDatabase->EnterSetVersionTransaction(); michael@0: mDatabase->mPreviousDatabaseInfo->version = oldVersion; michael@0: michael@0: actor->SetTransaction(transaction); michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(versionHelper->Dispatch(&target))) { michael@0: NS_WARNING("Dispatch of IPCSetVersionHelper failed!"); michael@0: return false; michael@0: } michael@0: michael@0: mOpenHelper = helper.forget(); michael@0: return true; michael@0: } michael@0: michael@0: PIndexedDBTransactionChild* michael@0: IndexedDBDatabaseChild::AllocPIndexedDBTransactionChild( michael@0: const TransactionParams& aParams) michael@0: { michael@0: MOZ_ASSERT(aParams.type() == michael@0: TransactionParams::TVersionChangeTransactionParams); michael@0: return new IndexedDBTransactionChild(); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDatabaseChild::DeallocPIndexedDBTransactionChild( michael@0: PIndexedDBTransactionChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBTransactionChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBTransactionChild::IndexedDBTransactionChild() michael@0: : mTransaction(nullptr) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBTransactionChild); michael@0: } michael@0: michael@0: IndexedDBTransactionChild::~IndexedDBTransactionChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBTransactionChild); michael@0: MOZ_ASSERT(!mTransaction); michael@0: MOZ_ASSERT(!mStrongTransaction); michael@0: } michael@0: michael@0: void michael@0: IndexedDBTransactionChild::SetTransaction(IDBTransaction* aTransaction) michael@0: { michael@0: MOZ_ASSERT(aTransaction); michael@0: MOZ_ASSERT(!mTransaction); michael@0: michael@0: aTransaction->SetActor(this); michael@0: michael@0: mTransaction = aTransaction; michael@0: mStrongTransaction = aTransaction; michael@0: } michael@0: michael@0: void michael@0: IndexedDBTransactionChild::Disconnect() michael@0: { michael@0: const InfallibleTArray& objectStores = michael@0: ManagedPIndexedDBObjectStoreChild(); michael@0: for (uint32_t i = 0; i < objectStores.Length(); ++i) { michael@0: static_cast(objectStores[i])->Disconnect(); michael@0: } michael@0: } michael@0: michael@0: void michael@0: IndexedDBTransactionChild::FireCompleteEvent(nsresult aRv) michael@0: { michael@0: MOZ_ASSERT(mTransaction); michael@0: MOZ_ASSERT(mStrongTransaction); michael@0: michael@0: nsRefPtr transaction; michael@0: mStrongTransaction.swap(transaction); michael@0: michael@0: if (transaction->GetMode() == IDBTransaction::VERSION_CHANGE) { michael@0: transaction->Database()->ExitSetVersionTransaction(); michael@0: } michael@0: michael@0: nsRefPtr helper = new CommitHelper(transaction, aRv); michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(target.Dispatch(helper, NS_DISPATCH_NORMAL))) { michael@0: NS_WARNING("Dispatch of CommitHelper failed!"); michael@0: } michael@0: } michael@0: michael@0: void michael@0: IndexedDBTransactionChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: if (mStrongTransaction) { michael@0: // We're being torn down before we received a complete event from the parent michael@0: // so fake one here. michael@0: FireCompleteEvent(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); michael@0: michael@0: MOZ_ASSERT(!mStrongTransaction); michael@0: } michael@0: michael@0: if (mTransaction) { michael@0: mTransaction->SetActor(static_cast(nullptr)); michael@0: #ifdef DEBUG michael@0: mTransaction = nullptr; michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: bool michael@0: IndexedDBTransactionChild::RecvComplete(const CompleteParams& aParams) michael@0: { michael@0: MOZ_ASSERT(mTransaction); michael@0: MOZ_ASSERT(mStrongTransaction); michael@0: michael@0: nsresult resultCode; michael@0: michael@0: switch (aParams.type()) { michael@0: case CompleteParams::TCompleteResult: michael@0: resultCode = NS_OK; michael@0: break; michael@0: case CompleteParams::TAbortResult: michael@0: resultCode = aParams.get_AbortResult().errorCode(); michael@0: if (NS_SUCCEEDED(resultCode)) { michael@0: resultCode = NS_ERROR_DOM_INDEXEDDB_ABORT_ERR; michael@0: } michael@0: break; michael@0: michael@0: default: michael@0: MOZ_CRASH("Unknown union type!"); michael@0: } michael@0: michael@0: FireCompleteEvent(resultCode); michael@0: return true; michael@0: } michael@0: michael@0: PIndexedDBObjectStoreChild* michael@0: IndexedDBTransactionChild::AllocPIndexedDBObjectStoreChild( michael@0: const ObjectStoreConstructorParams& aParams) michael@0: { michael@0: MOZ_CRASH("Caller is supposed to manually construct an object store!"); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBTransactionChild::DeallocPIndexedDBObjectStoreChild( michael@0: PIndexedDBObjectStoreChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBObjectStoreChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBObjectStoreChild::IndexedDBObjectStoreChild( michael@0: IDBObjectStore* aObjectStore) michael@0: : mObjectStore(aObjectStore) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBObjectStoreChild); michael@0: aObjectStore->SetActor(this); michael@0: } michael@0: michael@0: IndexedDBObjectStoreChild::~IndexedDBObjectStoreChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBObjectStoreChild); michael@0: MOZ_ASSERT(!mObjectStore); michael@0: } michael@0: michael@0: void michael@0: IndexedDBObjectStoreChild::Disconnect() michael@0: { michael@0: const InfallibleTArray& requests = michael@0: ManagedPIndexedDBRequestChild(); michael@0: for (uint32_t i = 0; i < requests.Length(); ++i) { michael@0: static_cast(requests[i])->Disconnect(); michael@0: } michael@0: michael@0: const InfallibleTArray& indexes = michael@0: ManagedPIndexedDBIndexChild(); michael@0: for (uint32_t i = 0; i < indexes.Length(); ++i) { michael@0: static_cast(indexes[i])->Disconnect(); michael@0: } michael@0: michael@0: const InfallibleTArray& cursors = michael@0: ManagedPIndexedDBCursorChild(); michael@0: for (uint32_t i = 0; i < cursors.Length(); ++i) { michael@0: static_cast(cursors[i])->Disconnect(); michael@0: } michael@0: } michael@0: michael@0: void michael@0: IndexedDBObjectStoreChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: if (mObjectStore) { michael@0: mObjectStore->SetActor(static_cast(nullptr)); michael@0: #ifdef DEBUG michael@0: mObjectStore = nullptr; michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: bool michael@0: IndexedDBObjectStoreChild::RecvPIndexedDBCursorConstructor( michael@0: PIndexedDBCursorChild* aActor, michael@0: const ObjectStoreCursorConstructorParams& aParams) michael@0: { michael@0: IndexedDBCursorChild* actor = static_cast(aActor); michael@0: michael@0: IndexedDBObjectStoreRequestChild* requestActor = michael@0: static_cast(aParams.requestChild()); michael@0: NS_ASSERTION(requestActor, "Must have an actor here!"); michael@0: michael@0: nsRefPtr request = requestActor->GetRequest(); michael@0: NS_ASSERTION(request, "Must have a request here!"); michael@0: michael@0: size_t direction = static_cast(aParams.direction()); michael@0: michael@0: nsRefPtr cursor; michael@0: nsresult rv; michael@0: michael@0: typedef ipc::OptionalStructuredCloneReadInfo CursorUnionType; michael@0: michael@0: switch (aParams.optionalCloneInfo().type()) { michael@0: case CursorUnionType::TSerializedStructuredCloneReadInfo: { michael@0: nsTArray blobs; michael@0: IDBObjectStore::ConvertActorsToBlobs(aParams.blobsChild(), blobs); michael@0: michael@0: const SerializedStructuredCloneReadInfo& cloneInfo = michael@0: aParams.optionalCloneInfo().get_SerializedStructuredCloneReadInfo(); michael@0: michael@0: rv = mObjectStore->OpenCursorFromChildProcess(request, direction, michael@0: aParams.key(), cloneInfo, michael@0: blobs, michael@0: getter_AddRefs(cursor)); michael@0: NS_ENSURE_SUCCESS(rv, false); michael@0: michael@0: MOZ_ASSERT(blobs.IsEmpty(), "Should have swapped blob elements!"); michael@0: } break; michael@0: michael@0: case CursorUnionType::Tvoid_t: michael@0: MOZ_ASSERT(aParams.blobsChild().IsEmpty()); michael@0: michael@0: rv = mObjectStore->OpenCursorFromChildProcess(request, direction, michael@0: aParams.key(), michael@0: getter_AddRefs(cursor)); michael@0: NS_ENSURE_SUCCESS(rv, false); michael@0: break; michael@0: michael@0: default: michael@0: MOZ_CRASH("Unknown union type!"); michael@0: } michael@0: michael@0: actor->SetCursor(cursor); michael@0: return true; michael@0: } michael@0: michael@0: PIndexedDBRequestChild* michael@0: IndexedDBObjectStoreChild::AllocPIndexedDBRequestChild( michael@0: const ObjectStoreRequestParams& aParams) michael@0: { michael@0: MOZ_CRASH("Caller is supposed to manually construct a request!"); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBObjectStoreChild::DeallocPIndexedDBRequestChild( michael@0: PIndexedDBRequestChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return false; michael@0: } michael@0: michael@0: PIndexedDBIndexChild* michael@0: IndexedDBObjectStoreChild::AllocPIndexedDBIndexChild( michael@0: const IndexConstructorParams& aParams) michael@0: { michael@0: MOZ_CRASH("Caller is supposed to manually construct an index!"); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBObjectStoreChild::DeallocPIndexedDBIndexChild(PIndexedDBIndexChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: PIndexedDBCursorChild* michael@0: IndexedDBObjectStoreChild::AllocPIndexedDBCursorChild( michael@0: const ObjectStoreCursorConstructorParams& aParams) michael@0: { michael@0: return new IndexedDBCursorChild(); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBObjectStoreChild::DeallocPIndexedDBCursorChild( michael@0: PIndexedDBCursorChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBIndexChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBIndexChild::IndexedDBIndexChild(IDBIndex* aIndex) michael@0: : mIndex(aIndex) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBIndexChild); michael@0: aIndex->SetActor(this); michael@0: } michael@0: michael@0: IndexedDBIndexChild::~IndexedDBIndexChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBIndexChild); michael@0: MOZ_ASSERT(!mIndex); michael@0: } michael@0: michael@0: void michael@0: IndexedDBIndexChild::Disconnect() michael@0: { michael@0: const InfallibleTArray& requests = michael@0: ManagedPIndexedDBRequestChild(); michael@0: for (uint32_t i = 0; i < requests.Length(); ++i) { michael@0: static_cast(requests[i])->Disconnect(); michael@0: } michael@0: michael@0: const InfallibleTArray& cursors = michael@0: ManagedPIndexedDBCursorChild(); michael@0: for (uint32_t i = 0; i < cursors.Length(); ++i) { michael@0: static_cast(cursors[i])->Disconnect(); michael@0: } michael@0: } michael@0: michael@0: void michael@0: IndexedDBIndexChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: if (mIndex) { michael@0: mIndex->SetActor(static_cast(nullptr)); michael@0: #ifdef DEBUG michael@0: mIndex = nullptr; michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: bool michael@0: IndexedDBIndexChild::RecvPIndexedDBCursorConstructor( michael@0: PIndexedDBCursorChild* aActor, michael@0: const IndexCursorConstructorParams& aParams) michael@0: { michael@0: IndexedDBCursorChild* actor = static_cast(aActor); michael@0: michael@0: IndexedDBObjectStoreRequestChild* requestActor = michael@0: static_cast(aParams.requestChild()); michael@0: NS_ASSERTION(requestActor, "Must have an actor here!"); michael@0: michael@0: nsRefPtr request = requestActor->GetRequest(); michael@0: NS_ASSERTION(request, "Must have a request here!"); michael@0: michael@0: size_t direction = static_cast(aParams.direction()); michael@0: michael@0: nsRefPtr cursor; michael@0: nsresult rv; michael@0: michael@0: typedef ipc::OptionalStructuredCloneReadInfo CursorUnionType; michael@0: michael@0: switch (aParams.optionalCloneInfo().type()) { michael@0: case CursorUnionType::TSerializedStructuredCloneReadInfo: { michael@0: nsTArray blobs; michael@0: IDBObjectStore::ConvertActorsToBlobs(aParams.blobsChild(), blobs); michael@0: michael@0: const SerializedStructuredCloneReadInfo& cloneInfo = michael@0: aParams.optionalCloneInfo().get_SerializedStructuredCloneReadInfo(); michael@0: michael@0: rv = mIndex->OpenCursorFromChildProcess(request, direction, aParams.key(), michael@0: aParams.objectKey(), cloneInfo, michael@0: blobs, michael@0: getter_AddRefs(cursor)); michael@0: NS_ENSURE_SUCCESS(rv, false); michael@0: } break; michael@0: michael@0: case CursorUnionType::Tvoid_t: michael@0: MOZ_ASSERT(aParams.blobsChild().IsEmpty()); michael@0: michael@0: rv = mIndex->OpenCursorFromChildProcess(request, direction, aParams.key(), michael@0: aParams.objectKey(), michael@0: getter_AddRefs(cursor)); michael@0: NS_ENSURE_SUCCESS(rv, false); michael@0: break; michael@0: michael@0: default: michael@0: MOZ_CRASH("Unknown union type!"); michael@0: } michael@0: michael@0: actor->SetCursor(cursor); michael@0: return true; michael@0: } michael@0: michael@0: PIndexedDBRequestChild* michael@0: IndexedDBIndexChild::AllocPIndexedDBRequestChild(const IndexRequestParams& aParams) michael@0: { michael@0: MOZ_CRASH("Caller is supposed to manually construct a request!"); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBIndexChild::DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: PIndexedDBCursorChild* michael@0: IndexedDBIndexChild::AllocPIndexedDBCursorChild( michael@0: const IndexCursorConstructorParams& aParams) michael@0: { michael@0: return new IndexedDBCursorChild(); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBIndexChild::DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBCursorChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBCursorChild::IndexedDBCursorChild() michael@0: : mCursor(nullptr) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBCursorChild); michael@0: } michael@0: michael@0: IndexedDBCursorChild::~IndexedDBCursorChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBCursorChild); michael@0: MOZ_ASSERT(!mCursor); michael@0: MOZ_ASSERT(!mStrongCursor); michael@0: } michael@0: michael@0: void michael@0: IndexedDBCursorChild::SetCursor(IDBCursor* aCursor) michael@0: { michael@0: MOZ_ASSERT(aCursor); michael@0: MOZ_ASSERT(!mCursor); michael@0: michael@0: aCursor->SetActor(this); michael@0: michael@0: mCursor = aCursor; michael@0: mStrongCursor = aCursor; michael@0: } michael@0: michael@0: void michael@0: IndexedDBCursorChild::Disconnect() michael@0: { michael@0: const InfallibleTArray& requests = michael@0: ManagedPIndexedDBRequestChild(); michael@0: for (uint32_t i = 0; i < requests.Length(); ++i) { michael@0: static_cast(requests[i])->Disconnect(); michael@0: } michael@0: } michael@0: michael@0: void michael@0: IndexedDBCursorChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: if (mCursor) { michael@0: mCursor->SetActor(static_cast(nullptr)); michael@0: #ifdef DEBUG michael@0: mCursor = nullptr; michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: PIndexedDBRequestChild* michael@0: IndexedDBCursorChild::AllocPIndexedDBRequestChild(const CursorRequestParams& aParams) michael@0: { michael@0: MOZ_CRASH("Caller is supposed to manually construct a request!"); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBCursorChild::DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBRequestChildBase michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBRequestChildBase::IndexedDBRequestChildBase( michael@0: AsyncConnectionHelper* aHelper) michael@0: : mHelper(aHelper) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBRequestChildBase); michael@0: } michael@0: michael@0: IndexedDBRequestChildBase::~IndexedDBRequestChildBase() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBRequestChildBase); michael@0: } michael@0: michael@0: IDBRequest* michael@0: IndexedDBRequestChildBase::GetRequest() const michael@0: { michael@0: return mHelper ? mHelper->GetRequest() : nullptr; michael@0: } michael@0: michael@0: void michael@0: IndexedDBRequestChildBase::Disconnect() michael@0: { michael@0: if (mHelper) { michael@0: IDBRequest* request = mHelper->GetRequest(); michael@0: michael@0: if (request->IsPending()) { michael@0: request->SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); michael@0: michael@0: IDBTransaction* transaction = mHelper->GetTransaction(); michael@0: if (transaction) { michael@0: transaction->OnRequestDisconnected(); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: bool michael@0: IndexedDBRequestChildBase::Recv__delete__(const ResponseValue& aResponse) michael@0: { michael@0: MOZ_CRASH("This should be overridden!"); michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBObjectStoreRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBObjectStoreRequestChild::IndexedDBObjectStoreRequestChild( michael@0: AsyncConnectionHelper* aHelper, michael@0: IDBObjectStore* aObjectStore, michael@0: RequestType aRequestType) michael@0: : IndexedDBRequestChildBase(aHelper), mObjectStore(aObjectStore), michael@0: mRequestType(aRequestType) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBObjectStoreRequestChild); michael@0: MOZ_ASSERT(aHelper); michael@0: MOZ_ASSERT(aObjectStore); michael@0: MOZ_ASSERT(aRequestType > ParamsUnionType::T__None && michael@0: aRequestType <= ParamsUnionType::T__Last); michael@0: } michael@0: michael@0: IndexedDBObjectStoreRequestChild::~IndexedDBObjectStoreRequestChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBObjectStoreRequestChild); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBObjectStoreRequestChild::Recv__delete__(const ResponseValue& aResponse) michael@0: { michael@0: switch (aResponse.type()) { michael@0: case ResponseValue::Tnsresult: michael@0: break; michael@0: case ResponseValue::TGetResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TGetParams); michael@0: break; michael@0: case ResponseValue::TGetAllResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TGetAllParams); michael@0: break; michael@0: case ResponseValue::TGetAllKeysResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TGetAllKeysParams); michael@0: break; michael@0: case ResponseValue::TAddResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TAddParams); michael@0: break; michael@0: case ResponseValue::TPutResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TPutParams); michael@0: break; michael@0: case ResponseValue::TDeleteResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TDeleteParams); michael@0: break; michael@0: case ResponseValue::TClearResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TClearParams); michael@0: break; michael@0: case ResponseValue::TCountResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TCountParams); michael@0: break; michael@0: case ResponseValue::TOpenCursorResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TOpenCursorParams || michael@0: mRequestType == ParamsUnionType::TOpenKeyCursorParams); michael@0: break; michael@0: michael@0: default: michael@0: MOZ_CRASH("Received invalid response parameters!"); michael@0: } michael@0: michael@0: nsresult rv = mHelper->OnParentProcessRequestComplete(aResponse); michael@0: NS_ENSURE_SUCCESS(rv, false); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBIndexRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBIndexRequestChild::IndexedDBIndexRequestChild( michael@0: AsyncConnectionHelper* aHelper, michael@0: IDBIndex* aIndex, michael@0: RequestType aRequestType) michael@0: : IndexedDBRequestChildBase(aHelper), mIndex(aIndex), mRequestType(aRequestType) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBIndexRequestChild); michael@0: MOZ_ASSERT(aHelper); michael@0: MOZ_ASSERT(aIndex); michael@0: MOZ_ASSERT(aRequestType > ParamsUnionType::T__None && michael@0: aRequestType <= ParamsUnionType::T__Last); michael@0: } michael@0: michael@0: IndexedDBIndexRequestChild::~IndexedDBIndexRequestChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBIndexRequestChild); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBIndexRequestChild::Recv__delete__(const ResponseValue& aResponse) michael@0: { michael@0: switch (aResponse.type()) { michael@0: case ResponseValue::Tnsresult: michael@0: break; michael@0: case ResponseValue::TGetResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TGetParams); michael@0: break; michael@0: case ResponseValue::TGetKeyResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TGetKeyParams); michael@0: break; michael@0: case ResponseValue::TGetAllResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TGetAllParams); michael@0: break; michael@0: case ResponseValue::TGetAllKeysResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TGetAllKeysParams); michael@0: break; michael@0: case ResponseValue::TCountResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TCountParams); michael@0: break; michael@0: case ResponseValue::TOpenCursorResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TOpenCursorParams || michael@0: mRequestType == ParamsUnionType::TOpenKeyCursorParams); michael@0: break; michael@0: michael@0: default: michael@0: MOZ_CRASH("Received invalid response parameters!"); michael@0: } michael@0: michael@0: nsresult rv = mHelper->OnParentProcessRequestComplete(aResponse); michael@0: NS_ENSURE_SUCCESS(rv, false); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBCursorRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBCursorRequestChild::IndexedDBCursorRequestChild( michael@0: AsyncConnectionHelper* aHelper, michael@0: IDBCursor* aCursor, michael@0: RequestType aRequestType) michael@0: : IndexedDBRequestChildBase(aHelper), mCursor(aCursor), michael@0: mRequestType(aRequestType) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBCursorRequestChild); michael@0: MOZ_ASSERT(aHelper); michael@0: MOZ_ASSERT(aCursor); michael@0: MOZ_ASSERT(aRequestType > ParamsUnionType::T__None && michael@0: aRequestType <= ParamsUnionType::T__Last); michael@0: } michael@0: michael@0: IndexedDBCursorRequestChild::~IndexedDBCursorRequestChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBCursorRequestChild); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBCursorRequestChild::Recv__delete__(const ResponseValue& aResponse) michael@0: { michael@0: switch (aResponse.type()) { michael@0: case ResponseValue::Tnsresult: michael@0: break; michael@0: case ResponseValue::TContinueResponse: michael@0: MOZ_ASSERT(mRequestType == ParamsUnionType::TContinueParams); michael@0: break; michael@0: michael@0: default: michael@0: MOZ_CRASH("Received invalid response parameters!"); michael@0: } michael@0: michael@0: nsresult rv = mHelper->OnParentProcessRequestComplete(aResponse); michael@0: NS_ENSURE_SUCCESS(rv, false); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * IndexedDBDeleteDatabaseRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: IndexedDBDeleteDatabaseRequestChild::IndexedDBDeleteDatabaseRequestChild( michael@0: IDBFactory* aFactory, michael@0: IDBOpenDBRequest* aOpenRequest, michael@0: const nsACString& aDatabaseId) michael@0: : mFactory(aFactory), mOpenRequest(aOpenRequest), mDatabaseId(aDatabaseId) michael@0: { michael@0: MOZ_COUNT_CTOR(IndexedDBDeleteDatabaseRequestChild); michael@0: MOZ_ASSERT(aFactory); michael@0: MOZ_ASSERT(aOpenRequest); michael@0: MOZ_ASSERT(!aDatabaseId.IsEmpty()); michael@0: } michael@0: michael@0: IndexedDBDeleteDatabaseRequestChild::~IndexedDBDeleteDatabaseRequestChild() michael@0: { michael@0: MOZ_COUNT_DTOR(IndexedDBDeleteDatabaseRequestChild); michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDeleteDatabaseRequestChild::Recv__delete__(const nsresult& aRv) michael@0: { michael@0: nsRefPtr helper = michael@0: new IPCDeleteDatabaseHelper(mOpenRequest); michael@0: michael@0: if (NS_SUCCEEDED(aRv)) { michael@0: DatabaseInfo::Remove(mDatabaseId); michael@0: } michael@0: else { michael@0: helper->SetError(aRv); michael@0: } michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(helper->Dispatch(&target))) { michael@0: NS_WARNING("Dispatch of IPCSetVersionHelper failed!"); michael@0: return false; michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: IndexedDBDeleteDatabaseRequestChild::RecvBlocked( michael@0: const uint64_t& aCurrentVersion) michael@0: { michael@0: MOZ_ASSERT(mOpenRequest); michael@0: michael@0: nsCOMPtr runnable = michael@0: IDBVersionChangeEvent::CreateBlockedRunnable(mOpenRequest, michael@0: aCurrentVersion, 0); michael@0: michael@0: ImmediateRunEventTarget target; michael@0: if (NS_FAILED(target.Dispatch(runnable, NS_DISPATCH_NORMAL))) { michael@0: NS_WARNING("Dispatch of blocked event failed!"); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * Helpers michael@0: ******************************************************************************/ michael@0: michael@0: nsresult michael@0: IPCOpenDatabaseHelper::UnpackResponseFromParentProcess( michael@0: const ResponseValue& aResponseValue) michael@0: { michael@0: NS_NOTREACHED("Should never get here!"); michael@0: return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; michael@0: } michael@0: michael@0: AsyncConnectionHelper::ChildProcessSendResult michael@0: IPCOpenDatabaseHelper::SendResponseToChildProcess(nsresult aResultCode) michael@0: { michael@0: MOZ_CRASH("Don't call me!"); michael@0: } michael@0: michael@0: nsresult michael@0: IPCOpenDatabaseHelper::DoDatabaseWork(mozIStorageConnection* aConnection) michael@0: { michael@0: MOZ_CRASH("Don't call me!"); michael@0: } michael@0: michael@0: nsresult michael@0: IPCOpenDatabaseHelper::GetSuccessResult(JSContext* aCx, JS::MutableHandle aVal) michael@0: { michael@0: return WrapNative(aCx, NS_ISUPPORTS_CAST(EventTarget*, mDatabase), michael@0: aVal); michael@0: } michael@0: michael@0: nsresult michael@0: IPCSetVersionHelper::UnpackResponseFromParentProcess( michael@0: const ResponseValue& aResponseValue) michael@0: { michael@0: NS_NOTREACHED("Should never get here!"); michael@0: return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; michael@0: } michael@0: michael@0: AsyncConnectionHelper::ChildProcessSendResult michael@0: IPCSetVersionHelper::SendResponseToChildProcess(nsresult aResultCode) michael@0: { michael@0: MOZ_CRASH("Don't call me!"); michael@0: } michael@0: michael@0: nsresult michael@0: IPCSetVersionHelper::DoDatabaseWork(mozIStorageConnection* aConnection) michael@0: { michael@0: MOZ_CRASH("Don't call me!"); michael@0: } michael@0: michael@0: already_AddRefed michael@0: IPCSetVersionHelper::CreateSuccessEvent(mozilla::dom::EventTarget* aOwner) michael@0: { michael@0: return IDBVersionChangeEvent::CreateUpgradeNeeded(aOwner, michael@0: mOldVersion, michael@0: mRequestedVersion); michael@0: } michael@0: michael@0: nsresult michael@0: IPCSetVersionHelper::GetSuccessResult(JSContext* aCx, JS::MutableHandle aVal) michael@0: { michael@0: mOpenRequest->SetTransaction(mTransaction); michael@0: michael@0: return WrapNative(aCx, NS_ISUPPORTS_CAST(EventTarget*, mDatabase), michael@0: aVal); michael@0: } michael@0: michael@0: nsresult michael@0: IPCDeleteDatabaseHelper::UnpackResponseFromParentProcess( michael@0: const ResponseValue& aResponseValue) michael@0: { michael@0: MOZ_CRASH("Don't call me!"); michael@0: } michael@0: michael@0: AsyncConnectionHelper::ChildProcessSendResult michael@0: IPCDeleteDatabaseHelper::SendResponseToChildProcess(nsresult aResultCode) michael@0: { michael@0: MOZ_CRASH("Don't call me!"); michael@0: } michael@0: michael@0: nsresult michael@0: IPCDeleteDatabaseHelper::GetSuccessResult(JSContext* aCx, JS::MutableHandle aVal) michael@0: { michael@0: aVal.setUndefined(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: IPCDeleteDatabaseHelper::DoDatabaseWork(mozIStorageConnection* aConnection) michael@0: { michael@0: MOZ_CRASH("Don't call me!"); michael@0: }