/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */ #ifndef WEBGPU_INSTANCE_PROVIDER_H_ #define WEBGPU_INSTANCE_PROVIDER_H_ #include "mozilla/AlreadyAddRefed.h" #include "mozilla/Maybe.h" #include "mozilla/RefPtr.h" class nsCycleCollectionTraversalCallback; class nsIGlobalObject; namespace mozilla { namespace webgpu { class Instance; class InstanceProvider { private: nsIGlobalObject* const mGlobal; mutable Maybe> mInstance; protected: explicit InstanceProvider(nsIGlobalObject* global); virtual ~InstanceProvider(); public: already_AddRefed Webgpu() const; nsIGlobalObject* GetParentObject() const { return mGlobal; } void CcTraverse(nsCycleCollectionTraversalCallback&) const; void CcUnlink(); }; template void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& callback, const Maybe& field, const char* name, uint32_t flags) { if (field) { CycleCollectionNoteChild(callback, field.value(), name, flags); } } template void ImplCycleCollectionUnlink(Maybe& field) { field = Nothing(); } } // namespace webgpu } // namespace mozilla #endif // WEBGPU_INSTANCE_PROVIDER_H_