Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / webgpu / Error.h
blob59e46c2e23499d0514cac08664659b34b5e99247
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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/. */
6 #ifndef GPU_Error_H_
7 #define GPU_Error_H_
9 #include "js/Value.h"
10 #include "mozilla/WeakPtr.h"
11 #include "nsIGlobalObject.h"
12 #include "nsString.h"
13 #include "ObjectModel.h"
15 namespace mozilla {
16 class ErrorResult;
17 namespace dom {
18 class GlobalObject;
19 } // namespace dom
20 namespace webgpu {
22 class Error : public nsWrapperCache, public SupportsWeakPtr {
23 protected:
24 nsCOMPtr<nsIGlobalObject> mGlobal;
25 nsString mMessage;
27 public:
28 GPU_DECL_CYCLE_COLLECTION(Error)
30 Error(nsIGlobalObject* const aGlobal, const nsAString& aMessage);
31 Error(nsIGlobalObject* const aGlobal, const nsACString& aMessage);
33 protected:
34 virtual ~Error() = default;
35 virtual void Cleanup() {}
37 public:
38 void GetMessage(nsAString& aMessage) const { aMessage = mMessage; }
39 nsIGlobalObject* GetParentObject() const { return mGlobal; }
40 virtual JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) = 0;
43 } // namespace webgpu
44 } // namespace mozilla
46 #endif // GPU_Error_H_