Update ChannelProxy and SyncMessageFilter with PendingAssociatedReceiver
This is a part of the effort to convert to new Mojo types. This CL updates ChannelProxy and SyncMessageFilter with PendingAssociatedReceiver instead of AssociatedInterfaceRequest. Bug: 955171 Change-Id: I6db2902ddc0cf42be819241ebf020a2b39a616bc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1950733 Reviewed-by: Ken Rockot <rockot@google.com> Commit-Queue: Julie Kim <jkim@igalia.com> Cr-Commit-Position: refs/heads/master@{#722730}
This commit is contained in:

committed by
Commit Bot

parent
42ba90c031
commit
a6c8e67fc1
@ -26,7 +26,7 @@
|
||||
#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/pending_associated_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
|
||||
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
|
||||
|
||||
|
@ -28,8 +28,10 @@
|
||||
#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"
|
||||
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
|
||||
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
|
||||
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
|
||||
#include "mojo/public/cpp/bindings/shared_associated_remote.h"
|
||||
|
||||
namespace base {
|
||||
class SingleThreadTaskRunner;
|
||||
@ -179,8 +181,8 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
|
||||
const GenericAssociatedInterfaceFactory& factory);
|
||||
|
||||
template <typename Interface>
|
||||
using AssociatedInterfaceFactory = base::RepeatingCallback<void(
|
||||
mojo::AssociatedInterfaceRequest<Interface>)>;
|
||||
using AssociatedInterfaceFactory =
|
||||
base::RepeatingCallback<void(mojo::PendingAssociatedReceiver<Interface>)>;
|
||||
|
||||
// Helper to bind an IO-thread associated interface factory, inferring the
|
||||
// interface name from the callback argument's type. MUST be called before
|
||||
@ -191,7 +193,7 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
|
||||
AddGenericAssociatedInterfaceForIOThread(
|
||||
Interface::Name_,
|
||||
base::BindRepeating(
|
||||
&ChannelProxy::BindAssociatedInterfaceRequest<Interface>, factory));
|
||||
&ChannelProxy::BindPendingAssociatedReceiver<Interface>, factory));
|
||||
}
|
||||
|
||||
// Requests an associated interface from the remote endpoint.
|
||||
@ -200,6 +202,8 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
|
||||
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) {
|
||||
@ -220,20 +224,19 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creates a ThreadSafeAssociatedInterfacePtr for |Interface|. This object
|
||||
// may be used to send messages on the interface from any thread and those
|
||||
// messages will remain ordered with respect to other messages sent on the
|
||||
// same thread over other ThreadSafeAssociatedInterfacePtrs associated with
|
||||
// the same Channel.
|
||||
// Creates a SharedAssociatedRemote for |Interface|. This object may be used
|
||||
// to send messages on the interface from any thread and those messages will
|
||||
// remain ordered with respect to other messages sent on the same thread over
|
||||
// other SharedAssociatedRemotes associated with the same Channel.
|
||||
template <typename Interface>
|
||||
void GetThreadSafeRemoteAssociatedInterface(
|
||||
scoped_refptr<mojo::ThreadSafeAssociatedInterfacePtr<Interface>>*
|
||||
out_ptr) {
|
||||
mojo::AssociatedInterfacePtrInfo<Interface> ptr_info;
|
||||
auto request = mojo::MakeRequest(&ptr_info);
|
||||
GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle());
|
||||
*out_ptr = mojo::ThreadSafeAssociatedInterfacePtr<Interface>::Create(
|
||||
std::move(ptr_info), ipc_task_runner());
|
||||
scoped_refptr<mojo::SharedAssociatedRemote<Interface>>* out_remote) {
|
||||
mojo::PendingAssociatedRemote<Interface> pending_remote;
|
||||
auto receiver = pending_remote.InitWithNewEndpointAndPassReceiver();
|
||||
GetGenericRemoteAssociatedInterface(Interface::Name_,
|
||||
receiver.PassHandle());
|
||||
*out_remote = mojo::SharedAssociatedRemote<Interface>::Create(
|
||||
std::move(pending_remote), ipc_task_runner());
|
||||
}
|
||||
|
||||
base::SingleThreadTaskRunner* ipc_task_runner() const {
|
||||
@ -429,10 +432,10 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
|
||||
friend class IpcSecurityTestUtil;
|
||||
|
||||
template <typename Interface>
|
||||
static void BindAssociatedInterfaceRequest(
|
||||
static void BindPendingAssociatedReceiver(
|
||||
const AssociatedInterfaceFactory<Interface>& factory,
|
||||
mojo::ScopedInterfaceEndpointHandle handle) {
|
||||
factory.Run(mojo::AssociatedInterfaceRequest<Interface>(std::move(handle)));
|
||||
factory.Run(mojo::PendingAssociatedReceiver<Interface>(std::move(handle)));
|
||||
}
|
||||
|
||||
// Always called once immediately after Init.
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include "ipc/ipc_sender.h"
|
||||
#include "ipc/ipc_sync_message.h"
|
||||
#include "ipc/message_filter.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/pending_associated_remote.h"
|
||||
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
|
||||
|
||||
namespace base {
|
||||
@ -52,9 +52,10 @@ class COMPONENT_EXPORT(IPC) SyncMessageFilter : public MessageFilter,
|
||||
// OnFilterAdded.
|
||||
template <typename Interface>
|
||||
void GetRemoteAssociatedInterface(
|
||||
mojo::AssociatedInterfacePtr<Interface>* proxy) {
|
||||
auto request = mojo::MakeRequest(proxy);
|
||||
GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle());
|
||||
mojo::PendingAssociatedRemote<Interface>* proxy) {
|
||||
auto receiver = proxy->InitWithNewEndpointAndPassReceiver();
|
||||
GetGenericRemoteAssociatedInterface(Interface::Name_,
|
||||
receiver.PassHandle());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user