Skip to content

Commit

Permalink
Migrate RenderProcessHost, ChildThread to InterfaceRegistry/Provider
Browse files Browse the repository at this point in the history
Extracted from: https://codereview.chromium.org/2096643002/

TBR=rockot@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2099063002
Cr-Commit-Position: refs/heads/master@{#402089}
  • Loading branch information
ben authored and Commit bot committed Jun 26, 2016
1 parent dc39326 commit d1dd50f
Show file tree
Hide file tree
Showing 81 changed files with 378 additions and 319 deletions.
2 changes: 1 addition & 1 deletion android_webview/gpu/aw_content_gpu_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AwContentGpuClient::AwContentGpuClient(

AwContentGpuClient::~AwContentGpuClient() {}

void AwContentGpuClient::RegisterMojoInterfaces(
void AwContentGpuClient::ExposeInterfacesToBrowser(
shell::InterfaceRegistry* registry) {}

gpu::SyncPointManager* AwContentGpuClient::GetSyncPointManager() {
Expand Down
2 changes: 1 addition & 1 deletion android_webview/gpu/aw_content_gpu_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AwContentGpuClient : public content::ContentGpuClient {
~AwContentGpuClient() override;

// content::ContentGpuClient implementation.
void RegisterMojoInterfaces(shell::InterfaceRegistry* registry) override;
void ExposeInterfacesToBrowser(shell::InterfaceRegistry* registry) override;
gpu::SyncPointManager* GetSyncPointManager() override;

private:
Expand Down
1 change: 1 addition & 0 deletions blimp/client/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ if (is_linux && !is_chromeos && use_x11) {
"//blimp/client:compositor",
"//blimp/net",
"//net",
"//services/shell/public/cpp",

# TODO(khushalsagar|scottmg): Remove this dependency from browser to
# blink. See https://crbug.com/608114.
Expand Down
8 changes: 4 additions & 4 deletions blimp/engine/app/blimp_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "blimp/engine/app/blimp_browser_main_parts.h"
#include "blimp/engine/app/settings_manager.h"
#include "blimp/engine/mojo/blob_channel_service.h"
#include "content/public/common/service_registry.h"
#include "services/shell/public/cpp/interface_registry.h"

namespace blimp {
namespace engine {
Expand Down Expand Up @@ -51,10 +51,10 @@ bool BlimpContentBrowserClient::UseNetworkLocationProviders() {
return false;
}

void BlimpContentBrowserClient::RegisterRenderProcessMojoServices(
content::ServiceRegistry* registry,
void BlimpContentBrowserClient::ExposeInterfacesToRenderer(
shell::InterfaceRegistry* registry,
content::RenderProcessHost* render_process_host) {
registry->AddService<mojom::BlobChannel>(
registry->AddInterface<mojom::BlobChannel>(
base::Bind(&BlobChannelService::Create,
blimp_browser_main_parts_->GetBlobChannelSender()));
}
Expand Down
4 changes: 2 additions & 2 deletions blimp/engine/app/blimp_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class BlimpContentBrowserClient : public content::ContentBrowserClient {
const content::MainFunctionParams& parameters) override;
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
content::WebPreferences* prefs) override;
void RegisterRenderProcessMojoServices(
content::ServiceRegistry* registry,
void ExposeInterfacesToRenderer(
shell::InterfaceRegistry* registry,
content::RenderProcessHost* render_process_host) override;

content::LocationProvider* OverrideSystemLocationProvider() override;
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandbox_type.h"
#include "content/public/common/service_registry.h"
#include "content/public/common/url_utils.h"
#include "content/public/common/web_preferences.h"
#include "device/usb/public/interfaces/chooser_service.mojom.h"
Expand Down Expand Up @@ -2728,10 +2727,10 @@ bool ChromeContentBrowserClient::IsWin32kLockdownEnabledForMimeType(
}
#endif // defined(OS_WIN)

void ChromeContentBrowserClient::RegisterRenderProcessMojoServices(
content::ServiceRegistry* registry,
void ChromeContentBrowserClient::ExposeInterfacesToRenderer(
shell::InterfaceRegistry* registry,
content::RenderProcessHost* render_process_host) {
registry->AddService(
registry->AddInterface(
base::Bind(&startup_metric_utils::StartupMetricHostImpl::Create));
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
bool IsWin32kLockdownEnabledForMimeType(
const std::string& mime_type) const override;
#endif
void RegisterRenderProcessMojoServices(
content::ServiceRegistry* registry,
void ExposeInterfacesToRenderer(
shell::InterfaceRegistry* registry,
content::RenderProcessHost* render_process_host) override;
void RegisterFrameMojoShellInterfaces(
shell::InterfaceRegistry* registry,
Expand Down
6 changes: 2 additions & 4 deletions chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@
#include "components/arc/common/video_accelerator.mojom.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_service_registry.h"
#include "content/public/common/service_registry.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
#include "services/shell/public/cpp/interface_provider.h"

namespace {

void ConnectToVideoAcceleratorServiceOnIOThread(
arc::mojom::VideoAcceleratorServiceClientRequest request) {
content::ServiceRegistry* registry = content::GetGpuServiceRegistry();

// Note |request| is not a ServiceRequest. It is a ClientRequest but doesn't
// request for a Client. Instead, it requests for a Service while specified
// the client. It works this odd way because the interfaces were modeled as
// arc's "Host notifies to Instance::Init", not mojo's typical "Client
// registers to Service".
// TODO(kcwu): revise the interface.
registry->ConnectToRemoteService(std::move(request));
content::GetGpuRemoteInterfaces()->GetInterface(std::move(request));
}

} // namespace
Expand Down
6 changes: 2 additions & 4 deletions chrome/browser/image_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/common/service_registry.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_util.h"

Expand Down Expand Up @@ -186,9 +186,7 @@ void ImageDecoder::StartBatchMode() {
delete utility_process_host_.get();
return;
}
content::ServiceRegistry* service_registry =
utility_process_host_->GetServiceRegistry();
service_registry->ConnectToRemoteService(mojo::GetProxy(&decoder_));
utility_process_host_->GetRemoteInterfaces()->GetInterface(&decoder_);
}

void ImageDecoder::StopBatchMode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h"
#include "content/public/common/service_registry.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "ui/base/l10n/l10n_util.h"

namespace {
Expand Down Expand Up @@ -54,10 +54,8 @@ void UtilityProcessMojoProxyResolverFactory::CreateProcessAndConnect() {
IDS_UTILITY_PROCESS_PROXY_RESOLVER_NAME));
bool process_started = utility_process_host->Start();
if (process_started) {
content::ServiceRegistry* service_registry =
utility_process_host->GetServiceRegistry();
service_registry->ConnectToRemoteService(
mojo::GetProxy(&resolver_factory_));
utility_process_host->GetRemoteInterfaces()->GetInterface(
&resolver_factory_);
resolver_factory_.set_connection_error_handler(
base::Bind(&UtilityProcessMojoProxyResolverFactory::OnConnectionError,
base::Unretained(this)));
Expand Down
10 changes: 4 additions & 6 deletions chrome/browser/task_management/providers/child_process_task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/common/process_type.h"
#include "content/public/common/service_registry.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension_set.h"
#include "grit/theme_resources.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"

Expand Down Expand Up @@ -123,11 +123,9 @@ void ConnectResourceReporterOnIOThread(
if (!host)
return;

content::ServiceRegistry* registry = host->GetServiceRegistry();
if (!registry)
return;

registry->ConnectToRemoteService(std::move(resource_reporter));
shell::InterfaceProvider* interfaces = host->GetRemoteInterfaces();
if (interfaces)
interfaces->GetInterface(std::move(resource_reporter));
}

// Creates the Mojo service wrapper that will be used to sample the V8 memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/service_registry.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "ui/base/l10n/l10n_util.h"

namespace task_management {
Expand All @@ -32,10 +32,7 @@ namespace {
ProcessResourceUsage* CreateRendererResourcesSampler(
content::RenderProcessHost* render_process_host) {
mojom::ResourceUsageReporterPtr service;
content::ServiceRegistry* service_registry =
render_process_host->GetServiceRegistry();
if (service_registry)
service_registry->ConnectToRemoteService(mojo::GetProxy(&service));
render_process_host->GetRemoteInterfaces()->GetInterface(&service);
return new ProcessResourceUsage(std::move(service));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/common/service_registry.h"
#include "grit/theme_resources.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
Expand Down Expand Up @@ -96,11 +96,7 @@ void ChildProcessResource::ConnectResourceReporterOnIOThread(
if (!host)
return;

content::ServiceRegistry* registry = host->GetServiceRegistry();
if (!registry)
return;

registry->ConnectToRemoteService(std::move(req));
host->GetRemoteInterfaces()->GetInterface(std::move(req));
}

ChildProcessResource::ChildProcessResource(int process_type,
Expand Down
8 changes: 3 additions & 5 deletions chrome/browser/task_manager/renderer_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "chrome/browser/task_manager/task_manager_util.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/service_registry.h"
#include "services/shell/public/cpp/interface_provider.h"

namespace task_manager {

Expand All @@ -24,10 +24,8 @@ RendererResource::RendererResource(base::ProcessHandle process,
// process reference becomes NULL and the TaskManager still needs it.
unique_process_id_ = render_view_host_->GetProcess()->GetID();
mojom::ResourceUsageReporterPtr service;
content::ServiceRegistry* service_registry =
render_view_host_->GetProcess()->GetServiceRegistry();
if (service_registry)
service_registry->ConnectToRemoteService(mojo::GetProxy(&service));
render_view_host_->GetProcess()->GetRemoteInterfaces()->GetInterface(
&service);
process_resource_usage_.reset(new ProcessResourceUsage(std::move(service)));
}

Expand Down
1 change: 0 additions & 1 deletion chrome/browser/ui/webui/mojo_web_ui_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/common/service_registry.h"
#include "mojo/public/cpp/system/core.h"
#include "services/shell/public/cpp/interface_registry.h"

Expand Down
2 changes: 1 addition & 1 deletion chrome/gpu/chrome_content_gpu_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ChromeContentGpuClient::ChromeContentGpuClient() {}

ChromeContentGpuClient::~ChromeContentGpuClient() {}

void ChromeContentGpuClient::RegisterMojoInterfaces(
void ChromeContentGpuClient::ExposeInterfacesToBrowser(
shell::InterfaceRegistry* registry) {
#if defined(OS_CHROMEOS)
registry->AddInterface(base::Bind(&CreateGpuArcVideoService));
Expand Down
2 changes: 1 addition & 1 deletion chrome/gpu/chrome_content_gpu_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ChromeContentGpuClient : public content::ContentGpuClient {

// content::ContentGpuClient:
void Initialize(base::FieldTrialList::Observer* observer) override;
void RegisterMojoInterfaces(shell::InterfaceRegistry* registry) override;
void ExposeInterfacesToBrowser(shell::InterfaceRegistry* registry) override;

private:
std::unique_ptr<chrome_variations::ChildProcessFieldTrialSyncer>
Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/chrome_content_utility_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ bool ChromeContentUtilityClient::OnMessageReceived(
return false;
}

void ChromeContentUtilityClient::RegisterMojoInterfaces(
void ChromeContentUtilityClient::ExposeInterfacesToBrowser(
shell::InterfaceRegistry* registry) {
// When the utility process is running with elevated privileges, we need to
// filter messages so that only a whitelist of IPCs can run. In Mojo, there's
Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/chrome_content_utility_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient {

void UtilityThreadStarted() override;
bool OnMessageReceived(const IPC::Message& message) override;
void RegisterMojoInterfaces(shell::InterfaceRegistry* registry) override;
void ExposeInterfacesToBrowser(shell::InterfaceRegistry* registry) override;

void AddHandler(std::unique_ptr<UtilityMessageHandler> handler);

Expand Down
1 change: 1 addition & 0 deletions components/web_cache/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ source_set("browser") {
"//components/web_cache/public/interfaces",
"//content/public/browser",
"//content/public/common",
"//services/shell/public/cpp",
"//third_party/WebKit/public:blink_headers",
]
}
Expand Down
3 changes: 2 additions & 1 deletion components/web_cache/browser/DEPS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include_rules = [
"+content/public/browser",
"+content/public",
'+third_party/WebKit/public/web',
"+services/shell/public/cpp",
"+third_party/WebKit/public/web",
]
5 changes: 2 additions & 3 deletions components/web_cache/browser/web_cache_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/service_registry.h"
#include "services/shell/public/cpp/interface_provider.h"

using base::Time;
using base::TimeDelta;
Expand Down Expand Up @@ -94,8 +94,7 @@ void WebCacheManager::Add(int renderer_id) {
content::RenderProcessHost::FromID(renderer_id);
if (host) {
mojom::WebCachePtr service;
host->GetServiceRegistry()->ConnectToRemoteService(
mojo::GetProxy(&service));
host->GetRemoteInterfaces()->GetInterface(&service);
web_cache_services_[renderer_id] = std::move(service);
}

Expand Down
16 changes: 0 additions & 16 deletions content/browser/android/service_registry_android_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ std::unique_ptr<ServiceRegistryAndroid> ServiceRegistryAndroid::Create(
interface_registry, remote_interfaces));
}

// static
std::unique_ptr<ServiceRegistryAndroid> ServiceRegistryAndroid::Create(
ServiceRegistry* service_registry) {
return base::WrapUnique(new ServiceRegistryAndroidImpl(service_registry));
}

// static
bool ServiceRegistryAndroidImpl::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
Expand All @@ -74,16 +68,6 @@ ServiceRegistryAndroidImpl::ServiceRegistryAndroidImpl(
Java_ServiceRegistry_create(env, reinterpret_cast<intptr_t>(this)).obj());
}

ServiceRegistryAndroidImpl::ServiceRegistryAndroidImpl(
ServiceRegistry* service_registry)
: service_registry_(service_registry) {
JNIEnv* env = AttachCurrentThread();
obj_.Reset(
env,
Java_ServiceRegistry_create(env, reinterpret_cast<intptr_t>(this)).obj());
}


const base::android::ScopedJavaGlobalRef<jobject>&
ServiceRegistryAndroidImpl::GetObj() {
return obj_;
Expand Down
1 change: 0 additions & 1 deletion content/browser/android/service_registry_android_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ServiceRegistryAndroidImpl : public ServiceRegistryAndroid {
// Use ServiceRegistryAndroid::Create() to create an instance.
ServiceRegistryAndroidImpl(shell::InterfaceRegistry* interface_registry,
shell::InterfaceProvider* remote_interfaces);
explicit ServiceRegistryAndroidImpl(ServiceRegistry* service_registry);

// ServiceRegistryAndroid implementation:
void AddService(
Expand Down
Loading

0 comments on commit d1dd50f

Please sign in to comment.