Commit 6dd4e24b authored by Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez Committed by Commit Bot

Use mojo::FusePipes in ScenicGpuService::Initialize

We get rid of a helper function, replacing it with a function with the
same purpose provided by the Mojo bindings. Also add comments on the
purpose of the function and why it's using FusePipes.

Bug: 955171
Change-Id: I52aaa8a3b031fee0d39b11243d89627e5131f3b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890036
Commit-Queue: Michael Spang <spang@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711388}
parent acb66218
......@@ -9,25 +9,6 @@
namespace ui {
namespace {
// Fulfills a PendingReceiver<T> using a PendingRemote<T>.
//
// Messages queued on the PendingReceiver's message pipe are preserved and will
// be eventually delivered to the remote end of PendingRemote<T>'s.
//
// PendingRemote<T> must be a brand new interface; i.e., it not have been
// previously used to send a message.
template <typename Interface>
void FulfillPendingReceiver(mojo::PendingReceiver<Interface> receiver,
mojo::PendingRemote<Interface> remote) {
MojoResult result =
mojo::FuseMessagePipes(remote.PassPipe(), receiver.PassPipe());
DCHECK_EQ(result, MOJO_RESULT_OK);
}
} // namespace
ScenicGpuService::ScenicGpuService(
mojo::PendingReceiver<mojom::ScenicGpuHost> gpu_host_receiver)
: gpu_host_receiver_(std::move(gpu_host_receiver)) {}
......@@ -42,7 +23,15 @@ ScenicGpuService::GetBinderCallback() {
void ScenicGpuService::Initialize(
mojo::PendingRemote<mojom::ScenicGpuHost> gpu_host) {
FulfillPendingReceiver(std::move(gpu_host_receiver_), std::move(gpu_host));
// The ScenicGpuService acts as a bridge to bind the
// Remote<mojom::ScenicGpuHost>, owned by ScenicSurfaceFactory and
// received in the constructor, and the mojo::Receiver<mojom::ScenicGpuHost>,
// owned by ScenicGpuHost and received as a parameter in this function. Using
// mojo::FusePipes is the only way to "bind" a pending remote with a
// pending receiver.
bool result =
mojo::FusePipes(std::move(gpu_host_receiver_), std::move(gpu_host));
DCHECK(result);
}
void ScenicGpuService::AddReceiver(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment