0

Cleanup usages of old mojo types and remove unused code

In the context of the migration started last year to migrate all the
uses of old mojo types to the new ones, today I've found that there
were a few bits that we could remove and either migrate easily or
outright remove them, now that nearly all the instances of those old
types have been migrated.

Therefore, this CL does a "sweep" and does the following cleanups in
different places, so that we get closer to the point where no old types
are present:

* Migrate uses of old types to the new ones in a couple of places where
  they were not migrated (i.e. MockChromePrompt, TestService).
* Remove unused templated methods from //ipc still using old types.
* Remove unused Interface{Ptr,Request} variants of helper methods
  Connector::BindInterface(), InterfaceProvider::GetInterface() and
  LocalInterfaceProvider::GetInterface().
* Remove unused includes for header files related to old mojo types.
* Delete strong_associated_binding_set.h (not even being compiled).

TBR=blundell@chromium.org,halliwell@chromium.org,achuith@chromium.org,achuith@chromium.org,kinuko@chromium.org

Bug: 955171
Change-Id: Ia4ca6f3f68bc1d6d4fd4016ed16c07ff132ea19f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2235699
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: Eugene But <eugenebut@chromium.org>
Reviewed-by: Joe Mason <joenotcharles@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#777288}
This commit is contained in:
Mario Sanchez Prada
2020-06-11 08:20:43 +00:00
committed by Commit Bot
parent 1419e31589
commit 85a081bc9b
24 changed files with 47 additions and 205 deletions

@ -140,7 +140,6 @@
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/base/filename_util.h"
#include "ui/aura/client/aura_constants.h"

