dawn/node: Implement Adapter.GetAdapterInfo()

Bug: dawn:1761
Change-Id: Ia1bf7841052897b69de50d6db41b05ee5645be47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128104
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/node/binding/CMakeLists.txt b/src/dawn/node/binding/CMakeLists.txt
index a4e427b..55c3713 100644
--- a/src/dawn/node/binding/CMakeLists.txt
+++ b/src/dawn/node/binding/CMakeLists.txt
@@ -25,6 +25,8 @@
     "GPU.h"
     "GPUAdapter.cpp"
     "GPUAdapter.h"
+    "GPUAdapterInfo.cpp"
+    "GPUAdapterInfo.h"
     "GPUBindGroup.cpp"
     "GPUBindGroup.h"
     "GPUBindGroupLayout.cpp"
diff --git a/src/dawn/node/binding/GPUAdapter.cpp b/src/dawn/node/binding/GPUAdapter.cpp
index 3b18ffa..e65378d 100644
--- a/src/dawn/node/binding/GPUAdapter.cpp
+++ b/src/dawn/node/binding/GPUAdapter.cpp
@@ -21,6 +21,7 @@
 #include "src/dawn/node/binding/Converter.h"
 #include "src/dawn/node/binding/Errors.h"
 #include "src/dawn/node/binding/Flags.h"
+#include "src/dawn/node/binding/GPUAdapterInfo.h"
 #include "src/dawn/node/binding/GPUDevice.h"
 #include "src/dawn/node/binding/GPUSupportedFeatures.h"
 #include "src/dawn/node/binding/GPUSupportedLimits.h"
@@ -203,9 +204,15 @@
 }
 
 interop::Promise<interop::Interface<interop::GPUAdapterInfo>> GPUAdapter::requestAdapterInfo(
-    Napi::Env,
+    Napi::Env env,
     std::vector<std::string> unmaskHints) {
-    UNIMPLEMENTED();
+    interop::Promise<interop::Interface<interop::GPUAdapterInfo>> promise(env, PROMISE_INFO);
+
+    WGPUAdapterProperties adapterProperties = {};
+    adapter_.GetProperties(&adapterProperties);
+
+    promise.Resolve(interop::GPUAdapterInfo::Create<GPUAdapterInfo>(env, adapterProperties));
+    return promise;
 }
 
 }  // namespace wgpu::binding
diff --git a/src/dawn/node/binding/GPUAdapterInfo.cpp b/src/dawn/node/binding/GPUAdapterInfo.cpp
new file mode 100644
index 0000000..8263f4f
--- /dev/null
+++ b/src/dawn/node/binding/GPUAdapterInfo.cpp
@@ -0,0 +1,45 @@
+// Copyright 2023 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/dawn/node/binding/GPUAdapterInfo.h"
+
+namespace wgpu::binding {
+
+////////////////////////////////////////////////////////////////////////////////
+// wgpu::bindings::GPUAdapterInfo
+////////////////////////////////////////////////////////////////////////////////
+
+GPUAdapterInfo::GPUAdapterInfo(WGPUAdapterProperties properties)
+    : vendor_(properties.vendorName),
+      architecture_(properties.architecture),
+      device_(properties.name),
+      description_(properties.driverDescription) {}
+
+std::string GPUAdapterInfo::getVendor(Napi::Env) {
+    return vendor_;
+}
+
+std::string GPUAdapterInfo::getArchitecture(Napi::Env) {
+    return architecture_;
+}
+
+std::string GPUAdapterInfo::getDevice(Napi::Env) {
+    return device_;
+}
+
+std::string GPUAdapterInfo::getDescription(Napi::Env) {
+    return description_;
+}
+
+}  // namespace wgpu::binding
diff --git a/src/dawn/node/binding/GPUAdapterInfo.h b/src/dawn/node/binding/GPUAdapterInfo.h
new file mode 100644
index 0000000..890322a
--- /dev/null
+++ b/src/dawn/node/binding/GPUAdapterInfo.h
@@ -0,0 +1,48 @@
+// Copyright 2023 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_DAWN_NODE_BINDING_GPUADAPTERINFO_H_
+#define SRC_DAWN_NODE_BINDING_GPUADAPTERINFO_H_
+
+#include <string>
+
+#include "dawn/native/DawnNative.h"
+#include "dawn/webgpu_cpp.h"
+
+#include "src/dawn/node/interop/Napi.h"
+#include "src/dawn/node/interop/WebGPU.h"
+
+namespace wgpu::binding {
+
+// GPUAdapterInfo is an implementation of interop::GPUAdapterInfo.
+class GPUAdapterInfo final : public interop::GPUAdapterInfo {
+  public:
+    explicit GPUAdapterInfo(WGPUAdapterProperties);
+
+    // interop::GPUAdapterInfo interface compliance
+    std::string getVendor(Napi::Env) override;
+    std::string getArchitecture(Napi::Env) override;
+    std::string getDevice(Napi::Env) override;
+    std::string getDescription(Napi::Env) override;
+
+  private:
+    std::string vendor_;
+    std::string architecture_;
+    std::string device_;
+    std::string description_;
+};
+
+}  // namespace wgpu::binding
+
+#endif  // SRC_DAWN_NODE_BINDING_GPUADAPTERINFO_H_