Commit f9dd1456 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert ContentIndexService client to use BrowserInterfaceBroker

This change converts ContentIndexService mojom interface client in blink to use
BrowserInterfaceBroker.

Bug: 936482
Change-Id: I341bbb5f57c48d9a5595291a51fc432cd5e351e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1813557
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699313}
parent db509d01
......@@ -6,6 +6,7 @@
#include "build/build_config.h"
#include "content/browser/background_fetch/background_fetch_service_impl.h"
#include "content/browser/content_index/content_index_service_impl.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/image_capture/image_capture_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
......@@ -19,6 +20,7 @@
#include "third_party/blink/public/mojom/appcache/appcache.mojom.h"
#include "third_party/blink/public/mojom/background_fetch/background_fetch.mojom.h"
#include "third_party/blink/public/mojom/bluetooth/web_bluetooth.mojom.h"
#include "third_party/blink/public/mojom/content_index/content_index.mojom.h"
#include "third_party/blink/public/mojom/filesystem/file_system.mojom.h"
#include "third_party/blink/public/mojom/idle/idle_manager.mojom.h"
#include "third_party/blink/public/mojom/locks/lock_manager.mojom.h"
......@@ -83,6 +85,8 @@ void PopulateBinderMapWithContext(
service_manager::BinderMapWithContext<RenderFrameHost*>* map) {
map->Add<blink::mojom::BackgroundFetchService>(
base::BindRepeating(&BackgroundFetchServiceImpl::CreateForFrame));
map->Add<blink::mojom::ContentIndexService>(
base::BindRepeating(&ContentIndexServiceImpl::CreateForFrame));
GetContentClient()->browser()->RegisterBrowserInterfaceBindersForFrame(map);
}
......@@ -185,10 +189,15 @@ void PopulateBinderMapWithContext(
if (ServiceWorkerContext::IsServiceWorkerOnUIEnabled()) {
map->Add<blink::mojom::BackgroundFetchService>(
base::BindRepeating(&BackgroundFetchServiceImpl::CreateForWorker));
map->Add<blink::mojom::ContentIndexService>(
base::BindRepeating(&ContentIndexServiceImpl::CreateForWorker));
} else {
map->Add<blink::mojom::BackgroundFetchService>(
base::BindRepeating(&BackgroundFetchServiceImpl::CreateForWorker),
base::CreateSingleThreadTaskRunner(BrowserThread::UI));
map->Add<blink::mojom::ContentIndexService>(
base::BindRepeating(&ContentIndexServiceImpl::CreateForWorker),
base::CreateSingleThreadTaskRunner(BrowserThread::UI));
}
}
......
......@@ -19,18 +19,40 @@
namespace content {
// static
void ContentIndexServiceImpl::Create(
mojo::PendingReceiver<blink::mojom::ContentIndexService> receiver,
RenderProcessHost* render_process_host,
const url::Origin& origin) {
void ContentIndexServiceImpl::CreateForFrame(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::ContentIndexService> receiver) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
RenderProcessHost* render_process_host = render_frame_host->GetProcess();
DCHECK(render_process_host);
auto* storage_partition = static_cast<StoragePartitionImpl*>(
render_process_host->GetStoragePartition());
mojo::MakeSelfOwnedReceiver(std::make_unique<ContentIndexServiceImpl>(
render_frame_host->GetLastCommittedOrigin(),
storage_partition->GetContentIndexContext()),
std::move(receiver));
}
// static
void ContentIndexServiceImpl::CreateForWorker(
const ServiceWorkerVersionInfo& info,
mojo::PendingReceiver<blink::mojom::ContentIndexService> receiver) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
RenderProcessHost* render_process_host =
RenderProcessHost::FromID(info.process_id);
if (!render_process_host)
return;
auto* storage_partition = static_cast<StoragePartitionImpl*>(
render_process_host->GetStoragePartition());
mojo::MakeSelfOwnedReceiver(
std::make_unique<ContentIndexServiceImpl>(
origin, storage_partition->GetContentIndexContext()),
info.script_origin, storage_partition->GetContentIndexContext()),
std::move(receiver));
}
......
......@@ -15,17 +15,21 @@ class GURL;
namespace content {
class RenderProcessHost;
class RenderFrameHost;
struct ServiceWorkerVersionInfo;
// Lazily constructed by the corresponding renderer when the Content Index API
// is triggered.
class CONTENT_EXPORT ContentIndexServiceImpl
: public blink::mojom::ContentIndexService {
public:
static void Create(
mojo::PendingReceiver<blink::mojom::ContentIndexService> receiver,
RenderProcessHost* render_process_host,
const url::Origin& origin);
static void CreateForFrame(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::ContentIndexService> receiver);
static void CreateForWorker(
const ServiceWorkerVersionInfo& info,
mojo::PendingReceiver<blink::mojom::ContentIndexService> receiver);
ContentIndexServiceImpl(
const url::Origin& origin,
......
......@@ -12,7 +12,6 @@
#include "base/no_destructor.h"
#include "base/task/post_task.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/content_index/content_index_service_impl.h"
#include "content/browser/cookie_store/cookie_store_context.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/native_file_system/native_file_system_manager_impl.h"
......@@ -248,8 +247,6 @@ void RendererInterfaceBinders::InitializeParameterizedBinderRegistry() {
host->GetBrowserContext()->GetVideoDecodePerfHistory()->BindRequest(
std::move(request));
}));
parameterized_binder_registry_.AddInterface(
base::BindRepeating(&ContentIndexServiceImpl::Create));
}
RendererInterfaceBinders& GetRendererInterfaceBinders() {
......
......@@ -199,7 +199,7 @@ const service_manager::Manifest& GetContentBrowserManifest() {
"navigation:service_worker", "renderer",
std::set<const char*>{
"blink.mojom.CacheStorage", "blink.mojom.CookieStore",
"blink.mojom.ContentIndexService", "blink.mojom.IDBFactory",
"blink.mojom.IDBFactory",
"blink.mojom.NativeFileSystemManager",
"blink.mojom.NotificationService",
"blink.mojom.PermissionService",
......@@ -219,7 +219,6 @@ const service_manager::Manifest& GetContentBrowserManifest() {
"blink.mojom.AnchorElementMetricsHost",
"blink.mojom.CacheStorage",
"blink.mojom.ColorChooserFactory",
"blink.mojom.ContentIndexService",
"blink.mojom.DateTimeChooser",
"blink.mojom.DisplayCutoutHost",
"blink.mojom.DedicatedWorkerHostFactory",
......
......@@ -5,7 +5,7 @@
#include "third_party/blink/renderer/modules/content_index/content_index.h"
#include "base/optional.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
......@@ -279,8 +279,10 @@ void ContentIndex::Trace(blink::Visitor* visitor) {
mojom::blink::ContentIndexService* ContentIndex::GetService() {
if (!content_index_service_) {
registration_->GetExecutionContext()->GetInterfaceProvider()->GetInterface(
content_index_service_.BindNewPipeAndPassReceiver(task_runner_));
registration_->GetExecutionContext()
->GetBrowserInterfaceBroker()
.GetInterface(
content_index_service_.BindNewPipeAndPassReceiver(task_runner_));
}
return content_index_service_.get();
}
......
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