Title: [291323] trunk/Source
Revision
291323
Author
[email protected]
Date
2022-03-15 16:44:09 -0700 (Tue, 15 Mar 2022)

Log Message

[WebGPU] Migrate from WTF::Function to WTF::CompletionHandler
https://bugs.webkit.org/show_bug.cgi?id=237925

Reviewed by Geoffrey Garen.

Source/WebCore/PAL:

CompletionHandlers make sure they are called exactly 1 time, and eagerly free up resources.

There are still 2 places which continue to use Functions, becuase they are expected to be
called multiple times:
- Device::setDeviceLostCallback()
- Device::setUncapturedErrorCallback()

* pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.cpp:
(PAL::WebGPU::AdapterImpl::requestDevice):
* pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.h:
* pal/graphics/WebGPU/Impl/WebGPUBufferImpl.cpp:
(PAL::WebGPU::BufferImpl::mapAsync):
* pal/graphics/WebGPU/Impl/WebGPUBufferImpl.h:
* pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.cpp:
(PAL::WebGPU::DeviceImpl::createComputePipelineAsync):
(PAL::WebGPU::DeviceImpl::createRenderPipelineAsync):
(PAL::WebGPU::DeviceImpl::popErrorScope):
* pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.h:
* pal/graphics/WebGPU/Impl/WebGPUImpl.cpp:
(PAL::WebGPU::GPUImpl::requestAdapter):
* pal/graphics/WebGPU/Impl/WebGPUImpl.h:
* pal/graphics/WebGPU/Impl/WebGPUQueueImpl.cpp:
(PAL::WebGPU::QueueImpl::onSubmittedWorkDone):
* pal/graphics/WebGPU/Impl/WebGPUQueueImpl.h:
* pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.cpp:
(PAL::WebGPU::ShaderModuleImpl::compilationInfo):
* pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.h:
* pal/graphics/WebGPU/WebGPU.h:
* pal/graphics/WebGPU/WebGPUAdapter.h:
* pal/graphics/WebGPU/WebGPUBuffer.h:
* pal/graphics/WebGPU/WebGPUDevice.h:
* pal/graphics/WebGPU/WebGPUQueue.h:
* pal/graphics/WebGPU/WebGPUShaderModule.h:

Source/WebGPU:

* WebGPU/Adapter.h:
* WebGPU/Adapter.mm:
(WebGPU::Adapter::requestDevice):
* WebGPU/Buffer.h:
* WebGPU/Buffer.mm:
(WebGPU::Buffer::mapAsync):
* WebGPU/ComputePipeline.mm:
(WebGPU::Device::createComputePipelineAsync):
* WebGPU/Device.h:
* WebGPU/Device.mm:
(WebGPU::Device::popErrorScope):
(WebGPU::Device::setDeviceLostCallback):
(WebGPU::Device::setUncapturedErrorCallback):
* WebGPU/Instance.h:
* WebGPU/Instance.mm:
(WebGPU::Instance::requestAdapter):
* WebGPU/Queue.h:
* WebGPU/Queue.mm:
(WebGPU::Queue::onSubmittedWorkDone):
* WebGPU/RenderPassEncoder.h:
* WebGPU/RenderPipeline.mm:
(WebGPU::Device::createRenderPipelineAsync):
* WebGPU/ShaderModule.h:
* WebGPU/ShaderModule.mm:
(WebGPU::ShaderModule::getCompilationInfo):

Source/WebKit:

* GPUProcess/graphics/WebGPU/RemoteAdapter.cpp:
(WebKit::RemoteAdapter::requestDevice):
* GPUProcess/graphics/WebGPU/RemoteAdapter.h:
* GPUProcess/graphics/WebGPU/RemoteBuffer.cpp:
(WebKit::RemoteBuffer::mapAsync):
* GPUProcess/graphics/WebGPU/RemoteBuffer.h:
* GPUProcess/graphics/WebGPU/RemoteDevice.cpp:
(WebKit::RemoteDevice::createComputePipelineAsync):
(WebKit::RemoteDevice::createRenderPipelineAsync):
(WebKit::RemoteDevice::popErrorScope):
* GPUProcess/graphics/WebGPU/RemoteDevice.h:
* GPUProcess/graphics/WebGPU/RemoteGPU.cpp:
(WebKit::RemoteGPU::requestAdapter):
* GPUProcess/graphics/WebGPU/RemoteGPU.h:
* GPUProcess/graphics/WebGPU/RemoteQueue.cpp:
(WebKit::RemoteQueue::onSubmittedWorkDone):
* GPUProcess/graphics/WebGPU/RemoteQueue.h:
* GPUProcess/graphics/WebGPU/RemoteShaderModule.cpp:
(WebKit::RemoteShaderModule::compilationInfo):
* GPUProcess/graphics/WebGPU/RemoteShaderModule.h:
* WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.cpp:
(WebKit::WebGPU::RemoteAdapterProxy::requestDevice):
* WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.h:
* WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp:
(WebKit::WebGPU::RemoteBufferProxy::mapAsync):
* WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h:
* WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.cpp:
(WebKit::WebGPU::RemoteDeviceProxy::createComputePipelineAsync):
(WebKit::WebGPU::RemoteDeviceProxy::createRenderPipelineAsync):
(WebKit::WebGPU::RemoteDeviceProxy::popErrorScope):
* WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.h:
* WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp:
(WebKit::RemoteGPUProxy::requestAdapter):
* WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h:
* WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.cpp:
(WebKit::WebGPU::RemoteQueueProxy::onSubmittedWorkDone):
* WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.h:
* WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.cpp:
(WebKit::WebGPU::RemoteShaderModuleProxy::compilationInfo):
* WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (291322 => 291323)


--- trunk/Source/WebCore/PAL/ChangeLog	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/ChangeLog	2022-03-15 23:44:09 UTC (rev 291323)
@@ -1,5 +1,46 @@
 2022-03-15  Myles C. Maxfield  <[email protected]>
 
+        [WebGPU] Migrate from WTF::Function to WTF::CompletionHandler
+        https://bugs.webkit.org/show_bug.cgi?id=237925
+
+        Reviewed by Geoffrey Garen.
+
+        CompletionHandlers make sure they are called exactly 1 time, and eagerly free up resources.
+
+        There are still 2 places which continue to use Functions, becuase they are expected to be
+        called multiple times:
+        - Device::setDeviceLostCallback()
+        - Device::setUncapturedErrorCallback()
+
+        * pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.cpp:
+        (PAL::WebGPU::AdapterImpl::requestDevice):
+        * pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.h:
+        * pal/graphics/WebGPU/Impl/WebGPUBufferImpl.cpp:
+        (PAL::WebGPU::BufferImpl::mapAsync):
+        * pal/graphics/WebGPU/Impl/WebGPUBufferImpl.h:
+        * pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.cpp:
+        (PAL::WebGPU::DeviceImpl::createComputePipelineAsync):
+        (PAL::WebGPU::DeviceImpl::createRenderPipelineAsync):
+        (PAL::WebGPU::DeviceImpl::popErrorScope):
+        * pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.h:
+        * pal/graphics/WebGPU/Impl/WebGPUImpl.cpp:
+        (PAL::WebGPU::GPUImpl::requestAdapter):
+        * pal/graphics/WebGPU/Impl/WebGPUImpl.h:
+        * pal/graphics/WebGPU/Impl/WebGPUQueueImpl.cpp:
+        (PAL::WebGPU::QueueImpl::onSubmittedWorkDone):
+        * pal/graphics/WebGPU/Impl/WebGPUQueueImpl.h:
+        * pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.cpp:
+        (PAL::WebGPU::ShaderModuleImpl::compilationInfo):
+        * pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.h:
+        * pal/graphics/WebGPU/WebGPU.h:
+        * pal/graphics/WebGPU/WebGPUAdapter.h:
+        * pal/graphics/WebGPU/WebGPUBuffer.h:
+        * pal/graphics/WebGPU/WebGPUDevice.h:
+        * pal/graphics/WebGPU/WebGPUQueue.h:
+        * pal/graphics/WebGPU/WebGPUShaderModule.h:
+
+2022-03-15  Myles C. Maxfield  <[email protected]>
+
         [WebGPU] Allow for scheduling asynchronous work
         https://bugs.webkit.org/show_bug.cgi?id=237755
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.cpp (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -146,7 +146,7 @@
     adapter->requestDeviceCallback(status, device, message);
 }
 
