Bug 261720

Summary: Give ability for IPC calls to work with NativePromise
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: WebKit Process ModelAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=257934
https://bugs.webkit.org/show_bug.cgi?id=261864

Description Jean-Yves Avenard [:jya] 2023-09-18 21:10:10 PDT
Would give the ability to instead of doing:

```
    m_connectionToWebProcess->connection().sendWithAsyncReply(Messages::MediaSourcePrivateRemote::WaitForTarget(target), WTFMove(completionHandler), m_identifier);
```

you could instead do:
```
    m_connectionToWebProcess->connection().sendWithPromisedReply(Messages::MediaSourcePrivateRemote::WaitForTarget(target), m_identifier)
    ->whenSettled(runLoop, __func__, [] (MediaSourcePrivateRemote::WaitForTarget::Promise::Result&& result) {
        if (result)
            // do something with result.value()
        else
            // do something with result.error()
    });
```

this would also gives the ability to propagate the IPC error, see bug 257934

It also allows to guarantee on which thread the completionHandler will run once the IPC operation has returned its value.
Comment 1 Radar WebKit Bug Importer 2023-09-18 21:12:48 PDT
<rdar://problem/115704438>
Comment 2 Jean-Yves Avenard [:jya] 2023-09-20 00:45:36 PDT
Pull request: https://github.com/WebKit/WebKit/pull/17965
Comment 3 EWS 2023-09-21 00:53:26 PDT
Committed 268240@main (f997a9edb80c): <https://commits.webkit.org/268240@main>

Reviewed commits have been landed. Closing PR #17965 and removing active labels.