| Index: content/browser/renderer_host/render_process_host_impl.cc
|
| diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
|
| index 0de0be4a4f8c0e815be76ea25ab784bc5e62d71d..937e3cef60efb461b242efbe73494be5d9a37336 100644
|
| --- a/content/browser/renderer_host/render_process_host_impl.cc
|
| +++ b/content/browser/renderer_host/render_process_host_impl.cc
|
| @@ -148,6 +148,7 @@
|
| #include "content/public/browser/user_metrics.h"
|
| #include "content/public/browser/worker_service.h"
|
| #include "content/public/common/child_process_host.h"
|
| +#include "content/public/common/connection_filter.h"
|
| #include "content/public/common/content_constants.h"
|
| #include "content/public/common/content_features.h"
|
| #include "content/public/common/content_switches.h"
|
| @@ -172,6 +173,7 @@
|
| #include "mojo/edk/embedder/embedder.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
| #include "ppapi/shared_impl/ppapi_switches.h"
|
| +#include "services/shell/public/cpp/connection.h"
|
| #include "services/shell/public/cpp/interface_provider.h"
|
| #include "services/shell/public/cpp/interface_registry.h"
|
| #include "services/shell/runner/common/switches.h"
|
| @@ -454,13 +456,6 @@ std::string UintVectorToString(const std::vector<unsigned>& vector) {
|
| return str;
|
| }
|
|
|
| -void CreateMemoryCoordinatorHandle(
|
| - int render_process_id,
|
| - memory_coordinator::mojom::MemoryCoordinatorHandleRequest request) {
|
| - BrowserMainLoop::GetInstance()->memory_coordinator()->CreateHandle(
|
| - render_process_id, std::move(request));
|
| -}
|
| -
|
| } // namespace
|
|
|
| RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
|
| @@ -476,6 +471,132 @@ RenderProcessHostImpl::GetInProcessRendererThreadForTesting() {
|
| // create.
|
| static size_t g_max_renderer_count_override = 0;
|
|
|
| +class RenderProcessHostImpl::ConnectionFilterImpl : public ConnectionFilter {
|
| + public:
|
| + explicit ConnectionFilterImpl(
|
| + base::WeakPtr<RenderProcessHostImpl> render_process_host)
|
| + : render_process_host_(render_process_host) {}
|
| + ~ConnectionFilterImpl() override {}
|
| +
|
| + private:
|
| + // ConnectionFilter implementation:
|
| + bool OnConnect(shell::Connection* connection,
|
| + shell::Connector* connector) override {
|
| + shell::InterfaceRegistry* reg = connection->GetInterfaceRegistry();
|
| +
|
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner =
|
| + BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
|
| +#if !defined(OS_ANDROID)
|
| + reg->AddInterface(base::Bind(&device::BatteryMonitorImpl::Create),
|
| + ui_task_runner);
|
| +#endif
|
| + reg->AddInterface(base::Bind(&ConnectionFilterImpl::BindPermissionService,
|
| + base::Unretained(this)),
|
| + ui_task_runner);
|
| + reg->AddInterface(base::Bind(&ImageCaptureImpl::Create), ui_task_runner);
|
| + reg->AddInterface(base::Bind(&OffscreenCanvasSurfaceImpl::Create),
|
| + ui_task_runner);
|
| + reg->AddInterface(
|
| + base::Bind(&ConnectionFilterImpl::BindBackgroundSyncService,
|
| + base::Unretained(this)),
|
| + ui_task_runner);
|
| + reg->AddInterface(
|
| + base::Bind(&ConnectionFilterImpl::BindNotificationService,
|
| + base::Unretained(this)),
|
| + ui_task_runner);
|
| + reg->AddInterface(
|
| + base::Bind(&ConnectionFilterImpl::BindStoragePartitionService,
|
| + base::Unretained(this)),
|
| + ui_task_runner);
|
| + reg->AddInterface(
|
| + base::Bind(&ConnectionFilterImpl::BindBroadcastChannelProvider,
|
| + base::Unretained(this)),
|
| + ui_task_runner);
|
| + if (memory_coordinator::IsEnabled()) {
|
| + reg->AddInterface(
|
| + base::Bind(&ConnectionFilterImpl::BindMemoryCoordinatorHandle,
|
| + base::Unretained(this)),
|
| + ui_task_runner);
|
| + }
|
| +
|
| + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner =
|
| + BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE);
|
| + reg->AddInterface(base::Bind(&MimeRegistryImpl::Create), file_task_runner);
|
| +#if defined(USE_MINIKIN_HYPHENATION)
|
| + reg->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create),
|
| + file_task_runner);
|
| +#endif
|
| +
|
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
|
| + BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
|
| + reg->AddInterface(base::Bind(&DeviceLightHost::Create), io_task_runner);
|
| + reg->AddInterface(base::Bind(&DeviceMotionHost::Create), io_task_runner);
|
| + reg->AddInterface(base::Bind(&DeviceOrientationHost::Create),
|
| + io_task_runner);
|
| + reg->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create),
|
| + io_task_runner);
|
| +
|
| + GetContentClient()->browser()->ExposeInterfacesToRenderer(connection);
|
| + return true;
|
| + }
|
| +
|
| + void BindPermissionService(blink::mojom::PermissionServiceRequest request) {
|
| + if (!render_process_host_)
|
| + return;
|
| + PermissionServiceContext* permission_service_context =
|
| + render_process_host_->permission_service_context_.get();
|
| + permission_service_context->CreateService(std::move(request));
|
| + }
|
| +
|
| + void BindBackgroundSyncService(
|
| + blink::mojom::BackgroundSyncServiceRequest request) {
|
| + if (!render_process_host_)
|
| + return;
|
| + render_process_host_->storage_partition_impl_->GetBackgroundSyncContext()->
|
| + CreateService(std::move(request));
|
| + }
|
| +
|
| + void BindNotificationService(
|
| + blink::mojom::NotificationServiceRequest request) {
|
| + if (!render_process_host_)
|
| + return;
|
| + render_process_host_->storage_partition_impl_->
|
| + GetPlatformNotificationContext()->CreateService(
|
| + render_process_host_->GetID(), std::move(request));
|
| + }
|
| +
|
| + void BindStoragePartitionService(
|
| + mojom::StoragePartitionServiceRequest request) {
|
| + if (!render_process_host_)
|
| + return;
|
| + // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW!
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kMojoLocalStorage)) {
|
| + render_process_host_->storage_partition_impl_->Bind(std::move(request));
|
| + }
|
| + }
|
| +
|
| + void BindBroadcastChannelProvider(
|
| + blink::mojom::BroadcastChannelProviderRequest request) {
|
| + if (!render_process_host_)
|
| + return;
|
| + render_process_host_->storage_partition_impl_->
|
| + GetBroadcastChannelProvider()->Connect(std::move(request));
|
| + }
|
| +
|
| + void BindMemoryCoordinatorHandle(
|
| + memory_coordinator::mojom::MemoryCoordinatorHandleRequest request) {
|
| + if (!render_process_host_)
|
| + return;
|
| + BrowserMainLoop::GetInstance()->memory_coordinator()->CreateHandle(
|
| + render_process_host_->GetID(), std::move(request));
|
| + }
|
| +
|
| + base::WeakPtr<RenderProcessHostImpl> render_process_host_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl);
|
| +};
|
| +
|
| // static
|
| size_t RenderProcessHost::GetMaxRendererProcessCount() {
|
| if (g_max_renderer_count_override)
|
| @@ -764,6 +885,14 @@ bool RenderProcessHostImpl::Init() {
|
|
|
| CreateMessageFilters();
|
| RegisterMojoInterfaces();
|
| + MojoShellConnection* connection =
|
| + BrowserContext::GetMojoShellConnectionFor(browser_context_);
|
| + BrowserThread::PostTask(BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&MojoShellConnection::AddConnectionFilter,
|
| + base::Unretained(connection),
|
| + base::Passed(base::WrapUnique(
|
| + new ConnectionFilterImpl(weak_factory_.GetWeakPtr())))));
|
|
|
| if (run_renderer_in_process()) {
|
| DCHECK(g_renderer_main_thread_factory);
|
| @@ -1059,82 +1188,10 @@ void RenderProcessHostImpl::CreateMessageFilters() {
|
| }
|
|
|
| void RenderProcessHostImpl::RegisterMojoInterfaces() {
|
| -#if !defined(OS_ANDROID)
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&device::BatteryMonitorImpl::Create));
|
| -#endif
|
| -
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&PermissionServiceContext::CreateService,
|
| - base::Unretained(permission_service_context_.get())));
|
| -
|
| - // TODO(mcasas): finalize arguments.
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&ImageCaptureImpl::Create));
|
| -
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&OffscreenCanvasSurfaceImpl::Create));
|
| -
|
| - GetInterfaceRegistry()->AddInterface(base::Bind(
|
| - &BackgroundSyncContext::CreateService,
|
| - base::Unretained(storage_partition_impl_->GetBackgroundSyncContext())));
|
| -
|
| - GetInterfaceRegistry()->AddInterface(base::Bind(
|
| - &PlatformNotificationContextImpl::CreateService,
|
| - base::Unretained(
|
| - storage_partition_impl_->GetPlatformNotificationContext()), GetID()));
|
| -
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService,
|
| - base::Unretained(this)));
|
| -
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&BroadcastChannelProvider::Connect,
|
| - base::Unretained(
|
| - storage_partition_impl_->GetBroadcastChannelProvider())));
|
| -
|
| - scoped_refptr<base::SingleThreadTaskRunner> file_task_runner =
|
| - BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE);
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&MimeRegistryImpl::Create), file_task_runner);
|
| -
|
| -#if defined(USE_MINIKIN_HYPHENATION)
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&hyphenation::HyphenationImpl::Create), file_task_runner);
|
| -#endif
|
| -
|
| - scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
|
| - BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
|
| - GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceLightHost::Create),
|
| - io_task_runner);
|
| - GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceMotionHost::Create),
|
| - io_task_runner);
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&DeviceOrientationHost::Create), io_task_runner);
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&DeviceOrientationAbsoluteHost::Create), io_task_runner);
|
| -
|
| - if (memory_coordinator::IsEnabled()) {
|
| - GetInterfaceRegistry()->AddInterface(
|
| - base::Bind(&CreateMemoryCoordinatorHandle, GetID()));
|
| - }
|
| -
|
| #if defined(OS_ANDROID)
|
| ServiceRegistrarAndroid::RegisterProcessHostServices(
|
| mojo_child_connection_->service_registry_android());
|
| #endif
|
| -
|
| - GetContentClient()->browser()->ExposeInterfacesToRenderer(
|
| - GetInterfaceRegistry(), this);
|
| -}
|
| -
|
| -void RenderProcessHostImpl::CreateStoragePartitionService(
|
| - mojo::InterfaceRequest<mojom::StoragePartitionService> request) {
|
| - // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW!
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kMojoLocalStorage)) {
|
| - storage_partition_impl_->Bind(std::move(request));
|
| - }
|
| }
|
|
|
| int RenderProcessHostImpl::GetNextRoutingID() {
|
|
|