-void AdapterImpl::requestDevice(const DeviceDescriptor& descriptor, WTF::Function<void(Ref<Device>&&)>&& callback)
+void AdapterImpl::requestDevice(const DeviceDescriptor& descriptor, CompletionHandler<void(Ref<Device>&&)>&& callback)
 {
     Ref protectedThis(*this);
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -59,9 +59,9 @@
     WGPUAdapter backing() const { return m_backing; }
 
     void requestDeviceCallback(WGPURequestDeviceStatus, WGPUDevice, const char* message);
-    void requestDevice(const DeviceDescriptor&, WTF::Function<void(Ref<Device>&&)>&&) final;
+    void requestDevice(const DeviceDescriptor&, CompletionHandler<void(Ref<Device>&&)>&&) final;
 
-    Deque<WTF::Function<void(Ref<Device>&&)>> m_callbacks;
+    Deque<CompletionHandler<void(Ref<Device>&&)>> m_callbacks;
 
     WGPUAdapter m_backing { nullptr };
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUBufferImpl.cpp (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUBufferImpl.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUBufferImpl.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -50,7 +50,7 @@
     buffer->mapCallback(status);
 }
 
-void BufferImpl::mapAsync(MapModeFlags mapModeFlags, Size64 offset, std::optional<Size64> size, WTF::Function<void()>&& callback)
+void BufferImpl::mapAsync(MapModeFlags mapModeFlags, Size64 offset, std::optional<Size64> size, CompletionHandler<void()>&& callback)
 {
     Ref protectedThis(*this);
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUBufferImpl.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUBufferImpl.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUBufferImpl.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -59,7 +59,7 @@
     WGPUBuffer backing() const { return m_backing; }
 
     void mapCallback(WGPUBufferMapAsyncStatus);
-    void mapAsync(MapModeFlags, Size64 offset, std::optional<Size64> sizeForMap, WTF::Function<void()>&&) final;
+    void mapAsync(MapModeFlags, Size64 offset, std::optional<Size64> sizeForMap, CompletionHandler<void()>&&) final;
     MappedRange getMappedRange(Size64 offset, std::optional<Size64>) final;
     void unmap() final;
 
@@ -67,7 +67,7 @@
 
     void setLabelInternal(const String&) final;
 
-    Deque<WTF::Function<void()>> m_callbacks;
+    Deque<CompletionHandler<void()>> m_callbacks;
 
     WGPUBuffer m_backing { nullptr };
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.cpp (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -515,7 +515,7 @@
     device->createComputePipelineAsyncCallback(status, pipeline, message);
 }
 
-void DeviceImpl::createComputePipelineAsync(const ComputePipelineDescriptor& descriptor, WTF::Function<void(Ref<ComputePipeline>&&)>&& callback)
+void DeviceImpl::createComputePipelineAsync(const ComputePipelineDescriptor& descriptor, CompletionHandler<void(Ref<ComputePipeline>&&)>&& callback)
 {
     Ref protectedThis(*this);
 
@@ -539,7 +539,7 @@
     device->createRenderPipelineAsyncCallback(status, pipeline, message);
 }
 
-void DeviceImpl::createRenderPipelineAsync(const RenderPipelineDescriptor& descriptor, WTF::Function<void(Ref<RenderPipeline>&&)>&& callback)
+void DeviceImpl::createRenderPipelineAsync(const RenderPipelineDescriptor& descriptor, CompletionHandler<void(Ref<RenderPipeline>&&)>&& callback)
 {
     Ref protectedThis(*this);
 
@@ -618,7 +618,7 @@
     device->popErrorScopeCallback(type, message);
 }
 
-void DeviceImpl::popErrorScope(WTF::Function<void(std::optional<Error>&&)>&& callback)
+void DeviceImpl::popErrorScope(CompletionHandler<void(std::optional<Error>&&)>&& callback)
 {
     Ref protectedThis(*this);
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -75,9 +75,9 @@
     Ref<ComputePipeline> createComputePipeline(const ComputePipelineDescriptor&) final;
     Ref<RenderPipeline> createRenderPipeline(const RenderPipelineDescriptor&) final;
     void createComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus, WGPUComputePipeline, const char* message);
-    void createComputePipelineAsync(const ComputePipelineDescriptor&, WTF::Function<void(Ref<ComputePipeline>&&)>&&) final;
+    void createComputePipelineAsync(const ComputePipelineDescriptor&, CompletionHandler<void(Ref<ComputePipeline>&&)>&&) final;
     void createRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus, WGPURenderPipeline, const char* message);
-    void createRenderPipelineAsync(const RenderPipelineDescriptor&, WTF::Function<void(Ref<RenderPipeline>&&)>&&) final;
+    void createRenderPipelineAsync(const RenderPipelineDescriptor&, CompletionHandler<void(Ref<RenderPipeline>&&)>&&) final;
 
     Ref<CommandEncoder> createCommandEncoder(const std::optional<CommandEncoderDescriptor>&) final;
     Ref<RenderBundleEncoder> createRenderBundleEncoder(const RenderBundleEncoderDescriptor&) final;
@@ -86,13 +86,13 @@
 
     void pushErrorScope(ErrorFilter) final;
     void popErrorScopeCallback(WGPUErrorType, const char* message);
-    void popErrorScope(WTF::Function<void(std::optional<Error>&&)>&&) final;
+    void popErrorScope(CompletionHandler<void(std::optional<Error>&&)>&&) final;
 
     void setLabelInternal(const String&) final;
 
-    Deque<WTF::Function<void(Ref<ComputePipeline>&&)>> m_createComputePipelineAsyncCallbacks;
-    Deque<WTF::Function<void(Ref<RenderPipeline>&&)>> m_createRenderPipelineAsyncCallbacks;
-    Deque<WTF::Function<void(std::optional<Error>&&)>> m_popErrorScopeCallbacks;
+    Deque<CompletionHandler<void(Ref<ComputePipeline>&&)>> m_createComputePipelineAsyncCallbacks;
+    Deque<CompletionHandler<void(Ref<RenderPipeline>&&)>> m_createRenderPipelineAsyncCallbacks;
+    Deque<CompletionHandler<void(std::optional<Error>&&)>> m_popErrorScopeCallbacks;
 
     WGPUDevice m_backing { nullptr };
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUImpl.cpp (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUImpl.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUImpl.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -82,7 +82,7 @@
     gpu->requestAdapterCallback(status, adapter, message);
 }
 
-void GPUImpl::requestAdapter(const RequestAdapterOptions& options, WTF::Function<void(RefPtr<Adapter>&&)>&& callback)
+void GPUImpl::requestAdapter(const RequestAdapterOptions& options, CompletionHandler<void(RefPtr<Adapter>&&)>&& callback)
 {
     Ref protectedThis(*this);
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUImpl.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUImpl.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUImpl.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -29,7 +29,7 @@
 
 #include "WebGPU.h"
 #include <WebGPU/WebGPU.h>
-#include <functional>
+#include <wtf/CompletionHandler.h>
 #include <wtf/Deque.h>
 #include <wtf/Function.h>
 
@@ -40,7 +40,7 @@
 class GPUImpl final : public GPU {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    using WorkItem = Function<void(void)>;
+    using WorkItem = CompletionHandler<void(void)>;
     using ScheduleWorkFunction = Function<void(WorkItem&&)>;
     PAL_EXPORT static RefPtr<GPUImpl> create(ScheduleWorkFunction&&);
 
@@ -65,9 +65,9 @@
     WGPUInstance backing() const { return m_backing; }
 
     void requestAdapterCallback(WGPURequestAdapterStatus, WGPUAdapter, const char* message);
-    void requestAdapter(const RequestAdapterOptions&, WTF::Function<void(RefPtr<Adapter>&&)>&&) final;
+    void requestAdapter(const RequestAdapterOptions&, CompletionHandler<void(RefPtr<Adapter>&&)>&&) final;
 
-    Deque<WTF::Function<void(RefPtr<Adapter>&&)>> m_callbacks;
+    Deque<CompletionHandler<void(RefPtr<Adapter>&&)>> m_callbacks;
 
     WGPUInstance m_backing { nullptr };
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUQueueImpl.cpp (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUQueueImpl.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUQueueImpl.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -62,7 +62,7 @@
     queue->onSubmittedWorkDoneCallback(status);
 }
 
-void QueueImpl::onSubmittedWorkDone(WTF::Function<void()>&& callback)
+void QueueImpl::onSubmittedWorkDone(CompletionHandler<void()>&& callback)
 {
     Ref protectedThis(*this);
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUQueueImpl.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUQueueImpl.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUQueueImpl.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -61,7 +61,7 @@
     void submit(Vector<std::reference_wrapper<CommandBuffer>>&&) final;
 
     void onSubmittedWorkDoneCallback(WGPUQueueWorkDoneStatus);
-    void onSubmittedWorkDone(WTF::Function<void()>&&) final;
+    void onSubmittedWorkDone(CompletionHandler<void()>&&) final;
 
     void writeBuffer(
         const Buffer&,
@@ -87,7 +87,7 @@
 
     uint64_t m_signalValue { 1 };
 
-    Deque<WTF::Function<void()>> m_callbacks;
+    Deque<CompletionHandler<void()>> m_callbacks;
 
     WGPUQueue m_backing { nullptr };
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.cpp (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -44,7 +44,7 @@
     wgpuShaderModuleRelease(m_backing);
 }
 
-void ShaderModuleImpl::compilationInfo(WTF::Function<void(Ref<CompilationInfo>&&)>&&)
+void ShaderModuleImpl::compilationInfo(CompletionHandler<void(Ref<CompilationInfo>&&)>&&)
 {
 }
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUShaderModuleImpl.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -56,7 +56,7 @@
 
     WGPUShaderModule backing() const { return m_backing; }
 
-    void compilationInfo(WTF::Function<void(Ref<CompilationInfo>&&)>&&) final;
+    void compilationInfo(CompletionHandler<void(Ref<CompilationInfo>&&)>&&) final;
 
     void setLabelInternal(const String&) final;
 

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPU.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPU.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPU.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -27,7 +27,7 @@
 
 #include "WebGPURequestAdapterOptions.h"
 #include <optional>
-#include <wtf/Function.h>
+#include <wtf/CompletionHandler.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
@@ -39,7 +39,7 @@
 public:
     virtual ~GPU() = default;
 
-    virtual void requestAdapter(const RequestAdapterOptions&, WTF::Function<void(RefPtr<Adapter>&&)>&&) = 0;
+    virtual void requestAdapter(const RequestAdapterOptions&, CompletionHandler<void(RefPtr<Adapter>&&)>&&) = 0;
 
 protected:
     GPU() = default;

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUAdapter.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUAdapter.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUAdapter.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -29,7 +29,7 @@
 #include "WebGPUSupportedFeatures.h"
 #include "WebGPUSupportedLimits.h"
 #include <optional>
-#include <wtf/Function.h>
+#include <wtf/CompletionHandler.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
@@ -47,7 +47,7 @@
     SupportedLimits& limits() const { return m_limits; }
     bool isFallbackAdapter() const { return m_isFallbackAdapter; }
 
-    virtual void requestDevice(const DeviceDescriptor&, WTF::Function<void(Ref<Device>&&)>&&) = 0;
+    virtual void requestDevice(const DeviceDescriptor&, CompletionHandler<void(Ref<Device>&&)>&&) = 0;
 
 protected:
     Adapter(String&& name, SupportedFeatures& features, SupportedLimits& limits, bool isFallbackAdapter)

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBuffer.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBuffer.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUBuffer.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -29,7 +29,7 @@
 #include "WebGPUMapMode.h"
 #include <cstdint>
 #include <optional>
-#include <wtf/Function.h>
+#include <wtf/CompletionHandler.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
@@ -48,7 +48,7 @@
         setLabelInternal(m_label);
     }
 
-    virtual void mapAsync(MapModeFlags, Size64 offset, std::optional<Size64>, WTF::Function<void()>&&) = 0;
+    virtual void mapAsync(MapModeFlags, Size64 offset, std::optional<Size64>, CompletionHandler<void()>&&) = 0;
     struct MappedRange {
         void* source { nullptr };
         size_t byteLength { 0 };

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUDevice.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUDevice.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUDevice.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -33,7 +33,7 @@
 #include "WebGPUSupportedFeatures.h"
 #include "WebGPUSupportedLimits.h"
 #include <optional>
-#include <wtf/Function.h>
+#include <wtf/CompletionHandler.h>
 #include <wtf/HashSet.h>
 #include <wtf/Ref.h>
 #include <wtf/text/WTFString.h>
@@ -100,8 +100,8 @@
     virtual Ref<ShaderModule> createShaderModule(const ShaderModuleDescriptor&) = 0;
     virtual Ref<ComputePipeline> createComputePipeline(const ComputePipelineDescriptor&) = 0;
     virtual Ref<RenderPipeline> createRenderPipeline(const RenderPipelineDescriptor&) = 0;
-    virtual void createComputePipelineAsync(const ComputePipelineDescriptor&, WTF::Function<void(Ref<ComputePipeline>&&)>&&) = 0;
-    virtual void createRenderPipelineAsync(const RenderPipelineDescriptor&, WTF::Function<void(Ref<RenderPipeline>&&)>&&) = 0;
+    virtual void createComputePipelineAsync(const ComputePipelineDescriptor&, CompletionHandler<void(Ref<ComputePipeline>&&)>&&) = 0;
+    virtual void createRenderPipelineAsync(const RenderPipelineDescriptor&, CompletionHandler<void(Ref<RenderPipeline>&&)>&&) = 0;
 
     virtual Ref<CommandEncoder> createCommandEncoder(const std::optional<CommandEncoderDescriptor>&) = 0;
     virtual Ref<RenderBundleEncoder> createRenderBundleEncoder(const RenderBundleEncoderDescriptor&) = 0;
@@ -109,7 +109,7 @@
     virtual Ref<QuerySet> createQuerySet(const QuerySetDescriptor&) = 0;
 
     virtual void pushErrorScope(ErrorFilter) = 0;
-    virtual void popErrorScope(WTF::Function<void(std::optional<Error>&&)>&&) = 0;
+    virtual void popErrorScope(CompletionHandler<void(std::optional<Error>&&)>&&) = 0;
 
     class DeviceLostClient {
         virtual ~DeviceLostClient() = default;

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUQueue.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUQueue.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUQueue.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -35,7 +35,7 @@
 #include <cstdint>
 #include <functional>
 #include <optional>
-#include <wtf/Function.h>
+#include <wtf/CompletionHandler.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -59,7 +59,7 @@
 
     virtual void submit(Vector<std::reference_wrapper<CommandBuffer>>&&) = 0;
 
-    virtual void onSubmittedWorkDone(WTF::Function<void()>&&) = 0;
+    virtual void onSubmittedWorkDone(CompletionHandler<void()>&&) = 0;
 
     virtual void writeBuffer(
         const Buffer&,

Modified: trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderModule.h (291322 => 291323)


--- trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderModule.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUShaderModule.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "WebGPUBindGroupLayout.h"
-#include <wtf/Function.h>
+#include <wtf/CompletionHandler.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
@@ -47,7 +47,7 @@
         setLabelInternal(m_label);
     }
 
-    virtual void compilationInfo(WTF::Function<void(Ref<CompilationInfo>&&)>&&) = 0;
+    virtual void compilationInfo(CompletionHandler<void(Ref<CompilationInfo>&&)>&&) = 0;
 
 protected:
     ShaderModule() = default;

Modified: trunk/Source/WebGPU/ChangeLog (291322 => 291323)


--- trunk/Source/WebGPU/ChangeLog	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/ChangeLog	2022-03-15 23:44:09 UTC (rev 291323)
@@ -1,5 +1,38 @@
 2022-03-15  Myles C. Maxfield  <[email protected]>
 
+        [WebGPU] Migrate from WTF::Function to WTF::CompletionHandler
+        https://bugs.webkit.org/show_bug.cgi?id=237925
+
+        Reviewed by Geoffrey Garen.
+
+        * WebGPU/Adapter.h:
+        * WebGPU/Adapter.mm:
+        (WebGPU::Adapter::requestDevice):
+        * WebGPU/Buffer.h:
+        * WebGPU/Buffer.mm:
+        (WebGPU::Buffer::mapAsync):
+        * WebGPU/ComputePipeline.mm:
+        (WebGPU::Device::createComputePipelineAsync):
+        * WebGPU/Device.h:
+        * WebGPU/Device.mm:
+        (WebGPU::Device::popErrorScope):
+        (WebGPU::Device::setDeviceLostCallback):
+        (WebGPU::Device::setUncapturedErrorCallback):
+        * WebGPU/Instance.h:
+        * WebGPU/Instance.mm:
+        (WebGPU::Instance::requestAdapter):
+        * WebGPU/Queue.h:
+        * WebGPU/Queue.mm:
+        (WebGPU::Queue::onSubmittedWorkDone):
+        * WebGPU/RenderPassEncoder.h:
+        * WebGPU/RenderPipeline.mm:
+        (WebGPU::Device::createRenderPipelineAsync):
+        * WebGPU/ShaderModule.h:
+        * WebGPU/ShaderModule.mm:
+        (WebGPU::ShaderModule::getCompilationInfo):
+
+2022-03-15  Myles C. Maxfield  <[email protected]>
+
         [WebGPU] Update WebGPU CommandLinePlayground to execute asynchronous tasks
         https://bugs.webkit.org/show_bug.cgi?id=237852
 

Modified: trunk/Source/WebGPU/WebGPU/Adapter.h (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Adapter.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Adapter.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -25,8 +25,8 @@
 
 #pragma once
 
+#import <wtf/CompletionHandler.h>
 #import <wtf/FastMalloc.h>
-#import <wtf/Function.h>
 #import <wtf/Ref.h>
 #import <wtf/RefCounted.h>
 #import <wtf/RefPtr.h>
@@ -49,7 +49,7 @@
     bool getLimits(WGPUSupportedLimits&);
     void getProperties(WGPUAdapterProperties&);
     bool hasFeature(WGPUFeatureName);
-    void requestDevice(const WGPUDeviceDescriptor&, WTF::Function<void(WGPURequestDeviceStatus, RefPtr<Device>&&, const char*)>&& callback);
+    void requestDevice(const WGPUDeviceDescriptor&, CompletionHandler<void(WGPURequestDeviceStatus, RefPtr<Device>&&, const char*)>&& callback);
 
 private:
     Adapter(id<MTLDevice>);

Modified: trunk/Source/WebGPU/WebGPU/Adapter.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Adapter.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Adapter.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -103,7 +103,7 @@
         && !requiredLimits.limits.maxComputeWorkgroupsPerDimension;
 }
 
-void Adapter::requestDevice(const WGPUDeviceDescriptor& descriptor, WTF::Function<void(WGPURequestDeviceStatus, RefPtr<Device>&&, const char*)>&& callback)
+void Adapter::requestDevice(const WGPUDeviceDescriptor& descriptor, CompletionHandler<void(WGPURequestDeviceStatus, RefPtr<Device>&&, const char*)>&& callback)
 {
     if (descriptor.nextInChain) {
         callback(WGPURequestDeviceStatus_Error, nullptr, "Unknown descriptor type");

Modified: trunk/Source/WebGPU/WebGPU/Buffer.h (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Buffer.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Buffer.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -25,8 +25,8 @@
 
 #pragma once
 
+#import <wtf/CompletionHandler.h>
 #import <wtf/FastMalloc.h>
-#import <wtf/Function.h>
 #import <wtf/Ref.h>
 #import <wtf/RefCounted.h>
 
@@ -45,7 +45,7 @@
     void destroy();
     const void* getConstMappedRange(size_t offset, size_t);
     void* getMappedRange(size_t offset, size_t);
-    void mapAsync(WGPUMapModeFlags, size_t offset, size_t, WTF::Function<void(WGPUBufferMapAsyncStatus)>&& callback);
+    void mapAsync(WGPUMapModeFlags, size_t offset, size_t, CompletionHandler<void(WGPUBufferMapAsyncStatus)>&& callback);
     void unmap();
     void setLabel(const char*);
 

Modified: trunk/Source/WebGPU/WebGPU/Buffer.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Buffer.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Buffer.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -61,7 +61,7 @@
     return nullptr;
 }
 
-void Buffer::mapAsync(WGPUMapModeFlags mode, size_t offset, size_t size, WTF::Function<void(WGPUBufferMapAsyncStatus)>&& callback)
+void Buffer::mapAsync(WGPUMapModeFlags mode, size_t offset, size_t size, CompletionHandler<void(WGPUBufferMapAsyncStatus)>&& callback)
 {
     UNUSED_PARAM(mode);
     UNUSED_PARAM(offset);

Modified: trunk/Source/WebGPU/WebGPU/ComputePipeline.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/ComputePipeline.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/ComputePipeline.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -170,7 +170,7 @@
     return ComputePipeline::create(computePipelineState);
 }
 
-void Device::createComputePipelineAsync(const WGPUComputePipelineDescriptor& descriptor, WTF::Function<void(WGPUCreatePipelineAsyncStatus, RefPtr<ComputePipeline>&&, const char* message)>&& callback)
+void Device::createComputePipelineAsync(const WGPUComputePipelineDescriptor& descriptor, CompletionHandler<void(WGPUCreatePipelineAsyncStatus, RefPtr<ComputePipeline>&&, const char* message)>&& callback)
 {
     // FIXME: Implement this
     UNUSED_PARAM(descriptor);

Modified: trunk/Source/WebGPU/WebGPU/Device.h (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Device.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Device.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -26,6 +26,7 @@
 #pragma once
 
 #import "Queue.h"
+#import <wtf/CompletionHandler.h>
 #import <wtf/FastMalloc.h>
 #import <wtf/Function.h>
 #import <wtf/Ref.h>
@@ -61,12 +62,12 @@
     RefPtr<Buffer> createBuffer(const WGPUBufferDescriptor&);
     RefPtr<CommandEncoder> createCommandEncoder(const WGPUCommandEncoderDescriptor&);
     RefPtr<ComputePipeline> createComputePipeline(const WGPUComputePipelineDescriptor&);
-    void createComputePipelineAsync(const WGPUComputePipelineDescriptor&, WTF::Function<void(WGPUCreatePipelineAsyncStatus, RefPtr<ComputePipeline>&&, const char* message)>&& callback);
+    void createComputePipelineAsync(const WGPUComputePipelineDescriptor&, CompletionHandler<void(WGPUCreatePipelineAsyncStatus, RefPtr<ComputePipeline>&&, const char* message)>&& callback);
     RefPtr<PipelineLayout> createPipelineLayout(const WGPUPipelineLayoutDescriptor&);
     RefPtr<QuerySet> createQuerySet(const WGPUQuerySetDescriptor&);
     RefPtr<RenderBundleEncoder> createRenderBundleEncoder(const WGPURenderBundleEncoderDescriptor&);
     RefPtr<RenderPipeline> createRenderPipeline(const WGPURenderPipelineDescriptor&);
-    void createRenderPipelineAsync(const WGPURenderPipelineDescriptor&, WTF::Function<void(WGPUCreatePipelineAsyncStatus, RefPtr<RenderPipeline>&&, const char* message)>&& callback);
+    void createRenderPipelineAsync(const WGPURenderPipelineDescriptor&, CompletionHandler<void(WGPUCreatePipelineAsyncStatus, RefPtr<RenderPipeline>&&, const char* message)>&& callback);
     RefPtr<Sampler> createSampler(const WGPUSamplerDescriptor&);
     RefPtr<ShaderModule> createShaderModule(const WGPUShaderModuleDescriptor&);
     RefPtr<SwapChain> createSwapChain(const Surface&, const WGPUSwapChainDescriptor&);
@@ -76,10 +77,10 @@
     bool getLimits(WGPUSupportedLimits&);
     Queue& getQueue();
     bool hasFeature(WGPUFeatureName);
-    bool popErrorScope(WTF::Function<void(WGPUErrorType, const char*)>&& callback);
+    bool popErrorScope(CompletionHandler<void(WGPUErrorType, const char*)>&& callback);
     void pushErrorScope(WGPUErrorFilter);
-    void setDeviceLostCallback(WTF::Function<void(WGPUDeviceLostReason, const char*)>&&);
-    void setUncapturedErrorCallback(WTF::Function<void(WGPUErrorType, const char*)>&&);
+    void setDeviceLostCallback(Function<void(WGPUDeviceLostReason, const char*)>&&);
+    void setUncapturedErrorCallback(Function<void(WGPUErrorType, const char*)>&&);
     void setLabel(const char*);
 
 private:

Modified: trunk/Source/WebGPU/WebGPU/Device.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Device.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Device.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -101,7 +101,7 @@
     return false;
 }
 
-bool Device::popErrorScope(WTF::Function<void(WGPUErrorType, const char*)>&& callback)
+bool Device::popErrorScope(CompletionHandler<void(WGPUErrorType, const char*)>&& callback)
 {
     // FIXME: Implement this.
     UNUSED_PARAM(callback);
@@ -114,13 +114,13 @@
     UNUSED_PARAM(filter);
 }
 
-void Device::setDeviceLostCallback(WTF::Function<void(WGPUDeviceLostReason, const char*)>&& callback)
+void Device::setDeviceLostCallback(Function<void(WGPUDeviceLostReason, const char*)>&& callback)
 {
     // FIXME: Implement this.
     UNUSED_PARAM(callback);
 }
 
-void Device::setUncapturedErrorCallback(WTF::Function<void(WGPUErrorType, const char*)>&& callback)
+void Device::setUncapturedErrorCallback(Function<void(WGPUErrorType, const char*)>&& callback)
 {
     // FIXME: Implement this.
     UNUSED_PARAM(callback);

Modified: trunk/Source/WebGPU/WebGPU/Instance.h (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Instance.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Instance.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -25,9 +25,9 @@
 
 #pragma once
 
+#import <wtf/CompletionHandler.h>
 #import <wtf/Deque.h>
 #import <wtf/FastMalloc.h>
-#import <wtf/Function.h>
 #import <wtf/Lock.h>
 #import <wtf/Ref.h>
 #import <wtf/RefPtr.h>
@@ -47,10 +47,10 @@
 
     RefPtr<Surface> createSurface(const WGPUSurfaceDescriptor&);
     void processEvents();
-    void requestAdapter(const WGPURequestAdapterOptions&, WTF::Function<void(WGPURequestAdapterStatus, RefPtr<Adapter>&&, const char*)>&& callback);
+    void requestAdapter(const WGPURequestAdapterOptions&, CompletionHandler<void(WGPURequestAdapterStatus, RefPtr<Adapter>&&, const char*)>&& callback);
 
     // This can be called on a background thread.
-    using WorkItem = Function<void(void)>;
+    using WorkItem = CompletionHandler<void(void)>;
     void scheduleWork(WorkItem&&);
 
 private:

Modified: trunk/Source/WebGPU/WebGPU/Instance.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Instance.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Instance.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -126,7 +126,7 @@
     }
 }
 
-void Instance::requestAdapter(const WGPURequestAdapterOptions& options, WTF::Function<void(WGPURequestAdapterStatus, RefPtr<Adapter>&&, const char*)>&& callback)
+void Instance::requestAdapter(const WGPURequestAdapterOptions& options, CompletionHandler<void(WGPURequestAdapterStatus, RefPtr<Adapter>&&, const char*)>&& callback)
 {
 #if PLATFORM(MAC) || PLATFORM(MACCATALYST)
     NSArray<id<MTLDevice>> *devices = MTLCopyAllDevices();

Modified: trunk/Source/WebGPU/WebGPU/Queue.h (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Queue.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Queue.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -25,8 +25,8 @@
 
 #pragma once
 
+#import <wtf/CompletionHandler.h>
 #import <wtf/FastMalloc.h>
-#import <wtf/Function.h>
 #import <wtf/Ref.h>
 #import <wtf/RefCounted.h>
 #import <wtf/Vector.h>
@@ -46,7 +46,7 @@
 
     ~Queue();
 
-    void onSubmittedWorkDone(uint64_t signalValue, WTF::Function<void(WGPUQueueWorkDoneStatus)>&& callback);
+    void onSubmittedWorkDone(uint64_t signalValue, CompletionHandler<void(WGPUQueueWorkDoneStatus)>&& callback);
     void submit(Vector<std::reference_wrapper<const CommandBuffer>>&& commands);
     void writeBuffer(const Buffer&, uint64_t bufferOffset, const void* data, size_t);
     void writeTexture(const WGPUImageCopyTexture& destination, const void* data, size_t dataSize, const WGPUTextureDataLayout&, const WGPUExtent3D& writeSize);

Modified: trunk/Source/WebGPU/WebGPU/Queue.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/Queue.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/Queue.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -38,7 +38,7 @@
 
 Queue::~Queue() = default;
 
-void Queue::onSubmittedWorkDone(uint64_t signalValue, WTF::Function<void(WGPUQueueWorkDoneStatus)>&& callback)
+void Queue::onSubmittedWorkDone(uint64_t signalValue, CompletionHandler<void(WGPUQueueWorkDoneStatus)>&& callback)
 {
     UNUSED_PARAM(signalValue);
     UNUSED_PARAM(callback);

Modified: trunk/Source/WebGPU/WebGPU/RenderPassEncoder.h (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/RenderPassEncoder.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/RenderPassEncoder.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -26,7 +26,6 @@
 #pragma once
 
 #import <wtf/FastMalloc.h>
-#import <wtf/Function.h>
 #import <wtf/Ref.h>
 #import <wtf/RefCounted.h>
 #import <wtf/Vector.h>

Modified: trunk/Source/WebGPU/WebGPU/RenderPipeline.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/RenderPipeline.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/RenderPipeline.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -37,7 +37,7 @@
     return RenderPipeline::create(nil);
 }
 
-void Device::createRenderPipelineAsync(const WGPURenderPipelineDescriptor& descriptor, WTF::Function<void(WGPUCreatePipelineAsyncStatus, RefPtr<RenderPipeline>&&, const char* message)>&& callback)
+void Device::createRenderPipelineAsync(const WGPURenderPipelineDescriptor& descriptor, CompletionHandler<void(WGPUCreatePipelineAsyncStatus, RefPtr<RenderPipeline>&&, const char* message)>&& callback)
 {
     UNUSED_PARAM(descriptor);
     UNUSED_PARAM(callback);

Modified: trunk/Source/WebGPU/WebGPU/ShaderModule.h (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/ShaderModule.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/ShaderModule.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -46,7 +46,7 @@
 
     ~ShaderModule();
 
-    void getCompilationInfo(WTF::Function<void(WGPUCompilationInfoRequestStatus, const WGPUCompilationInfo&)>&& callback);
+    void getCompilationInfo(CompletionHandler<void(WGPUCompilationInfoRequestStatus, const WGPUCompilationInfo&)>&& callback);
     void setLabel(const char*);
 
     static WGSL::PipelineLayout convertPipelineLayout(const PipelineLayout&);

Modified: trunk/Source/WebGPU/WebGPU/ShaderModule.mm (291322 => 291323)


--- trunk/Source/WebGPU/WebGPU/ShaderModule.mm	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebGPU/WebGPU/ShaderModule.mm	2022-03-15 23:44:09 UTC (rev 291323)
@@ -182,7 +182,7 @@
     return { WTFMove(flattenedCompilationMessages), WTFMove(flattenedMessages) };
 }
 
-void ShaderModule::getCompilationInfo(WTF::Function<void(WGPUCompilationInfoRequestStatus, const WGPUCompilationInfo&)>&& callback)
+void ShaderModule::getCompilationInfo(CompletionHandler<void(WGPUCompilationInfoRequestStatus, const WGPUCompilationInfo&)>&& callback)
 {
     WTF::switchOn(m_checkResult, [&] (const WGSL::SuccessfulCheck& successfulCheck) {
         auto compilationMessageData(convertMessages({ successfulCheck.warnings, WGPUCompilationMessageType_Warning }));

Modified: trunk/Source/WebKit/ChangeLog (291322 => 291323)


--- trunk/Source/WebKit/ChangeLog	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/ChangeLog	2022-03-15 23:44:09 UTC (rev 291323)
@@ -1,3 +1,51 @@
+2022-03-15  Myles C. Maxfield  <[email protected]>
+
+        [WebGPU] Migrate from WTF::Function to WTF::CompletionHandler
+        https://bugs.webkit.org/show_bug.cgi?id=237925
+
+        Reviewed by Geoffrey Garen.
+
+        * GPUProcess/graphics/WebGPU/RemoteAdapter.cpp:
+        (WebKit::RemoteAdapter::requestDevice):
+        * GPUProcess/graphics/WebGPU/RemoteAdapter.h:
+        * GPUProcess/graphics/WebGPU/RemoteBuffer.cpp:
+        (WebKit::RemoteBuffer::mapAsync):
+        * GPUProcess/graphics/WebGPU/RemoteBuffer.h:
+        * GPUProcess/graphics/WebGPU/RemoteDevice.cpp:
+        (WebKit::RemoteDevice::createComputePipelineAsync):
+        (WebKit::RemoteDevice::createRenderPipelineAsync):
+        (WebKit::RemoteDevice::popErrorScope):
+        * GPUProcess/graphics/WebGPU/RemoteDevice.h:
+        * GPUProcess/graphics/WebGPU/RemoteGPU.cpp:
+        (WebKit::RemoteGPU::requestAdapter):
+        * GPUProcess/graphics/WebGPU/RemoteGPU.h:
+        * GPUProcess/graphics/WebGPU/RemoteQueue.cpp:
+        (WebKit::RemoteQueue::onSubmittedWorkDone):
+        * GPUProcess/graphics/WebGPU/RemoteQueue.h:
+        * GPUProcess/graphics/WebGPU/RemoteShaderModule.cpp:
+        (WebKit::RemoteShaderModule::compilationInfo):
+        * GPUProcess/graphics/WebGPU/RemoteShaderModule.h:
+        * WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.cpp:
+        (WebKit::WebGPU::RemoteAdapterProxy::requestDevice):
+        * WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.h:
+        * WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp:
+        (WebKit::WebGPU::RemoteBufferProxy::mapAsync):
+        * WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h:
+        * WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.cpp:
+        (WebKit::WebGPU::RemoteDeviceProxy::createComputePipelineAsync):
+        (WebKit::WebGPU::RemoteDeviceProxy::createRenderPipelineAsync):
+        (WebKit::WebGPU::RemoteDeviceProxy::popErrorScope):
+        * WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.h:
+        * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp:
+        (WebKit::RemoteGPUProxy::requestAdapter):
+        * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h:
+        * WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.cpp:
+        (WebKit::WebGPU::RemoteQueueProxy::onSubmittedWorkDone):
+        * WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.h:
+        * WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.cpp:
+        (WebKit::WebGPU::RemoteShaderModuleProxy::compilationInfo):
+        * WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.h:
+
 2022-03-15  J Pascoe  <[email protected]>
 
         [WebAuthn] Mock UI interactions whenever virtual authenticators are in use.

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteAdapter.cpp (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteAdapter.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteAdapter.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -56,7 +56,7 @@
     m_streamConnection->stopReceivingMessages(Messages::RemoteAdapter::messageReceiverName(), m_identifier.toUInt64());
 }
 
-void RemoteAdapter::requestDevice(const WebGPU::DeviceDescriptor& descriptor, WebGPUIdentifier identifier, WTF::CompletionHandler<void(WebGPU::SupportedFeatures&&, WebGPU::SupportedLimits&&)>&& callback)
+void RemoteAdapter::requestDevice(const WebGPU::DeviceDescriptor& descriptor, WebGPUIdentifier identifier, CompletionHandler<void(WebGPU::SupportedFeatures&&, WebGPU::SupportedLimits&&)>&& callback)
 {
     auto convertedDescriptor = m_objectHeap.convertFromBacking(descriptor);
     ASSERT(convertedDescriptor);

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteAdapter.h (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteAdapter.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteAdapter.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -75,7 +75,7 @@
 
     void didReceiveStreamMessage(IPC::StreamServerConnectionBase&, IPC::Decoder&) final;
 
-    void requestDevice(const WebGPU::DeviceDescriptor&, WebGPUIdentifier, WTF::CompletionHandler<void(WebGPU::SupportedFeatures&&, WebGPU::SupportedLimits&&)>&&);
+    void requestDevice(const WebGPU::DeviceDescriptor&, WebGPUIdentifier, CompletionHandler<void(WebGPU::SupportedFeatures&&, WebGPU::SupportedLimits&&)>&&);
 
     Ref<PAL::WebGPU::Adapter> m_backing;
     WebGPU::ObjectHeap& m_objectHeap;

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -50,7 +50,7 @@
     m_streamConnection->stopReceivingMessages(Messages::RemoteBuffer::messageReceiverName(), m_identifier.toUInt64());
 }
 
-void RemoteBuffer::mapAsync(PAL::WebGPU::MapModeFlags mapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> size, WTF::CompletionHandler<void(std::optional<Vector<uint8_t>>&&)>&& callback)
+void RemoteBuffer::mapAsync(PAL::WebGPU::MapModeFlags mapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> size, CompletionHandler<void(std::optional<Vector<uint8_t>>&&)>&& callback)
 {
     if (m_isMapped) {
         callback(std::nullopt);

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteBuffer.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -77,7 +77,7 @@
 
     void didReceiveStreamMessage(IPC::StreamServerConnectionBase&, IPC::Decoder&) final;
 
-    void mapAsync(PAL::WebGPU::MapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> sizeForMap, WTF::CompletionHandler<void(std::optional<Vector<uint8_t>>&&)>&&);
+    void mapAsync(PAL::WebGPU::MapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> sizeForMap, CompletionHandler<void(std::optional<Vector<uint8_t>>&&)>&&);
     void unmap(Vector<uint8_t>&&);
 
     void destroy();

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteDevice.cpp (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteDevice.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteDevice.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -219,7 +219,7 @@
     m_objectHeap.addObject(identifier, remoteRenderPipeline);
 }
 
-void RemoteDevice::createComputePipelineAsync(const WebGPU::ComputePipelineDescriptor& descriptor, WebGPUIdentifier identifier, WTF::CompletionHandler<void()>&& callback)
+void RemoteDevice::createComputePipelineAsync(const WebGPU::ComputePipelineDescriptor& descriptor, WebGPUIdentifier identifier, CompletionHandler<void()>&& callback)
 {
     auto convertedDescriptor = m_objectHeap.convertFromBacking(descriptor);
     ASSERT(convertedDescriptor);
@@ -235,7 +235,7 @@
     });
 }
 
-void RemoteDevice::createRenderPipelineAsync(const WebGPU::RenderPipelineDescriptor& descriptor, WebGPUIdentifier identifier, WTF::CompletionHandler<void()>&& callback)
+void RemoteDevice::createRenderPipelineAsync(const WebGPU::RenderPipelineDescriptor& descriptor, WebGPUIdentifier identifier, CompletionHandler<void()>&& callback)
 {
     auto convertedDescriptor = m_objectHeap.convertFromBacking(descriptor);
     ASSERT(convertedDescriptor);
@@ -295,7 +295,7 @@
     m_backing->pushErrorScope(errorFilter);
 }
 
-void RemoteDevice::popErrorScope(WTF::CompletionHandler<void(std::optional<WebGPU::Error>&&)>&& callback)
+void RemoteDevice::popErrorScope(CompletionHandler<void(std::optional<WebGPU::Error>&&)>&& callback)
 {
     m_backing->popErrorScope([callback = WTFMove(callback)] (std::optional<PAL::WebGPU::Error>&& error) mutable {
         if (!error) {

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteDevice.h (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteDevice.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteDevice.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -102,8 +102,8 @@
     void createShaderModule(const WebGPU::ShaderModuleDescriptor&, WebGPUIdentifier);
     void createComputePipeline(const WebGPU::ComputePipelineDescriptor&, WebGPUIdentifier);
     void createRenderPipeline(const WebGPU::RenderPipelineDescriptor&, WebGPUIdentifier);
-    void createComputePipelineAsync(const WebGPU::ComputePipelineDescriptor&, WebGPUIdentifier, WTF::CompletionHandler<void()>&&);
-    void createRenderPipelineAsync(const WebGPU::RenderPipelineDescriptor&, WebGPUIdentifier, WTF::CompletionHandler<void()>&&);
+    void createComputePipelineAsync(const WebGPU::ComputePipelineDescriptor&, WebGPUIdentifier, CompletionHandler<void()>&&);
+    void createRenderPipelineAsync(const WebGPU::RenderPipelineDescriptor&, WebGPUIdentifier, CompletionHandler<void()>&&);
 
     void createCommandEncoder(const std::optional<WebGPU::CommandEncoderDescriptor>&, WebGPUIdentifier);
     void createRenderBundleEncoder(const WebGPU::RenderBundleEncoderDescriptor&, WebGPUIdentifier);
@@ -111,7 +111,7 @@
     void createQuerySet(const WebGPU::QuerySetDescriptor&, WebGPUIdentifier);
 
     void pushErrorScope(PAL::WebGPU::ErrorFilter);
-    void popErrorScope(WTF::CompletionHandler<void(std::optional<WebGPU::Error>&&)>&&);
+    void popErrorScope(CompletionHandler<void(std::optional<WebGPU::Error>&&)>&&);
 
     void setLabel(String&&);
 

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -105,7 +105,7 @@
     m_backing = nullptr;
 }
 
-void RemoteGPU::requestAdapter(const WebGPU::RequestAdapterOptions& options, WebGPUIdentifier identifier, WTF::CompletionHandler<void(std::optional<RequestAdapterResponse>&&)>&& callback)
+void RemoteGPU::requestAdapter(const WebGPU::RequestAdapterOptions& options, WebGPUIdentifier identifier, CompletionHandler<void(std::optional<RequestAdapterResponse>&&)>&& callback)
 {
     assertIsCurrent(workQueue());
     ASSERT(m_backing);

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.h (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -134,7 +134,7 @@
 
     void didReceiveStreamMessage(IPC::StreamServerConnectionBase&, IPC::Decoder&) final;
 
-    void requestAdapter(const WebGPU::RequestAdapterOptions&, WebGPUIdentifier, WTF::CompletionHandler<void(std::optional<RequestAdapterResponse>&&)>&&);
+    void requestAdapter(const WebGPU::RequestAdapterOptions&, WebGPUIdentifier, CompletionHandler<void(std::optional<RequestAdapterResponse>&&)>&&);
 
     WeakPtr<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess;
     Ref<IPC::StreamConnectionWorkQueue> m_workQueue;

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteQueue.cpp (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteQueue.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteQueue.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -65,7 +65,7 @@
     m_backing->submit(WTFMove(convertedCommandBuffers));
 }
 
-void RemoteQueue::onSubmittedWorkDone(WTF::CompletionHandler<void()>&& callback)
+void RemoteQueue::onSubmittedWorkDone(CompletionHandler<void()>&& callback)
 {
     m_backing->onSubmittedWorkDone([callback = WTFMove(callback)] () mutable {
         callback();

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteQueue.h (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteQueue.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteQueue.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -83,7 +83,7 @@
 
     void submit(Vector<WebGPUIdentifier>&&);
 
-    void onSubmittedWorkDone(WTF::CompletionHandler<void()>&&);
+    void onSubmittedWorkDone(CompletionHandler<void()>&&);
 
     void writeBuffer(
         WebGPUIdentifier,

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteShaderModule.cpp (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteShaderModule.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteShaderModule.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -53,7 +53,7 @@
     m_streamConnection->stopReceivingMessages(Messages::RemoteShaderModule::messageReceiverName(), m_identifier.toUInt64());
 }
 
-void RemoteShaderModule::compilationInfo(WTF::CompletionHandler<void(Vector<WebGPU::CompilationMessage>&&)>&& callback)
+void RemoteShaderModule::compilationInfo(CompletionHandler<void(Vector<WebGPU::CompilationMessage>&&)>&& callback)
 {
     m_backing->compilationInfo([callback = WTFMove(callback)] (Ref<PAL::WebGPU::CompilationInfo>&& compilationMessage) mutable {
         auto convertedMessages = compilationMessage->messages().map([] (const Ref<PAL::WebGPU::CompilationMessage>& message) {

Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteShaderModule.h (291322 => 291323)


--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteShaderModule.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteShaderModule.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -75,7 +75,7 @@
 
     void didReceiveStreamMessage(IPC::StreamServerConnectionBase&, IPC::Decoder&) final;
 
-    void compilationInfo(WTF::CompletionHandler<void(Vector<WebGPU::CompilationMessage>&&)>&&);
+    void compilationInfo(CompletionHandler<void(Vector<WebGPU::CompilationMessage>&&)>&&);
 
     void setLabel(String&&);
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.cpp (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -46,7 +46,7 @@
 {
 }
 
-void RemoteAdapterProxy::requestDevice(const PAL::WebGPU::DeviceDescriptor& descriptor, WTF::Function<void(Ref<PAL::WebGPU::Device>&&)>&& callback)
+void RemoteAdapterProxy::requestDevice(const PAL::WebGPU::DeviceDescriptor& descriptor, CompletionHandler<void(Ref<PAL::WebGPU::Device>&&)>&& callback)
 {
     auto convertedDescriptor = m_convertToBackingContext->convertToBacking(descriptor);
     ASSERT(convertedDescriptor);

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.h (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteAdapterProxy.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -77,9 +77,9 @@
         return root().streamClientConnection().sendSync(WTFMove(message), WTFMove(reply), backing(), defaultSendTimeout);
     }
 
-    void requestDevice(const PAL::WebGPU::DeviceDescriptor&, WTF::Function<void(Ref<PAL::WebGPU::Device>&&)>&&) final;
+    void requestDevice(const PAL::WebGPU::DeviceDescriptor&, CompletionHandler<void(Ref<PAL::WebGPU::Device>&&)>&&) final;
 
-    Deque<WTF::Function<void(Ref<PAL::WebGPU::Device>)>> m_callbacks;
+    Deque<CompletionHandler<void(Ref<PAL::WebGPU::Device>)>> m_callbacks;
 
     WebGPUIdentifier m_backing;
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -44,7 +44,7 @@
 {
 }
 
-void RemoteBufferProxy::mapAsync(PAL::WebGPU::MapModeFlags mapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> size, WTF::Function<void()>&& callback)
+void RemoteBufferProxy::mapAsync(PAL::WebGPU::MapModeFlags mapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> size, CompletionHandler<void()>&& callback)
 {
     std::optional<Vector<uint8_t>> data;
     auto sendResult = sendSync(Messages::RemoteBuffer::MapAsync(mapModeFlags, offset, size), { data });

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteBufferProxy.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -73,7 +73,7 @@
         return root().streamClientConnection().sendSync(WTFMove(message), WTFMove(reply), backing(), defaultSendTimeout);
     }
 
-    void mapAsync(PAL::WebGPU::MapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> sizeForMap, WTF::Function<void()>&&) final;
+    void mapAsync(PAL::WebGPU::MapModeFlags, PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64> sizeForMap, CompletionHandler<void()>&&) final;
     MappedRange getMappedRange(PAL::WebGPU::Size64 offset, std::optional<PAL::WebGPU::Size64>) final;
     void unmap() final;
 
@@ -81,7 +81,7 @@
 
     void setLabelInternal(const String&) final;
 
-    Deque<WTF::Function<void()>> m_callbacks;
+    Deque<CompletionHandler<void()>> m_callbacks;
 
     WebGPUIdentifier m_backing;
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.cpp (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -213,7 +213,7 @@
     return RemoteRenderPipelineProxy::create(*this, m_convertToBackingContext, identifier);
 }
 
-void RemoteDeviceProxy::createComputePipelineAsync(const PAL::WebGPU::ComputePipelineDescriptor& descriptor, WTF::Function<void(Ref<PAL::WebGPU::ComputePipeline>&&)>&& callback)
+void RemoteDeviceProxy::createComputePipelineAsync(const PAL::WebGPU::ComputePipelineDescriptor& descriptor, CompletionHandler<void(Ref<PAL::WebGPU::ComputePipeline>&&)>&& callback)
 {
     auto convertedDescriptor = m_convertToBackingContext->convertToBacking(descriptor);
     ASSERT(convertedDescriptor);
@@ -228,7 +228,7 @@
     callback(RemoteComputePipelineProxy::create(*this, m_convertToBackingContext, identifier));
 }
 
-void RemoteDeviceProxy::createRenderPipelineAsync(const PAL::WebGPU::RenderPipelineDescriptor& descriptor, WTF::Function<void(Ref<PAL::WebGPU::RenderPipeline>&&)>&& callback)
+void RemoteDeviceProxy::createRenderPipelineAsync(const PAL::WebGPU::RenderPipelineDescriptor& descriptor, CompletionHandler<void(Ref<PAL::WebGPU::RenderPipeline>&&)>&& callback)
 {
     auto convertedDescriptor = m_convertToBackingContext->convertToBacking(descriptor);
     ASSERT(convertedDescriptor);
@@ -297,7 +297,7 @@
     UNUSED_VARIABLE(sendResult);
 }
 
-void RemoteDeviceProxy::popErrorScope(WTF::Function<void(std::optional<PAL::WebGPU::Error>&&)>&& callback)
+void RemoteDeviceProxy::popErrorScope(CompletionHandler<void(std::optional<PAL::WebGPU::Error>&&)>&& callback)
 {
     std::optional<Error> error;
     auto sendResult = sendSync(Messages::RemoteDevice::PopErrorScope(), { error });

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.h (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteDeviceProxy.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -88,8 +88,8 @@
     Ref<PAL::WebGPU::ShaderModule> createShaderModule(const PAL::WebGPU::ShaderModuleDescriptor&) final;
     Ref<PAL::WebGPU::ComputePipeline> createComputePipeline(const PAL::WebGPU::ComputePipelineDescriptor&) final;
     Ref<PAL::WebGPU::RenderPipeline> createRenderPipeline(const PAL::WebGPU::RenderPipelineDescriptor&) final;
-    void createComputePipelineAsync(const PAL::WebGPU::ComputePipelineDescriptor&, WTF::Function<void(Ref<PAL::WebGPU::ComputePipeline>&&)>&&) final;
-    void createRenderPipelineAsync(const PAL::WebGPU::RenderPipelineDescriptor&, WTF::Function<void(Ref<PAL::WebGPU::RenderPipeline>&&)>&&) final;
+    void createComputePipelineAsync(const PAL::WebGPU::ComputePipelineDescriptor&, CompletionHandler<void(Ref<PAL::WebGPU::ComputePipeline>&&)>&&) final;
+    void createRenderPipelineAsync(const PAL::WebGPU::RenderPipelineDescriptor&, CompletionHandler<void(Ref<PAL::WebGPU::RenderPipeline>&&)>&&) final;
 
     Ref<PAL::WebGPU::CommandEncoder> createCommandEncoder(const std::optional<PAL::WebGPU::CommandEncoderDescriptor>&) final;
     Ref<PAL::WebGPU::RenderBundleEncoder> createRenderBundleEncoder(const PAL::WebGPU::RenderBundleEncoderDescriptor&) final;
@@ -97,13 +97,13 @@
     Ref<PAL::WebGPU::QuerySet> createQuerySet(const PAL::WebGPU::QuerySetDescriptor&) final;
 
     void pushErrorScope(PAL::WebGPU::ErrorFilter) final;
-    void popErrorScope(WTF::Function<void(std::optional<PAL::WebGPU::Error>&&)>&&) final;
+    void popErrorScope(CompletionHandler<void(std::optional<PAL::WebGPU::Error>&&)>&&) final;
 
     void setLabelInternal(const String&) final;
 
-    Deque<WTF::Function<void(Ref<PAL::WebGPU::ComputePipeline>&&)>> m_createComputePipelineAsyncCallbacks;
-    Deque<WTF::Function<void(Ref<PAL::WebGPU::RenderPipeline>&&)>> m_createRenderPipelineAsyncCallbacks;
-    Deque<WTF::Function<void(std::optional<PAL::WebGPU::Error>&&)>> m_popErrorScopeCallbacks;
+    Deque<CompletionHandler<void(Ref<PAL::WebGPU::ComputePipeline>&&)>> m_createComputePipelineAsyncCallbacks;
+    Deque<CompletionHandler<void(Ref<PAL::WebGPU::RenderPipeline>&&)>> m_createRenderPipelineAsyncCallbacks;
+    Deque<CompletionHandler<void(std::optional<PAL::WebGPU::Error>&&)>> m_popErrorScopeCallbacks;
 
     WebGPUIdentifier m_backing;
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -90,7 +90,7 @@
     m_lost = true;
 }
 
-void RemoteGPUProxy::requestAdapter(const PAL::WebGPU::RequestAdapterOptions& options, WTF::Function<void(RefPtr<PAL::WebGPU::Adapter>&&)>&& callback)
+void RemoteGPUProxy::requestAdapter(const PAL::WebGPU::RequestAdapterOptions& options, CompletionHandler<void(RefPtr<PAL::WebGPU::Adapter>&&)>&& callback)
 {
     if (m_lost) {
         callback(nullptr);

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -95,11 +95,11 @@
     }
     IPC::Connection& connection() const { return m_gpuProcessConnection->connection(); }
 
-    void requestAdapter(const PAL::WebGPU::RequestAdapterOptions&, WTF::Function<void(RefPtr<PAL::WebGPU::Adapter>&&)>&&) final;
+    void requestAdapter(const PAL::WebGPU::RequestAdapterOptions&, CompletionHandler<void(RefPtr<PAL::WebGPU::Adapter>&&)>&&) final;
 
     void abandonGPUProcess();
 
-    Deque<WTF::Function<void(RefPtr<PAL::WebGPU::Adapter>&&)>> m_callbacks;
+    Deque<CompletionHandler<void(RefPtr<PAL::WebGPU::Adapter>&&)>> m_callbacks;
 
     WebGPUIdentifier m_backing;
     Ref<WebGPU::ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.cpp (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -59,7 +59,7 @@
     UNUSED_VARIABLE(sendResult);
 }
 
-void RemoteQueueProxy::onSubmittedWorkDone(WTF::Function<void()>&& callback)
+void RemoteQueueProxy::onSubmittedWorkDone(CompletionHandler<void()>&& callback)
 {
     auto sendResult = sendSync(Messages::RemoteQueue::OnSubmittedWorkDone(), { });
     UNUSED_VARIABLE(sendResult);

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.h (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteQueueProxy.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -75,7 +75,7 @@
 
     void submit(Vector<std::reference_wrapper<PAL::WebGPU::CommandBuffer>>&&) final;
 
-    void onSubmittedWorkDone(WTF::Function<void()>&&) final;
+    void onSubmittedWorkDone(CompletionHandler<void()>&&) final;
 
     void writeBuffer(
         const PAL::WebGPU::Buffer&,
@@ -99,7 +99,7 @@
 
     void setLabelInternal(const String&) final;
 
-    Deque<WTF::Function<void()>> m_callbacks;
+    Deque<CompletionHandler<void()>> m_callbacks;
 
     WebGPUIdentifier m_backing;
     Ref<ConvertToBackingContext> m_convertToBackingContext;

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.cpp (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.cpp	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.cpp	2022-03-15 23:44:09 UTC (rev 291323)
@@ -46,7 +46,7 @@
 {
 }
 
-void RemoteShaderModuleProxy::compilationInfo(WTF::Function<void(Ref<PAL::WebGPU::CompilationInfo>&&)>&& callback)
+void RemoteShaderModuleProxy::compilationInfo(CompletionHandler<void(Ref<PAL::WebGPU::CompilationInfo>&&)>&& callback)
 {
     Vector<CompilationMessage> messages;
     auto sendResult = sendSync(Messages::RemoteShaderModule::CompilationInfo(), { messages });

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.h (291322 => 291323)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.h	2022-03-15 23:40:34 UTC (rev 291322)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteShaderModuleProxy.h	2022-03-15 23:44:09 UTC (rev 291323)
@@ -72,7 +72,7 @@
         return root().streamClientConnection().sendSync(WTFMove(message), WTFMove(reply), backing(), defaultSendTimeout);
     }
 
-    void compilationInfo(WTF::Function<void(Ref<PAL::WebGPU::CompilationInfo>&&)>&&) final;
+    void compilationInfo(CompletionHandler<void(Ref<PAL::WebGPU::CompilationInfo>&&)>&&) final;
 
     void setLabelInternal(const String&) final;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to