-
Notifications
You must be signed in to change notification settings - Fork 54
/
InstanceProvider.h
55 lines (42 loc) · 1.46 KB
/
InstanceProvider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* -*- 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<RefPtr<Instance>> mInstance;
protected:
explicit InstanceProvider(nsIGlobalObject* global);
virtual ~InstanceProvider();
public:
already_AddRefed<Instance> Webgpu() const;
nsIGlobalObject* GetParentObject() const { return mGlobal; }
void CcTraverse(nsCycleCollectionTraversalCallback&) const;
void CcUnlink();
};
template <typename T>
void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& callback,
const Maybe<T>& field, const char* name,
uint32_t flags) {
if (field) {
CycleCollectionNoteChild(callback, field.value(), name, flags);
}
}
template <typename T>
void ImplCycleCollectionUnlink(Maybe<T>& field) {
field = Nothing();
}
} // namespace webgpu
} // namespace mozilla
#endif // WEBGPU_INSTANCE_PROVIDER_H_