Bug 1733673 [wpt PR 31066] - Annotate CSS Transforms WPT reftests as fuzzy where...
[gecko.git] / dom / cache / CacheParent.cpp
blob811e2c2d7ae41d882b92f52a416e67dad148ab04
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/cache/CacheParent.h"
9 #include "mozilla/dom/cache/CacheOpParent.h"
10 #include "nsCOMPtr.h"
12 namespace mozilla::dom::cache {
14 // Declared in ActorUtils.h
15 void DeallocPCacheParent(PCacheParent* aActor) { delete aActor; }
17 CacheParent::CacheParent(SafeRefPtr<cache::Manager> aManager, CacheId aCacheId)
18 : mManager(std::move(aManager)), mCacheId(aCacheId) {
19 MOZ_COUNT_CTOR(cache::CacheParent);
20 MOZ_DIAGNOSTIC_ASSERT(mManager);
21 mManager->AddRefCacheId(mCacheId);
24 CacheParent::~CacheParent() {
25 MOZ_COUNT_DTOR(cache::CacheParent);
26 MOZ_DIAGNOSTIC_ASSERT(!mManager);
29 void CacheParent::ActorDestroy(ActorDestroyReason aReason) {
30 MOZ_DIAGNOSTIC_ASSERT(mManager);
31 mManager->ReleaseCacheId(mCacheId);
32 mManager = nullptr;
35 PCacheOpParent* CacheParent::AllocPCacheOpParent(const CacheOpArgs& aOpArgs) {
36 if (aOpArgs.type() != CacheOpArgs::TCacheMatchArgs &&
37 aOpArgs.type() != CacheOpArgs::TCacheMatchAllArgs &&
38 aOpArgs.type() != CacheOpArgs::TCachePutAllArgs &&
39 aOpArgs.type() != CacheOpArgs::TCacheDeleteArgs &&
40 aOpArgs.type() != CacheOpArgs::TCacheKeysArgs) {
41 MOZ_CRASH("Invalid operation sent to Cache actor!");
44 return new CacheOpParent(Manager(), mCacheId, aOpArgs);
47 bool CacheParent::DeallocPCacheOpParent(PCacheOpParent* aActor) {
48 delete aActor;
49 return true;
52 mozilla::ipc::IPCResult CacheParent::RecvPCacheOpConstructor(
53 PCacheOpParent* aActor, const CacheOpArgs& aOpArgs) {
54 auto actor = static_cast<CacheOpParent*>(aActor);
55 actor->Execute(mManager.clonePtr());
56 return IPC_OK();
59 mozilla::ipc::IPCResult CacheParent::RecvTeardown() {
60 // If child process is gone, warn and allow actor to clean up normally
61 QM_WARNONLY_TRY(OkIf(Send__delete__(this)));
62 return IPC_OK();
65 } // namespace mozilla::dom::cache