// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef GPU_WEBGPU_CALLBACK_H_ #define GPU_WEBGPU_CALLBACK_H_ #include #include "base/callback.h" namespace gpu::webgpu { // WGPUCallback is a heap-allocated version of // base::OnceCallback or base::RepeatingCallback. // It is allocated on the heap so that it can be reinterpret_cast to/from // void* and passed to WGPU C callbacks. // // Example: // WGPUOnceCallback* callback = // BindWGPUOnceCallback(func, arg1); // // // |someWGPUFunction| expects callback function with arguments: // // Args... args, void* userdata. // // When it is called, it will forward to func(arg1, args...). // GetProcs().someWGPUFunction( // callback->UnboundCallback(), callback->AsUserdata()); template class WGPUCallbackBase; template class WGPUOnceCallback; template class WGPURepeatingCallback; template