/work/obj-fuzz/dist/include/mozilla/webgpu/InstanceProvider.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef WEBGPU_INSTANCE_PROVIDER_H_ |
7 | | #define WEBGPU_INSTANCE_PROVIDER_H_ |
8 | | |
9 | | #include "mozilla/AlreadyAddRefed.h" |
10 | | #include "mozilla/Maybe.h" |
11 | | #include "mozilla/RefPtr.h" |
12 | | |
13 | | class nsCycleCollectionTraversalCallback; |
14 | | class nsIGlobalObject; |
15 | | |
16 | | namespace mozilla { |
17 | | namespace webgpu { |
18 | | class Instance; |
19 | | |
20 | | class InstanceProvider |
21 | | { |
22 | | private: |
23 | | nsIGlobalObject* const mGlobal; |
24 | | mutable Maybe<RefPtr<Instance>> mInstance; |
25 | | |
26 | | protected: |
27 | | explicit InstanceProvider(nsIGlobalObject* global); |
28 | | virtual ~InstanceProvider(); |
29 | | |
30 | | public: |
31 | | already_AddRefed<Instance> Webgpu() const; |
32 | | |
33 | 0 | nsIGlobalObject* GetParentObject() const { return mGlobal; } |
34 | | |
35 | | void CcTraverse(nsCycleCollectionTraversalCallback&) const; |
36 | | void CcUnlink(); |
37 | | }; |
38 | | |
39 | | template<typename T> |
40 | | void |
41 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& callback, |
42 | | const Maybe<T>& field, |
43 | | const char* name, uint32_t flags) |
44 | | { |
45 | | if (field) { |
46 | | CycleCollectionNoteChild(callback, field.value(), name, flags); |
47 | | } |
48 | | } |
49 | | |
50 | | template<typename T> |
51 | | void |
52 | | ImplCycleCollectionUnlink(Maybe<T>& field) |
53 | | { |
54 | | field = Nothing(); |
55 | | } |
56 | | |
57 | | } // namespace webgpu |
58 | | } // namespace mozilla |
59 | | |
60 | | #endif // WEBGPU_INSTANCE_PROVIDER_H_ |