dawn_wire: Factor the common command serialization pattern.

Bug: dawn:445

Change-Id: I15a99a126c0494fd06dd727ff5c9008cde675d76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23560
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2020-06-19 16:49:43 +00:00
committed by Commit Bot service account
parent 8f9523eb38
commit 90abd47a28
12 changed files with 57 additions and 92 deletions

View File

@@ -31,18 +31,14 @@ namespace dawn_wire { namespace server {
cmd.type = type;
cmd.message = message;
size_t requiredSize = cmd.GetRequiredSize();
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
cmd.Serialize(allocatedBuffer);
SerializeCommand(cmd);
}
void Server::OnDeviceLost(const char* message) {
ReturnDeviceLostCallbackCmd cmd;
cmd.message = message;
size_t requiredSize = cmd.GetRequiredSize();
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
cmd.Serialize(allocatedBuffer);
SerializeCommand(cmd);
}
bool Server::DoDevicePopErrorScope(WGPUDevice cDevice, uint64_t requestSerial) {
@@ -73,9 +69,7 @@ namespace dawn_wire { namespace server {
cmd.type = type;
cmd.message = message;
size_t requiredSize = cmd.GetRequiredSize();
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
cmd.Serialize(allocatedBuffer);
SerializeCommand(cmd);
}
}} // namespace dawn_wire::server