Commit e8c9f74a authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert Mojo interfaces from shutdown.test-mojom to new Mojo types

This CL converts ShutdownTestService, ShutdownTestClient, and
ShutdownTestClientController to new Mojo types using PendingReceiver,
PendingRemote, Remote, and Receiver.

Bug: 955171
Change-Id: I3731946c426df305ac59657fa8c255485362a496
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930242Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#718337}
parent a91fe279
......@@ -5,7 +5,7 @@
module service_manager.mojom;
interface ShutdownTestService {
SetClient(ShutdownTestClient client);
SetClient(pending_remote<ShutdownTestClient> client);
ShutDown();
};
......
......@@ -6,7 +6,9 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_executor.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service.h"
......@@ -36,8 +38,9 @@ class ShutdownClientApp : public Service,
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
void Create(mojom::ShutdownTestClientControllerRequest request) {
bindings_.AddBinding(this, std::move(request));
void Create(
mojo::PendingReceiver<mojom::ShutdownTestClientController> receiver) {
receivers_.Add(this, std::move(receiver));
}
// mojom::ShutdownTestClientController:
......@@ -46,15 +49,12 @@ class ShutdownClientApp : public Service,
service_binding_.GetConnector()->BindInterface("shutdown_service",
&service);
mojo::Binding<mojom::ShutdownTestClient> client_binding(this);
mojo::Receiver<mojom::ShutdownTestClient> client_receiver(this);
mojom::ShutdownTestClientPtr client_ptr;
client_binding.Bind(mojo::MakeRequest(&client_ptr));
service->SetClient(std::move(client_ptr));
service->SetClient(client_receiver.BindNewPipeAndPassRemote());
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
client_binding.set_connection_error_handler(run_loop.QuitClosure());
client_receiver.set_disconnect_handler(run_loop.QuitClosure());
run_loop.Run();
std::move(callback).Run();
......@@ -62,7 +62,7 @@ class ShutdownClientApp : public Service,
ServiceBinding service_binding_;
BinderRegistry registry_;
mojo::BindingSet<mojom::ShutdownTestClientController> bindings_;
mojo::ReceiverSet<mojom::ShutdownTestClientController> receivers_;
DISALLOW_COPY_AND_ASSIGN(ShutdownClientApp);
};
......
......@@ -5,7 +5,9 @@
#include "base/bind.h"
#include "base/macros.h"
#include "base/task/single_thread_task_executor.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_binding.h"
......@@ -35,16 +37,17 @@ class ShutdownServiceApp : public Service, public mojom::ShutdownTestService {
}
// mojom::ShutdownTestService:
void SetClient(mojom::ShutdownTestClientPtr client) override {}
void SetClient(
mojo::PendingRemote<mojom::ShutdownTestClient> client) override {}
void ShutDown() override { Terminate(); }
void Create(mojom::ShutdownTestServiceRequest request) {
bindings_.AddBinding(this, std::move(request));
void Create(mojo::PendingReceiver<mojom::ShutdownTestService> receiver) {
receivers_.Add(this, std::move(receiver));
}
ServiceBinding service_binding_;
BinderRegistry registry_;
mojo::BindingSet<mojom::ShutdownTestService> bindings_;
mojo::ReceiverSet<mojom::ShutdownTestService> receivers_;
DISALLOW_COPY_AND_ASSIGN(ShutdownServiceApp);
};
......
......@@ -7,6 +7,7 @@
#include "base/no_destructor.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/manifest.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
......@@ -92,12 +93,14 @@ TEST_F(ShutdownTest, ConnectRace) {
// not
// working as intended.
mojom::ShutdownTestClientControllerPtr control;
connector()->BindInterface(kShutdownClientName, &control);
mojo::Remote<mojom::ShutdownTestClientController> control;
connector()->Connect(kShutdownClientName,
control.BindNewPipeAndPassReceiver());
// Connect to shutdown_service and immediately request that it shut down.
mojom::ShutdownTestServicePtr service;
connector()->BindInterface(kShutdownServiceName, &service);
mojo::Remote<mojom::ShutdownTestService> service;
connector()->Connect(kShutdownServiceName,
service.BindNewPipeAndPassReceiver());
service->ShutDown();
// Tell shutdown_client to connect to an interface on shutdown_service and
......
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