Bug 1750871 - run mochitest-remote on fission everywhere. r=releng-reviewers,aki
[gecko.git] / dom / cache / ActorChild.cpp
blob3d5eec8642ad0c6a55e512233b225a2b467f97b5
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/ActorChild.h"
9 #include "mozilla/dom/cache/CacheWorkerRef.h"
10 #include "nsThreadUtils.h"
12 namespace mozilla::dom::cache {
14 void ActorChild::SetWorkerRef(SafeRefPtr<CacheWorkerRef> aWorkerRef) {
15 // Some of the Cache actors can have multiple DOM objects associated with
16 // them. In this case the workerRef will be added multiple times. This is
17 // permitted, but the workerRef should be the same each time.
18 if (mWorkerRef) {
19 // XXX Here, we don't use aWorkerRef, so we unnecessarily add-refed... This
20 // might be a case to show in the raw pointer guideline as a possible
21 // exception, if warranted by performance analyses.
23 MOZ_DIAGNOSTIC_ASSERT(mWorkerRef == aWorkerRef);
24 return;
27 mWorkerRef = std::move(aWorkerRef);
28 if (mWorkerRef) {
29 mWorkerRef->AddActor(*this);
33 void ActorChild::RemoveWorkerRef() {
34 MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerRef);
35 if (mWorkerRef) {
36 mWorkerRef->RemoveActor(*this);
37 mWorkerRef = nullptr;
41 const SafeRefPtr<CacheWorkerRef>& ActorChild::GetWorkerRefPtr() const {
42 return mWorkerRef;
45 bool ActorChild::WorkerRefNotified() const {
46 return mWorkerRef && mWorkerRef->Notified();
49 ActorChild::ActorChild() = default;
51 ActorChild::~ActorChild() { MOZ_DIAGNOSTIC_ASSERT(!mWorkerRef); }
53 } // namespace mozilla::dom::cache