@ -22,7 +22,8 @@
#include "chrome/chrome_cleaner/test/test_util.h"
#include "components/chrome_cleaner/public/proto/chrome_prompt.pb.h"
#include "components/chrome_cleaner/test/test_name_helper.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
@ -87,8 +88,9 @@ struct TestConfig {
// Class that lives in the parent process and handles that side of the IPC.
class MockChromePrompt : public mojom::ChromePrompt {
public:
MockChromePrompt(TestConfig test_config, mojom::ChromePromptRequest request)
: test_config_(test_config), binding_(this, std::move(request)) {}
MockChromePrompt(TestConfig test_config,
mojo::PendingReceiver<mojom::ChromePrompt> receiver)
: test_config_(test_config), receiver_(this, std::move(receiver)) {}
~MockChromePrompt() override = default;
@ -119,11 +121,11 @@ class MockChromePrompt : public mojom::ChromePrompt {
// |parent_disconnected|.
void CloseConnectionIf(ParentDisconnected parent_disconnected) {
if (test_config_.expected_parent_disconnected == parent_disconnected)
binding_.Close();
receiver_.reset();
}
TestConfig test_config_;
mojo::Binding<chrome_cleaner::mojom::ChromePrompt> binding_;
mojo::Receiver<chrome_cleaner::mojom::ChromePrompt> receiver_{this};
};
class ChromePromptIPCParentProcess : public ParentProcess {
@ -144,9 +146,9 @@ class ChromePromptIPCParentProcess : public ParentProcess {
protected:
void CreateImpl(mojo::ScopedMessagePipeHandle mojo_pipe) override {
mojom::ChromePromptRequest chrome_prompt_request(std::move(mojo_pipe));
mock_chrome_prompt_ = std::make_unique<MockChromePrompt>(
test_config_, std::move(chrome_prompt_request));
test_config_,
mojo::PendingReceiver<mojom::ChromePrompt>(std::move(mojo_pipe)));
// At this point, the child process should be connected.
mock_chrome_prompt_->CloseConnectionIf(ParentDisconnected::kOnStartup);
}

@ -14,7 +14,6 @@
#include "chromecast/common/mojom/activity_url_filter.mojom.h"
#include "content/public/renderer/render_frame_observer.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"

@ -9,7 +9,6 @@
#include "chromeos/components/help_app_ui/help_app_ui.mojom.h"
#include "chromeos/components/help_app_ui/help_app_ui_delegate.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/webui/mojo_web_ui_controller.h"

@ -9,7 +9,6 @@
#include "chromeos/components/media_app_ui/media_app_ui.mojom.h"
#include "chromeos/components/media_app_ui/media_app_ui_delegate.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/webui/mojo_web_ui_controller.h"

@ -58,7 +58,6 @@
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/web_contents_delegate.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/mojom/devtools/devtools_agent.mojom.h"

@ -16,8 +16,6 @@
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
#include "content/test/fake_network_url_loader_factory.h"
#include "mojo/public/cpp/bindings/associated_binding_set.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/common/service_worker/service_worker_utils.h"
#include "third_party/blink/public/common/user_agent/user_agent_metadata.h"

@ -30,7 +30,6 @@
#include "content/common/service_worker/service_worker_utils.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "net/base/net_errors.h"
#include "third_party/blink/public/common/service_worker/service_worker_type_converters.h"
#include "third_party/blink/public/common/service_worker/service_worker_utils.h"

@ -1001,12 +1001,6 @@ class CONTENT_EXPORT ContentBrowserClient {
mojo::GenericPendingReceiver receiver) {
}
// Called when RenderFrameHostImpl connects to the Media service. Expose
// interfaces to the service using |registry|.
virtual void ExposeInterfacesToMediaService(
service_manager::BinderRegistry* registry,
RenderFrameHost* render_frame_host) {}
// The Media Service can run in many different types of configurations
// (typically in the GPU process or its own isolated process), but some
// clients want an additional dedicated instance to use for specific

@ -20,7 +20,6 @@
#include "build/build_config.h"
#include "components/discardable_memory/client/client_discardable_shared_memory_manager.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"

@ -58,7 +58,6 @@
#include "ipc/ipc_message.h"
#include "ipc/ipc_platform_file.h"
#include "media/base/routing_token_callback.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"

@ -15,7 +15,6 @@
#include "ios/web/public/test/web_test.h"
#include "ios/web/test/mojo_test.mojom.h"
#include "ios/web/web_state/web_state_impl.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#import "testing/gtest_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)

@ -24,8 +24,6 @@
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_sender.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
@ -110,21 +108,6 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender {
const std::string& name,
mojo::ScopedInterfaceEndpointHandle handle) = 0;
// Remove this after done with migrating all AsscoiatedInterfacePtr to
// AsscoiatedRemote.
// Template helper to add an interface factory to this channel.
template <typename Interface>
using AssociatedInterfaceFactory = base::RepeatingCallback<void(
mojo::AssociatedInterfaceRequest<Interface>)>;
template <typename Interface>
void AddAssociatedInterface(
const AssociatedInterfaceFactory<Interface>& factory) {
AddGenericAssociatedInterface(
Interface::Name_,
base::BindRepeating(&BindAssociatedInterfaceRequest<Interface>,
factory));
}
// Template helper to add an interface factory to this channel.
template <typename Interface>
using AssociatedReceiverFactory = base::RepeatingCallback<void(
@ -138,17 +121,6 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender {
factory));
}
// Remove this after done with migrating all AsscoiatedInterfacePtr to
// AsscoiatedRemote.
// Template helper to request a remote associated interface.
template <typename Interface>
void GetRemoteAssociatedInterface(
mojo::AssociatedInterfacePtr<Interface>* proxy) {
auto request = mojo::MakeRequest(proxy);
GetGenericRemoteAssociatedInterface(Interface::Name_,
request.PassHandle());
}
// Template helper to request a remote associated interface.
template <typename Interface>
void GetRemoteAssociatedInterface(
@ -158,16 +130,6 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender {
}
private:
// Remove this after done with migrating all AsscoiatedInterfacePtr to
// AsscoiatedRemote.
template <typename Interface>
static void BindAssociatedInterfaceRequest(
const AssociatedInterfaceFactory<Interface>& factory,
mojo::ScopedInterfaceEndpointHandle handle) {
factory.Run(
mojo::AssociatedInterfaceRequest<Interface>(std::move(handle)));
}
template <typename Interface>
static void BindPendingAssociatedReceiver(
const AssociatedReceiverFactory<Interface>& factory,

@ -24,8 +24,6 @@
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
@ -201,16 +199,6 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
const std::string& name,
mojo::ScopedInterfaceEndpointHandle handle);
// Template helper to request associated interfaces from the remote endpoint.
// Remove this after done with migrating all AsscoiatedInterfacePtr to
// AsscoiatedRemote.
template <typename Interface>
void GetRemoteAssociatedInterface(
mojo::AssociatedInterfacePtr<Interface>* proxy) {
auto request = mojo::MakeRequest(proxy);
GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle());
}
// Template helper to receive associated interfaces from the remote endpoint.
template <typename Interface>
void GetRemoteAssociatedInterface(mojo::AssociatedRemote<Interface>* proxy) {

@ -1,25 +0,0 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MOJO_PUBLIC_CPP_BINDINGS_STRONG_ASSOCIATED_BINDING_SET_H_
#define MOJO_PUBLIC_CPP_BINDINGS_STRONG_ASSOCIATED_BINDING_SET_H_
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/associated_binding_set.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/unique_ptr_impl_ref_traits.h"
namespace mojo {
template <typename Interface, typename ContextType = void>
using StrongAssociatedBindingSet = BindingSetBase<
Interface,
AssociatedBinding<Interface, UniquePtrImplRefTraits<Interface>>,
ContextType>;
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_ASSOCIATED_BINDING_SET_H_

@ -27,19 +27,6 @@ class BinderRegistryWithArgs {
BinderRegistryWithArgs() {}
~BinderRegistryWithArgs() = default;
// Adds an interface inferring the interface name via the templated
// parameter Interface::Name_
// Usage example: //services/service_manager/README.md#OnBindInterface
template <typename Interface>
void AddInterface(
const base::RepeatingCallback<void(mojo::InterfaceRequest<Interface>,
BinderArgs...)>& callback,
const scoped_refptr<base::SequencedTaskRunner>& task_runner = nullptr) {
SetInterfaceBinder(
Interface::Name_,
std::make_unique<CallbackBinder<Interface, BinderArgs...>>(
callback, task_runner));
}
template <typename Interface>
void AddInterface(
const base::RepeatingCallback<void(mojo::PendingReceiver<Interface>,

@ -191,19 +191,6 @@ class SERVICE_MANAGER_PUBLIC_CPP_EXPORT Connector {
std::move(callback));
}
template <typename Interface>
void BindInterface(const ServiceFilter& filter,
mojo::InterfacePtr<Interface>* ptr) {
BindInterface(filter, mojo::MakeRequest(ptr));
}
template <typename Interface>
void BindInterface(const std::string& service_name,
mojo::InterfacePtr<Interface>* ptr) {
return BindInterface(ServiceFilter::ByName(service_name),
mojo::MakeRequest(ptr));
}
template <typename Interface>
void BindInterface(const std::string& service_name,
mojo::PendingReceiver<Interface> receiver) {

@ -9,7 +9,6 @@
#include <utility>
#include "base/bind.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/system/message_pipe.h"
@ -31,8 +30,8 @@ class InterfaceBinder {
virtual ~InterfaceBinder() {}
// Asks the InterfaceBinder to bind an implementation of the specified
// interface to the request passed via |handle|. If the InterfaceBinder binds
// an implementation it must take ownership of the request handle.
// interface to the receiver passed via |handle|. If the InterfaceBinder binds
// an implementation it must take ownership of the receiver handle.
virtual void BindInterface(const std::string& interface_name,
mojo::ScopedMessagePipeHandle handle,
BinderArgs... args) = 0;
@ -42,18 +41,12 @@ template <typename Interface, typename... BinderArgs>
class CallbackBinder : public InterfaceBinder<BinderArgs...> {
public:
using BindCallback =
base::RepeatingCallback<void(mojo::InterfaceRequest<Interface>,
base::RepeatingCallback<void(mojo::PendingReceiver<Interface>,
BinderArgs...)>;
CallbackBinder(const BindCallback& callback,
const scoped_refptr<base::SequencedTaskRunner>& task_runner)
: callback_(callback), task_runner_(task_runner) {}
CallbackBinder(
const base::RepeatingCallback<void(mojo::PendingReceiver<Interface>,
BinderArgs...)>& callback,
const scoped_refptr<base::SequencedTaskRunner>& task_runner)
: CallbackBinder(base::BindRepeating(&RunBindReceiverCallback, callback),
task_runner) {}
~CallbackBinder() override = default;
private:
@ -61,28 +54,28 @@ class CallbackBinder : public InterfaceBinder<BinderArgs...> {
void BindInterface(const std::string& interface_name,
mojo::ScopedMessagePipeHandle handle,
BinderArgs... args) override {
mojo::InterfaceRequest<Interface> request(std::move(handle));
mojo::PendingReceiver<Interface> receiver(std::move(handle));
if (task_runner_) {
task_runner_->PostTask(
FROM_HERE, base::BindOnce(&CallbackBinder::RunCallback, callback_,
std::move(request), args...));
std::move(receiver), args...));
} else {
RunCallback(callback_, std::move(request), args...);
RunCallback(callback_, std::move(receiver), args...);
}
}
static void RunCallback(const BindCallback& callback,
mojo::InterfaceRequest<Interface> request,
mojo::PendingReceiver<Interface> receiver,
BinderArgs... args) {
callback.Run(std::move(request), args...);
callback.Run(std::move(receiver), args...);
}
static void RunBindReceiverCallback(
const base::RepeatingCallback<void(mojo::PendingReceiver<Interface>,
BinderArgs...)>& callback,
mojo::InterfaceRequest<Interface> request,
mojo::PendingReceiver<Interface> receiver,
BinderArgs... args) {
callback.Run(std::move(request), args...);
callback.Run(std::move(receiver), args...);
}
const BindCallback callback_;

@ -16,7 +16,7 @@ namespace service_manager {
// Encapsulates a mojo::PendingRemote|Remote<mojom::InterfaceProvider>
// implemented in a remote application. Provides two main features:
// - a typesafe GetInterface() method for binding InterfacePtrs.
// - a typesafe GetInterface() method for binding Interface remotes.
// - a testing API that allows local callbacks to be registered that bind
// requests for remote interfaces.
// An instance of this class is used by the GetInterface() methods on
@ -87,18 +87,11 @@ class SERVICE_MANAGER_PUBLIC_CPP_EXPORT InterfaceProvider {
base::WeakPtr<InterfaceProvider> GetWeakPtr();
// Binds a passed in interface pointer to an implementation of the interface
// in the remote application using MakeRequest. The interface pointer can
// immediately be used to start sending requests to the remote interface.
// Uses templated parameters in order to work with weak interfaces in blink.
template <typename... Args>
void GetInterface(Args&&... args) {
GetInterface(MakeRequest(std::forward<Args>(args)...));
}
template <typename Interface>
void GetInterface(mojo::InterfaceRequest<Interface> request) {
GetInterfaceByName(Interface::Name_, std::move(request.PassMessagePipe()));
}
// Binds a passed in pending receiver to an implementation of the interface in
// the remote application. The mojo remote associated to the interface in the
// local application can immediately be used to start sending requests to the
// remote interface. Uses templated parameters in order to work with weak
// interfaces in blink.
template <typename Interface>
void GetInterface(mojo::PendingReceiver<Interface> receiver) {
GetInterfaceByName(Interface::Name_, receiver.PassPipe());
@ -106,23 +99,7 @@ class SERVICE_MANAGER_PUBLIC_CPP_EXPORT InterfaceProvider {
void GetInterfaceByName(const std::string& name,
mojo::ScopedMessagePipeHandle request_handle);
// Returns a callback to GetInterface<Interface>(). This can be passed to
// BinderRegistry::AddInterface() to forward requests.
template <typename Interface>
base::RepeatingCallback<void(mojo::InterfaceRequest<Interface>)>
CreateInterfaceFactory() {
return base::BindRepeating(
&InterfaceProvider::BindInterfaceRequestFromSource<Interface>,
GetWeakPtr());
}
private:
template <typename Interface>
void BindInterfaceRequestFromSource(
mojo::InterfaceRequest<Interface> request) {
GetInterface<Interface>(std::move(request));
}
void SetBinderForName(
const std::string& name,
base::RepeatingCallback<void(mojo::ScopedMessagePipeHandle)> binder) {

@ -6,8 +6,6 @@
#define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_INTERFACE_PROVIDER_BASE_H_
#include "base/macros.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "services/service_manager/public/cpp/export.h"
@ -18,19 +16,6 @@ class LocalInterfaceProvider {
public:
virtual ~LocalInterfaceProvider() = default;
// Binds |ptr| to an implementation of Interface in the remote application.
// |ptr| can immediately be used to start sending requests to the remote
// interface.
template <typename Interface>
void GetInterface(mojo::InterfacePtr<Interface>* ptr) {
mojo::MessagePipe pipe;
ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u));
GetInterface(Interface::Name_, std::move(pipe.handle1));
}
template <typename Interface>
void GetInterface(mojo::InterfaceRequest<Interface> request) {
GetInterface(Interface::Name_, std::move(request.PassMessagePipe()));
}
template <typename Interface>
void GetInterface(mojo::PendingReceiver<Interface> receiver) {
GetInterface(Interface::Name_, std::move(receiver.PassPipe()));

@ -10,7 +10,6 @@
#include "base/bind_helpers.h"
#include "base/guid.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"

@ -7,7 +7,8 @@
#include "base/bind.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_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/connector.h"
@ -22,8 +23,9 @@ namespace {
class Parent : public service_manager::Service,
public service_manager::test::mojom::Parent {
public:
explicit Parent(service_manager::mojom::ServiceRequest request)
: service_binding_(this, std::move(request)) {
explicit Parent(
mojo::PendingReceiver<service_manager::mojom::Service> receiver)
: service_binding_(this, std::move(receiver)) {
registry_.AddInterface<service_manager::test::mojom::Parent>(
base::BindRepeating(&Parent::Create, base::Unretained(this)));
}
@ -38,8 +40,9 @@ class Parent : public service_manager::Service,
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
void Create(service_manager::test::mojom::ParentRequest request) {
parent_bindings_.AddBinding(this, std::move(request));
void Create(
mojo::PendingReceiver<service_manager::test::mojom::Parent> receiver) {
parent_receivers_.Add(this, std::move(receiver));
}
// service_manager::test::mojom::Parent:
@ -59,7 +62,7 @@ class Parent : public service_manager::Service,
service_manager::ServiceBinding service_binding_;
service_manager::BinderRegistry registry_;
mojo::BindingSet<service_manager::test::mojom::Parent> parent_bindings_;
mojo::ReceiverSet<service_manager::test::mojom::Parent> parent_receivers_;
DISALLOW_COPY_AND_ASSIGN(Parent);
};

@ -23,8 +23,8 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/token.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/binding.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.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/platform/platform_channel.h"
@ -97,8 +97,8 @@ class TestService : public Service, public test::mojom::CreateInstanceTest {
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
void Create(test::mojom::CreateInstanceTestRequest request) {
binding_.Bind(std::move(request));
void Create(mojo::PendingReceiver<test::mojom::CreateInstanceTest> receiver) {
receiver_.Bind(std::move(receiver));
}
// test::mojom::CreateInstanceTest:
@ -115,7 +115,7 @@ class TestService : public Service, public test::mojom::CreateInstanceTest {
std::unique_ptr<base::RunLoop> wait_for_target_identity_loop_;
BinderRegistry registry_;
mojo::Binding<test::mojom::CreateInstanceTest> binding_{this};
mojo::Receiver<test::mojom::CreateInstanceTest> receiver_{this};
DISALLOW_COPY_AND_ASSIGN(TestService);
};
@ -537,11 +537,12 @@ TEST_F(ServiceManagerTest, ClientProcessCapabilityEnforced) {
// Introduce a new service instance for service_manager_unittest_target,
// which should be allowed because the test service has
// |can_create_other_service_instances| set to |true| in its manifest.
mojom::ServicePtr test_service_proxy1;
SimpleService test_service1(mojo::MakeRequest(&test_service_proxy1));
mojo::PendingRemote<mojom::Service> test_service_remote1;
SimpleService test_service1(
test_service_remote1.InitWithNewPipeAndPassReceiver());
mojo::Remote<mojom::ProcessMetadata> metadata1;
connector()->RegisterServiceInstance(kInstance1Id,
test_service_proxy1.PassInterface(),
std::move(test_service_remote1),
metadata1.BindNewPipeAndPassReceiver());
metadata1->SetPID(42);
WaitForInstanceToStart(kInstance1Id);
@ -550,11 +551,12 @@ TEST_F(ServiceManagerTest, ClientProcessCapabilityEnforced) {
// Now use the new instance (which does not have client_process capability)
// to attempt introduction of yet another instance. This should fail.
mojom::ServicePtr test_service_proxy2;
SimpleService test_service2(mojo::MakeRequest(&test_service_proxy2));
mojo::PendingRemote<mojom::Service> test_service_remote2;
SimpleService test_service2(
test_service_remote2.InitWithNewPipeAndPassReceiver());
mojo::Remote<mojom::ProcessMetadata> metadata2;
test_service1.connector()->RegisterServiceInstance(
kInstance2Id, test_service_proxy2.PassInterface(),
kInstance2Id, std::move(test_service_remote2),
metadata2.BindNewPipeAndPassReceiver());
metadata2->SetPID(43);

@ -11,7 +11,6 @@
#include "base/macros.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/strong_binding_set.h"
#include "mojo/public/cpp/bindings/unique_receiver_set.h"
#include "services/tracing/perfetto/consumer_host.h"
#include "services/tracing/public/cpp/perfetto/task_runner.h"