ActorUtils.h (2953B)
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/. */ 6 7 #ifndef mozilla_dom_cache_ActorUtils_h 8 #define mozilla_dom_cache_ActorUtils_h 9 10 #include "mozilla/dom/cache/Types.h" 11 12 namespace mozilla { 13 14 namespace ipc { 15 class PBackgroundParent; 16 class PrincipalInfo; 17 } // namespace ipc 18 19 namespace dom::cache { 20 class ActorChild; 21 class BoundStorageKeyParent; 22 class PCacheChild; 23 class PCacheParent; 24 class PCacheStreamControlChild; 25 class PCacheStreamControlParent; 26 class PCacheStorageChild; 27 class PCacheStorageParent; 28 29 // Factory methods for use in ipc/glue methods. Implemented in individual actor 30 // cpp files. 31 32 // Creates and returns a CacheChild object 33 // 34 // aParentActor -> CacheChild being a non-top level action gets created as a 35 // child actor 36 // If a parent wishes to get notified for child's lifecycle events like 37 // destruction, it can do so by implementing and passing itself as a ActorChild 38 // interface as parameter 39 already_AddRefed<PCacheChild> AllocPCacheChild( 40 ActorChild* aParentActor = nullptr); 41 42 // Helper method to carry-out the destruction of CacheChild actor 43 void DeallocPCacheChild(PCacheChild* aActor); 44 45 // Helper method to carry-out the destruction of CacheParent actor 46 void DeallocPCacheParent(PCacheParent* aActor); 47 48 // Similar to CacheChild above, parent can get notified for 49 // CacheStreamControlChild lifecycle events 50 already_AddRefed<PCacheStreamControlChild> AllocPCacheStreamControlChild( 51 ActorChild* aParentActor = nullptr); 52 53 void DeallocPCacheStreamControlParent(PCacheStreamControlParent* aActor); 54 55 // This method is used on the main process side to create CacheStorageParent 56 // actor in response to construction request received from the child process 57 // side 58 // 59 // caller is expected to pass below parameters: 60 // aBackgroundIPCActor -> BackgroundParent actor; required to verify 61 // PrincipalInfo aBoundStorageKeyActor -> In case this is getting created on 62 // BoundStorageKeyParent actor, nullptr otherwise aNamespace -> Namespace 63 // corresponding to this request aPrincipalInfo -> PrincipalInfo corresponding 64 // to this request 65 already_AddRefed<PCacheStorageParent> AllocPCacheStorageParent( 66 mozilla::ipc::PBackgroundParent* aBackgroundIPCActor, 67 PBoundStorageKeyParent* aBoundStorageKeyActor, Namespace aNamespace, 68 const mozilla::ipc::PrincipalInfo& aPrincipalInfo); 69 70 // Helper method to carry-out the destruction of CacheStorageChild actor 71 void DeallocPCacheStorageChild(PCacheStorageChild* aActor); 72 73 // Helper method to carry-out the destruction of CacheStorageParent actor 74 void DeallocPCacheStorageParent(PCacheStorageParent* aActor); 75 76 } // namespace dom::cache 77 } // namespace mozilla 78 79 #endif // mozilla_dom_cache_ActorUtils_h