mozilla::ipc::IPCResult CacheOpChild::Recv__delete__(const ErrorResult& aRv, const CacheOpResult& aResult) { NS_ASSERT_OWNINGTHREAD(CacheOpChild); if (NS_WARN_IF(aRv.Failed())) { MOZ_ASSERT(aResult.type() == CacheOpResult::Tvoid_t); // TODO: Remove this const_cast (bug 1152078). // It is safe for now since this ErrorResult is handed off to us by IPDL // and is thrown into the trash afterwards. mPromise->MaybeReject(const_cast<ErrorResult&>(aRv)); mPromise = nullptr; return IPC_OK(); } switch (aResult.type()) { case CacheOpResult::TCacheMatchResult: { HandleResponse(aResult.get_CacheMatchResult().responseOrVoid()); break; } case CacheOpResult::TCacheMatchAllResult: { HandleResponseList(aResult.get_CacheMatchAllResult().responseList()); break; } case CacheOpResult::TCachePutAllResult: { mPromise->MaybeResolveWithUndefined(); break; } case CacheOpResult::TCacheDeleteResult: { mPromise->MaybeResolve(aResult.get_CacheDeleteResult().success()); break; } case CacheOpResult::TCacheKeysResult: { HandleRequestList(aResult.get_CacheKeysResult().requestList()); break; } case CacheOpResult::TStorageMatchResult: { HandleResponse(aResult.get_StorageMatchResult().responseOrVoid()); break; } case CacheOpResult::TStorageHasResult: { mPromise->MaybeResolve(aResult.get_StorageHasResult().success()); break; } case CacheOpResult::TStorageOpenResult: { auto actor = static_cast<CacheChild*>( aResult.get_StorageOpenResult().actorChild()); actor->SetWorkerHolder(GetWorkerHolder()); RefPtr<Cache> cache = new Cache(mGlobal, actor); mPromise->MaybeResolve(cache); break; } case CacheOpResult::TStorageDeleteResult: { mPromise->MaybeResolve(aResult.get_StorageDeleteResult().success()); break; } case CacheOpResult::TStorageKeysResult: { mPromise->MaybeResolve(aResult.get_StorageKeysResult().keyList()); break; } default: MOZ_CRASH("Unknown Cache op result type!"); } mPromise = nullptr; return IPC_OK(); }
mozilla::ipc::IPCResult CacheOpChild::Recv__delete__( const ErrorResult& aRv, const CacheOpResult& aResult) { NS_ASSERT_OWNINGTHREAD(CacheOpChild); if (NS_WARN_IF(aRv.Failed())) { MOZ_DIAGNOSTIC_ASSERT(aResult.type() == CacheOpResult::Tvoid_t); // TODO: Remove this const_cast (bug 1152078). // It is safe for now since this ErrorResult is handed off to us by IPDL // and is thrown into the trash afterwards. mPromise->MaybeReject(const_cast<ErrorResult&>(aRv)); mPromise = nullptr; return IPC_OK(); } switch (aResult.type()) { case CacheOpResult::TCacheMatchResult: { HandleResponse(aResult.get_CacheMatchResult().maybeResponse()); break; } case CacheOpResult::TCacheMatchAllResult: { HandleResponseList(aResult.get_CacheMatchAllResult().responseList()); break; } case CacheOpResult::TCachePutAllResult: { mPromise->MaybeResolveWithUndefined(); break; } case CacheOpResult::TCacheDeleteResult: { mPromise->MaybeResolve(aResult.get_CacheDeleteResult().success()); break; } case CacheOpResult::TCacheKeysResult: { HandleRequestList(aResult.get_CacheKeysResult().requestList()); break; } case CacheOpResult::TStorageMatchResult: { HandleResponse(aResult.get_StorageMatchResult().maybeResponse()); break; } case CacheOpResult::TStorageHasResult: { mPromise->MaybeResolve(aResult.get_StorageHasResult().success()); break; } case CacheOpResult::TStorageOpenResult: { auto result = aResult.get_StorageOpenResult(); auto actor = static_cast<CacheChild*>(result.actorChild()); // If we have a success status then we should have an actor. Gracefully // reject instead of crashing, though, if we get a nullptr here. MOZ_DIAGNOSTIC_ASSERT(actor); if (!actor) { ErrorResult status; status.ThrowTypeError<MSG_CACHE_OPEN_FAILED>(); mPromise->MaybeReject(status); break; } RefPtr<CacheWorkerHolder> workerHolder = CacheWorkerHolder::PreferBehavior( GetWorkerHolder(), CacheWorkerHolder::AllowIdleShutdownStart); actor->SetWorkerHolder(workerHolder); RefPtr<Cache> cache = new Cache(mGlobal, actor, result.ns()); mPromise->MaybeResolve(cache); break; } case CacheOpResult::TStorageDeleteResult: { mPromise->MaybeResolve(aResult.get_StorageDeleteResult().success()); break; } case CacheOpResult::TStorageKeysResult: { mPromise->MaybeResolve(aResult.get_StorageKeysResult().keyList()); break; } default: MOZ_CRASH("Unknown Cache op result type!"); } mPromise = nullptr; return IPC_OK(); }