ActorChild.h (1713B)
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_ActioChild_h 8 #define mozilla_dom_cache_ActioChild_h 9 10 #include "mozilla/dom/SafeRefPtr.h" 11 12 namespace mozilla::dom::cache { 13 14 class CacheWorkerRef; 15 16 // ActorChild is used in parent-child hierachies where parent actor implements 17 // the interface and expects the child actor class to notify it for various 18 // reasons. Child actor cannot bind directly to it's parent actor class (i.e. 19 // manager) as it could have multiple managers. 20 // TODO: I think it would be better to move this to a more general location as 21 // this is very generic interface and can represent any parent-child actor 22 // relationship. 23 class ActorChild { 24 public: 25 virtual void StartDestroy() = 0; 26 virtual void NoteDeletedActor() { /*no-op*/ } 27 28 protected: 29 ActorChild() = default; 30 ~ActorChild() = default; 31 }; 32 33 // This is more specific interface and meant to be used by cache related 34 // parent/child actors. Each cache actor expects to keep the worker ref alive 35 // throughout it's lifetime. 36 class CacheActorChild : public ActorChild { 37 public: 38 void SetWorkerRef(SafeRefPtr<CacheWorkerRef> aWorkerRef); 39 const SafeRefPtr<CacheWorkerRef>& GetWorkerRefPtr() const; 40 void RemoveWorkerRef(); 41 42 protected: 43 CacheActorChild() = default; 44 ~CacheActorChild(); 45 46 private: 47 SafeRefPtr<CacheWorkerRef> mWorkerRef; 48 }; 49 50 } // namespace mozilla::dom::cache 51 52 #endif // mozilla_dom_cache_ActioChild_h