/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Helper for HoldStrongWorkerRefUntilMainThreadObserverNotified that optionally // holds a ThreadSafeWorkerRef until the given observer notification is notified // and also notifies a monitor. class WorkerTestUtilsObserver final : public nsIObserver { public:
WorkerTestUtilsObserver(const nsACString& aTopic,
RefPtr<ThreadSafeWorkerRef>&& aWorkerRef)
: mMonitor("WorkerTestUtils"),
mTopic(aTopic),
mWorkerRef(std::move(aWorkerRef)),
mRegistered(false),
mObserved(false) {}
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD Observe(nsISupports* aSubject, constchar* aTopic, const char16_t* aData) override { // We only register for one topic so we don't actually need to compare it.
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
MOZ_ALWAYS_SUCCEEDS(observerService->RemoveObserver(this, mTopic.get()));
// The ThreadSafeWorkerRef is responsible for / knows how to drop the // underlying StrongWorkerRef on the worker.
mWorkerRef = nullptr;
// Wait for the observer to be registered before returning control so that we // can be certain we won't miss an observer notification.
observer->WaitOnRegister();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.