Skip to content
Permalink
Browse files

Convert RouteProvider to new Mojo types

This CL converts RouteProvider{AssociatedPtr, AssociatedRequest}
in content to the new Mojo types, and introduces
GetRemoteAssociatedInterface(mojo::AssociatedRemote<Interface>*)
in ipc_channel_proxy.h

Bug: 955171, 978694
Change-Id: Ifc8afca4b05a7f537780b3604893f3f5bf667eaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784310
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#693569}
  • Loading branch information
MyidShin authored and Commit Bot committed Sep 5, 2019
1 parent 424efce commit 998cfcf0fa6f703175a13486a4dccc99428a6f61
@@ -1430,7 +1430,6 @@ RenderProcessHostImpl::RenderProcessHostImpl(
pending_views_(0),
keep_alive_ref_count_(0),
is_keep_alive_ref_count_disabled_(false),
route_provider_binding_(this),
visible_clients_(0),
priority_(!blink::kLaunchingProcessIsBackgrounded,
false /* has_media_stream */,
@@ -1800,6 +1799,7 @@ void RenderProcessHostImpl::InitializeChannelProxy() {
//
// See OnProcessLaunched() for some additional details of this somewhat
// surprising behavior.
remote_route_provider_.reset();
channel_->GetRemoteAssociatedInterface(&remote_route_provider_);
channel_->GetRemoteAssociatedInterface(&renderer_interface_);

@@ -2184,10 +2184,10 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
}

void RenderProcessHostImpl::BindRouteProvider(
mojom::RouteProviderAssociatedRequest request) {
if (route_provider_binding_.is_bound())
mojo::PendingAssociatedReceiver<mojom::RouteProvider> receiver) {
if (route_provider_receiver_.is_bound())
return;
route_provider_binding_.Bind(std::move(request));
route_provider_receiver_.Bind(std::move(receiver));
}

void RenderProcessHostImpl::GetRoute(
@@ -4150,8 +4150,7 @@ void RenderProcessHostImpl::ProcessDied(
void RenderProcessHostImpl::ResetIPC() {
if (renderer_host_binding_.is_bound())
renderer_host_binding_.Unbind();
if (route_provider_binding_.is_bound())
route_provider_binding_.Close();
route_provider_receiver_.reset();
associated_interface_provider_bindings_.CloseAllBindings();
associated_interfaces_.reset();

@@ -51,9 +51,11 @@
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_platform_file.h"
#include "media/media_buildflags.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/associated_binding_set.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/invitation.h"
@@ -573,7 +575,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
BrowserHistogramCallback callback) override;
void SuddenTerminationChanged(bool enabled) override;

void BindRouteProvider(mojom::RouteProviderAssociatedRequest request);
void BindRouteProvider(
mojo::PendingAssociatedReceiver<mojom::RouteProvider> receiver);

void CreateEmbeddedFrameSinkProvider(
mojo::PendingReceiver<blink::mojom::EmbeddedFrameSinkProvider> receiver);
@@ -761,7 +764,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
// nature (e.g. metrics, memory usage).
std::unique_ptr<blink::AssociatedInterfaceRegistry> associated_interfaces_;

mojo::AssociatedBinding<mojom::RouteProvider> route_provider_binding_;
mojo::AssociatedReceiver<mojom::RouteProvider> route_provider_receiver_{this};
mojo::AssociatedBindingSet<blink::mojom::AssociatedInterfaceProvider, int32_t>
associated_interface_provider_bindings_;

@@ -911,7 +914,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
std::unique_ptr<PluginRegistryImpl> plugin_registry_;

mojo::Remote<mojom::ChildProcess> child_process_;
mojom::RouteProviderAssociatedPtr remote_route_provider_;
mojo::AssociatedRemote<mojom::RouteProvider> remote_route_provider_;
mojom::RendererAssociatedPtr renderer_interface_;
mojo::AssociatedBinding<mojom::RendererHost> renderer_host_binding_;

@@ -515,8 +515,7 @@ ChildThreadImpl::ChildThreadImpl(base::RepeatingClosure quit_closure)

ChildThreadImpl::ChildThreadImpl(base::RepeatingClosure quit_closure,
const Options& options)
: route_provider_binding_(this),
router_(this),
: router_(this),
quit_closure_(std::move(quit_closure)),
browser_process_io_runner_(options.browser_process_io_runner),
channel_connected_factory_(
@@ -846,13 +845,14 @@ void ChildThreadImpl::OnAssociatedInterfaceRequest(
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) {
if (interface_name == mojom::RouteProvider::Name_) {
DCHECK(!route_provider_binding_.is_bound());
route_provider_binding_.Bind(
mojom::RouteProviderAssociatedRequest(std::move(handle)),
DCHECK(!route_provider_receiver_.is_bound());
route_provider_receiver_.Bind(
mojo::PendingAssociatedReceiver<mojom::RouteProvider>(
std::move(handle)),
ipc_task_runner_ ? ipc_task_runner_
: base::ThreadTaskRunnerHandle::Get());
} else {
LOG(ERROR) << "Request for unknown Channel-associated interface: "
LOG(ERROR) << "Receiver for unknown Channel-associated interface: "
<< interface_name;
}
}
@@ -28,8 +28,9 @@
#include "ipc/ipc_buildflags.h" // For BUILDFLAG(IPC_MESSAGE_LOG_ENABLED).
#include "ipc/ipc_platform_file.h"
#include "ipc/message_router.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/associated_binding_set.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
#include "mojo/public/cpp/bindings/shared_remote.h"
#include "services/service_manager/public/mojom/service.mojom.h"
@@ -219,10 +220,10 @@ class CONTENT_EXPORT ChildThreadImpl
std::unique_ptr<mojo::core::ScopedIPCSupport> mojo_ipc_support_;
std::unique_ptr<ServiceManagerConnection> service_manager_connection_;

mojo::AssociatedBinding<mojom::RouteProvider> route_provider_binding_;
mojo::AssociatedReceiver<mojom::RouteProvider> route_provider_receiver_{this};
mojo::AssociatedBindingSet<blink::mojom::AssociatedInterfaceProvider, int32_t>
associated_interface_provider_bindings_;
mojom::RouteProviderAssociatedPtr remote_route_provider_;
mojo::AssociatedRemote<mojom::RouteProvider> remote_route_provider_;
#if defined(OS_WIN)
mojom::FontCacheWinPtr font_cache_win_ptr_;
#endif
@@ -26,6 +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/scoped_interface_endpoint_handle.h"
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"

@@ -205,6 +206,13 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle());
}

// Template helper to receive associated interfaces from the remote endpoint.
template <typename Interface>
void GetRemoteAssociatedInterface(mojo::AssociatedRemote<Interface>* proxy) {
GetGenericRemoteAssociatedInterface(
Interface::Name_, proxy->BindNewEndpointAndPassReceiver().PassHandle());
}

#if defined(ENABLE_IPC_FUZZER)
void set_outgoing_message_filter(OutgoingMessageFilter* filter) {
outgoing_message_filter_ = filter;

0 comments on commit 998cfcf

Please sign in to comment.
You can’t perform that action at this time.