Introduce CompletionHandler-based Async IPC messages with replies
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 17:40:20 +0000 (17:40 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 17:40:20 +0000 (17:40 +0000)
commit0d5b52cc66b99b6c2b9dc5bff409da769e27727c
tree8f96839272f6f39495a1690b61f2a53638ad0af4
parent63c52b3871773ad02dd32494cb38bf5d55ea4f34
Introduce CompletionHandler-based Async IPC messages with replies
https://bugs.webkit.org/show_bug.cgi?id=190746

Reviewed by Tim Horton.

Before this patch, to make an asynchronous IPC message with a reply you had to find two objects that
can talk to each other, make two new message types, send a generated identifier, keep track of that
identifier, make a HashMap somewhere to store the object waiting for the response, and hook it all up.
What a mess.  No wonder people take shortcuts and make strange design decisions.

Now, you can just use a CompletionHandler and mark the reply as Async in *.messages.in.
I've adopted this with a message whose behavior is covered by the storage/indexeddb/modern/blob-cursor.html
layout test and many others.  I intent to refine and further adopt this incrementally.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::getSandboxExtensionsForBlobFiles):
(WebKit::NetworkProcess::didGetSandboxExtensionsForBlobFiles): Deleted.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
This is representative of how code will be simplified with greater adoption.
* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::decode):
Modernize HandleArray decoding.
* Platform/IPC/Connection.cpp:
(IPC::Connection::dispatchMessage):
(IPC::nextAsyncReplyHandlerID):
(IPC::asyncReplyHandlerMap):
Handle async replies when looking at incoming messages from the sending process.
* Platform/IPC/Connection.h:
(IPC::Connection::sendWithAsyncReply):
Send a message with an async reply and prepare the reply receiver.
* Platform/IPC/Encoder.h:
Make the uint64_t encoder public so we can use it when encoding the listenerID.
* Platform/IPC/HandleMessage.h:
(IPC::handleMessageAsync):
Handle an asynchronous message with a reply from the receiving process.
This is similar to how DelayedReply messages are handled, but the listenerID is automatically captured and sent back.
* Scripts/webkit/messages.py:
Generate code for async message replies.
* Shared/Databases/IndexedDB/WebIDBResult.cpp:
(WebKit::WebIDBResult::decode):
* Shared/SandboxExtension.h:
(WebKit::SandboxExtension::HandleArray::at):
(WebKit::SandboxExtension::HandleArray::decode):
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::decode):
* Shared/mac/SandboxExtensionMac.mm:
(WebKit::SandboxExtension::HandleArray::decode):
Modernize the decoding of HandleArray to work with generated decoding.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::getSandboxExtensionsForBlobFiles):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
This is also representative of how code will be simplified with greater adoption.
* WebProcess/MediaStream/MediaDeviceSandboxExtensions.cpp:
(WebKit::MediaDeviceSandboxExtensions::decode):
Modernize HandleArray decoding.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237294 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
Source/WebKit/Platform/IPC/Connection.cpp
Source/WebKit/Platform/IPC/Connection.h
Source/WebKit/Platform/IPC/Encoder.h
Source/WebKit/Platform/IPC/HandleMessage.h
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Shared/Databases/IndexedDB/WebIDBResult.cpp
Source/WebKit/Shared/SandboxExtension.h
Source/WebKit/Shared/WebProcessCreationParameters.cpp
Source/WebKit/Shared/mac/SandboxExtensionMac.mm
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
Source/WebKit/WebProcess/MediaStream/MediaDeviceSandboxExtensions.cpp