diff --git a/android_webview/browser/BUILD.gn b/android_webview/browser/BUILD.gn index f975be465b2fce..643e623bb51b9e 100644 --- a/android_webview/browser/BUILD.gn +++ b/android_webview/browser/BUILD.gn @@ -36,8 +36,6 @@ source_set("browser") { "aw_content_browser_client.h", "aw_content_browser_overlay_manifest.cc", "aw_content_browser_overlay_manifest.h", - "aw_content_renderer_overlay_manifest.cc", - "aw_content_renderer_overlay_manifest.h", "aw_contents.cc", "aw_contents.h", "aw_contents_client_bridge.cc", diff --git a/android_webview/browser/OWNERS b/android_webview/browser/OWNERS index 2a4425c1a6a538..2cb608d3a31685 100644 --- a/android_webview/browser/OWNERS +++ b/android_webview/browser/OWNERS @@ -1,8 +1,4 @@ -per-file aw_content_renderer_overlay_manifest.cc=set noparent -per-file aw_content_renderer_overlay_manifest.cc=file://ipc/SECURITY_OWNERS per-file aw_content_browser_overlay_manifest.h=set noparent per-file aw_content_browser_overlay_manifest.h=file://ipc/SECURITY_OWNERS -per-file aw_content_renderer_overlay_manifest.h=set noparent -per-file aw_content_renderer_overlay_manifest.h=file://ipc/SECURITY_OWNERS per-file aw_content_browser_overlay_manifest.cc=set noparent per-file aw_content_browser_overlay_manifest.cc=file://ipc/SECURITY_OWNERS diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc index ae93f4838991b3..8bd76f83f74fb1 100644 --- a/android_webview/browser/aw_content_browser_client.cc +++ b/android_webview/browser/aw_content_browser_client.cc @@ -12,7 +12,6 @@ #include "android_webview/browser/aw_browser_context.h" #include "android_webview/browser/aw_browser_main_parts.h" #include "android_webview/browser/aw_content_browser_overlay_manifest.h" -#include "android_webview/browser/aw_content_renderer_overlay_manifest.h" #include "android_webview/browser/aw_contents.h" #include "android_webview/browser/aw_contents_client_bridge.h" #include "android_webview/browser/aw_contents_io_thread_client.h" @@ -697,8 +696,6 @@ base::Optional AwContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { if (name == content::mojom::kBrowserServiceName) return GetAWContentBrowserOverlayManifest(); - if (name == content::mojom::kRendererServiceName) - return GetAWContentRendererOverlayManifest(); return base::nullopt; } diff --git a/android_webview/browser/aw_content_renderer_overlay_manifest.cc b/android_webview/browser/aw_content_renderer_overlay_manifest.cc deleted file mode 100644 index c84505318464de..00000000000000 --- a/android_webview/browser/aw_content_renderer_overlay_manifest.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "android_webview/browser/aw_content_renderer_overlay_manifest.h" - -#include "android_webview/common/js_java_interaction/interfaces.mojom.h" -#include "base/no_destructor.h" -#include "components/autofill/content/common/mojom/autofill_agent.mojom.h" -#include "components/safe_browsing/common/safe_browsing.mojom.h" -#include "content/public/common/service_names.mojom.h" -#include "services/service_manager/public/cpp/manifest_builder.h" - -namespace android_webview { - -const service_manager::Manifest& GetAWContentRendererOverlayManifest() { - static base::NoDestructor manifest{ - service_manager::ManifestBuilder() - .ExposeInterfaceFilterCapability_Deprecated( - "navigation:frame", "browser", - service_manager::Manifest::InterfaceList< - autofill::mojom::AutofillAgent, - autofill::mojom::PasswordAutofillAgent, - autofill::mojom::PasswordGenerationAgent, - safe_browsing::mojom::ThreatReporter, - mojom::JsJavaConfigurator, mojom::JsToJavaMessaging>()) - .Build()}; - return *manifest; -} - -} // namespace android_webview diff --git a/android_webview/browser/aw_content_renderer_overlay_manifest.h b/android_webview/browser/aw_content_renderer_overlay_manifest.h deleted file mode 100644 index a4202dc0f3ed85..00000000000000 --- a/android_webview/browser/aw_content_renderer_overlay_manifest.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ANDROID_WEBVIEW_BROWSER_AW_CONTENT_RENDERER_OVERLAY_MANIFEST_H_ -#define ANDROID_WEBVIEW_BROWSER_AW_CONTENT_RENDERER_OVERLAY_MANIFEST_H_ - -#include "services/service_manager/public/cpp/manifest.h" - -namespace android_webview { - -// Returns the manifest Android WebView amends to Content's content_renderer -// service manifest. This allows WebView to extend the capabilities exposed -// and/or required by content_renderer service instances. -const service_manager::Manifest& GetAWContentRendererOverlayManifest(); - -} // namespace android_webview - -#endif // ANDROID_WEBVIEW_BROWSER_AW_CONTENT_RENDERER_OVERLAY_MANIFEST_H_ diff --git a/chrome/app/BUILD.gn b/chrome/app/BUILD.gn index 7498f243ec5266..10676936659354 100644 --- a/chrome/app/BUILD.gn +++ b/chrome/app/BUILD.gn @@ -478,47 +478,6 @@ source_set("chrome_content_browser_overlay_manifest") { } } -source_set("chrome_content_renderer_overlay_manifest") { - sources = [ - "chrome_content_renderer_overlay_manifest.cc", - "chrome_content_renderer_overlay_manifest.h", - ] - - deps = [ - "//base", - "//base/allocator:buildflags", - "//chrome/common:mojo_bindings", - "//chrome/common:search_mojom", - "//components/autofill/content/common/mojom", - "//components/dom_distiller/content/common/mojom", - "//components/metrics/public/mojom:call_stack_mojo_bindings", - "//components/rappor/public/mojom", - "//components/safe_browsing:buildflags", - "//components/safe_browsing/common:interfaces", - "//components/services/heap_profiling/public/mojom", - "//components/subresource_filter/content/mojom", - "//extensions/buildflags", - "//services/service_manager/public/cpp", - "//third_party/blink/public/common", - ] - - if (is_linux) { - deps += [ "//chrome/common/performance_manager/mojom" ] - } - - if (is_chromeos) { - deps += [ "//chromeos/services/network_config/public/mojom" ] - } - - if (is_mac) { - deps += [ "//components/spellcheck/common:interfaces" ] - } - - if (enable_extensions) { - deps += [ "//extensions/common:mojom" ] - } -} - source_set("builtin_service_manifests") { sources = [ "builtin_service_manifests.cc", @@ -545,6 +504,5 @@ source_set("chrome_service_manifests") { public_deps = [ ":builtin_service_manifests", ":chrome_content_browser_overlay_manifest", - ":chrome_content_renderer_overlay_manifest", ] } diff --git a/chrome/app/DEPS b/chrome/app/DEPS index 858bca711c997d..c67af3dcafefe2 100644 --- a/chrome/app/DEPS +++ b/chrome/app/DEPS @@ -67,17 +67,5 @@ specific_include_rules = { "+services/resource_coordinator/public", "+third_party/blink/public/mojom", ], - "chrome_content_renderer_overlay_manifest\.cc": [ - "+base/allocator", - "+chrome/common/performance_manager/mojom", - "+chromeos/services/network_config/public", - "+components/autofill/content/common", - "+components/dom_distiller/content/common", - "+components/spellcheck/common", - "+components/subresource_filter/content/mojom", - "+extensions/buildflags", - "+extensions/common", - "+third_party/blink/public/mojom", - ], } diff --git a/chrome/app/OWNERS b/chrome/app/OWNERS index fbbed7143b9d87..7a0460695e41f0 100644 --- a/chrome/app/OWNERS +++ b/chrome/app/OWNERS @@ -62,7 +62,3 @@ per-file chrome_content_browser_overlay_manifest.cc=set noparent per-file chrome_content_browser_overlay_manifest.cc=file://ipc/SECURITY_OWNERS per-file chrome_content_browser_overlay_manifest.h=set noparent per-file chrome_content_browser_overlay_manifest.h=file://ipc/SECURITY_OWNERS -per-file chrome_content_renderer_overlay_manifest.cc=set noparent -per-file chrome_content_renderer_overlay_manifest.cc=file://ipc/SECURITY_OWNERS -per-file chrome_content_renderer_overlay_manifest.h=set noparent -per-file chrome_content_renderer_overlay_manifest.h=file://ipc/SECURITY_OWNERS diff --git a/chrome/app/chrome_content_renderer_overlay_manifest.cc b/chrome/app/chrome_content_renderer_overlay_manifest.cc deleted file mode 100644 index ec8c42c83f61ca..00000000000000 --- a/chrome/app/chrome_content_renderer_overlay_manifest.cc +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/app/chrome_content_renderer_overlay_manifest.h" - -#include "base/allocator/buildflags.h" -#include "base/no_destructor.h" -#include "build/build_config.h" -#include "chrome/common/chrome_render_frame.mojom.h" -#include "chrome/common/content_settings_agent.mojom.h" -#include "chrome/common/prerender.mojom.h" -#include "chrome/common/search.mojom.h" -#include "components/autofill/content/common/mojom/autofill_agent.mojom.h" -#include "components/dom_distiller/content/common/mojom/distiller_page_notifier_service.mojom.h" -#include "components/safe_browsing/buildflags.h" -#include "components/safe_browsing/common/safe_browsing.mojom.h" -#include "components/subresource_filter/content/mojom/subresource_filter_agent.mojom.h" -#include "extensions/buildflags/buildflags.h" -#include "services/service_manager/public/cpp/manifest_builder.h" -#include "third_party/blink/public/mojom/loader/pause_subresource_loading_handle.mojom.h" -#include "third_party/blink/public/mojom/loader/previews_resource_loading_hints.mojom.h" -#include "third_party/blink/public/mojom/page/display_cutout.mojom.h" - -#if BUILDFLAG(USE_TCMALLOC) -#include "chrome/common/performance_manager/mojom/tcmalloc.mojom.h" // nogncheck -#endif // BUILDFLAG(USE_TCMALLOC) - -#if defined(OS_ANDROID) -#include "chrome/common/sandbox_status_extension_android.mojom.h" -#include "third_party/blink/public/mojom/document_metadata/copyless_paste.mojom.h" -#endif - -#if defined(OS_CHROMEOS) -#include "chromeos/services/network_config/public/mojom/constants.mojom.h" // nogncheck -#endif - -#if defined(OS_MACOSX) -#include "components/spellcheck/common/spellcheck_panel.mojom.h" -#endif - -#if BUILDFLAG(ENABLE_EXTENSIONS) -#include "extensions/common/mojom/app_window.mojom.h" -#include "extensions/common/mojom/guest_view.mojom.h" -#endif - -const service_manager::Manifest& GetChromeContentRendererOverlayManifest() { - static base::NoDestructor manifest { - service_manager::ManifestBuilder() - .ExposeCapability("browser", service_manager::Manifest::InterfaceList< - chrome::mojom::SearchBouncer>()) - .ExposeInterfaceFilterCapability_Deprecated( - "navigation:frame", "browser", - service_manager::Manifest::InterfaceList< -#if defined(OS_ANDROID) - blink::mojom::document_metadata::CopylessPaste, - chrome::mojom::SandboxStatusExtension, -#endif - autofill::mojom::AutofillAgent, - autofill::mojom::PasswordAutofillAgent, - autofill::mojom::PasswordGenerationAgent, - blink::mojom::DisplayCutoutClient, - blink::mojom::PauseSubresourceLoadingHandle, - blink::mojom::PreviewsResourceLoadingHintsReceiver, - chrome::mojom::ChromeRenderFrame, - chrome::mojom::ContentSettingsAgent, - chrome::mojom::PrerenderDispatcher, - dom_distiller::mojom::DistillerPageNotifierService, -#if BUILDFLAG(ENABLE_EXTENSIONS) - extensions::mojom::AppWindow, - extensions::mojom::MimeHandlerViewContainerManager, -#endif // TODO: need gated include back - safe_browsing::mojom::ThreatReporter, -#if BUILDFLAG(FULL_SAFE_BROWSING) - safe_browsing::mojom::PhishingDetector, -#endif -#if defined(OS_MACOSX) - spellcheck::mojom::SpellCheckPanel, -#endif -#if defined(OS_LINUX) -#if BUILDFLAG(USE_TCMALLOC) - tcmalloc::mojom::TcmallocTunables, -#endif // BUILDFLAG(USE_TCMALLOC) -#endif // defined(OS_LINUX) - subresource_filter::mojom::SubresourceFilterAgent>()) -#if defined(OS_CHROMEOS) - .RequireInterfaceFilterCapability_Deprecated( - "content_browser", "navigation:frame", "cellular_setup") - .RequireInterfaceFilterCapability_Deprecated( - "content_browser", "navigation:frame", "multidevice_setup") - .RequireInterfaceFilterCapability_Deprecated( - "content_browser", "navigation:frame", - chromeos::network_config::mojom::kNetworkConfigCapability) -#endif - .Build() - }; - return *manifest; -} diff --git a/chrome/app/chrome_content_renderer_overlay_manifest.h b/chrome/app/chrome_content_renderer_overlay_manifest.h deleted file mode 100644 index 76d771cc6ed851..00000000000000 --- a/chrome/app/chrome_content_renderer_overlay_manifest.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_APP_CHROME_CONTENT_RENDERER_OVERLAY_MANIFEST_H_ -#define CHROME_APP_CHROME_CONTENT_RENDERER_OVERLAY_MANIFEST_H_ - -#include "services/service_manager/public/cpp/manifest.h" - -// Returns the Manifest Chrome amends to Content's content_renderer service -// manifest. This allows Chrome to extend the set of capabilities exposed and/or -// required by content_renderer service instances. -const service_manager::Manifest& GetChromeContentRendererOverlayManifest(); - -#endif // CHROME_APP_CHROME_CONTENT_RENDERER_OVERLAY_MANIFEST_H_ diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index df7b271d4f1af8..df05de74dd7e3d 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -36,7 +36,6 @@ #include "build/build_config.h" #include "chrome/app/builtin_service_manifests.h" #include "chrome/app/chrome_content_browser_overlay_manifest.h" -#include "chrome/app/chrome_content_renderer_overlay_manifest.h" #include "chrome/browser/accessibility/accessibility_labels_service.h" #include "chrome/browser/accessibility/accessibility_labels_service_factory.h" #include "chrome/browser/after_startup_task_utils.h" @@ -3706,8 +3705,6 @@ base::Optional ChromeContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { if (name == content::mojom::kBrowserServiceName) return GetChromeContentBrowserOverlayManifest(); - if (name == content::mojom::kRendererServiceName) - return GetChromeContentRendererOverlayManifest(); return base::nullopt; } diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc index 760fbcc69b4459..23f6b308966ff5 100644 --- a/chromecast/browser/cast_content_browser_client.cc +++ b/chromecast/browser/cast_content_browser_client.cc @@ -654,8 +654,6 @@ CastContentBrowserClient::GetServiceManifestOverlay( base::StringPiece service_name) { if (service_name == content::mojom::kBrowserServiceName) return GetCastContentBrowserOverlayManifest(); - if (service_name == content::mojom::kRendererServiceName) - return GetCastContentRendererOverlayManifest(); return base::nullopt; } diff --git a/chromecast/browser/cast_overlay_manifests.cc b/chromecast/browser/cast_overlay_manifests.cc index 0bd758d1792995..acc376f52edae3 100644 --- a/chromecast/browser/cast_overlay_manifests.cc +++ b/chromecast/browser/cast_overlay_manifests.cc @@ -8,11 +8,8 @@ #include "build/build_config.h" #include "chromecast/chromecast_buildflags.h" #include "chromecast/common/mojom/application_media_capabilities.mojom.h" -#include "chromecast/common/mojom/feature_manager.mojom.h" #include "chromecast/common/mojom/media_caps.mojom.h" -#include "chromecast/common/mojom/media_playback_options.mojom.h" #include "chromecast/common/mojom/memory_pressure.mojom.h" -#include "chromecast/common/mojom/queryable_data_store.mojom.h" #include "media/mojo/services/media_manifest.h" #include "services/service_manager/public/cpp/manifest_builder.h" @@ -23,7 +20,6 @@ #if defined(USE_INTERNAL_OVERLAY_MANIFESTS) #include "chromecast/internal/shell/browser/cast_content_browser_internal_manifest_overlay.h" #include "chromecast/internal/shell/browser/cast_content_packaged_services_internal_manifest_overlay.h" -#include "chromecast/internal/shell/browser/cast_content_renderer_internal_manifest_overlay.h" #endif namespace chromecast { @@ -48,22 +44,6 @@ const service_manager::Manifest& GetCastContentBrowserOverlayManifest() { return *manifest; } -const service_manager::Manifest& GetCastContentRendererOverlayManifest() { - static base::NoDestructor manifest { - service_manager::ManifestBuilder() - .ExposeInterfaceFilterCapability_Deprecated( - "navigation:frame", "browser", - service_manager::Manifest::InterfaceList< - mojom::FeatureManager, mojom::MediaPlaybackOptions, - mojom::QueryableDataStore>()) - .Build() -#if defined(USE_INTERNAL_OVERLAY_MANIFESTS) - .Amend(cast_content_renderer_internal_manifest_overlay::GetManifest()) -#endif - }; - return *manifest; -} - const service_manager::Manifest& GetCastContentPackagedServicesOverlayManifest() { static base::NoDestructor manifest { diff --git a/chromecast/browser/cast_overlay_manifests.h b/chromecast/browser/cast_overlay_manifests.h index add22a40cc6748..8bd5376f6022de 100644 --- a/chromecast/browser/cast_overlay_manifests.h +++ b/chromecast/browser/cast_overlay_manifests.h @@ -15,11 +15,6 @@ namespace shell { // required by content_browser service instances. const service_manager::Manifest& GetCastContentBrowserOverlayManifest(); -// Returns the manifest Cast amends to Content's content_renderer service -// manifest. This allows Cast to extend the capabilities exposed and/or -// required by content_renderer service instances. -const service_manager::Manifest& GetCastContentRendererOverlayManifest(); - // Returns the manifest Cast amends to Content's content_packaged_services // service manifest. This allows Cast to extend the set of in- and out-of- // process services packaged by the browser. diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index e268ff0a1ff118..95f4b920f9c75b 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn @@ -103,6 +103,7 @@ jumbo_source_set("browser") { "//content/common:mojo_bindings", "//content/public/app:service_manifests", "//content/public/common:common_sources", + "//content/public/common:content_descriptor_keys", "//crypto", "//device/base", "//device/bluetooth", @@ -1809,6 +1810,8 @@ jumbo_source_set("browser") { "utility_process_host.cc", "utility_process_host.h", "utility_process_host_receiver_bindings.cc", + "v8_snapshot_files.cc", + "v8_snapshot_files.h", "video_capture_service.cc", "wake_lock/wake_lock_context_host.cc", "wake_lock/wake_lock_context_host.h", diff --git a/content/browser/browser_child_process_host_impl.cc b/content/browser/browser_child_process_host_impl.cc index 7e4b89029ef5a4..363d0fc0def3ce 100644 --- a/content/browser/browser_child_process_host_impl.cc +++ b/content/browser/browser_child_process_host_impl.cc @@ -276,10 +276,20 @@ void BrowserChildProcessHostImpl::Launch( std::unique_ptr delegate, std::unique_ptr cmd_line, bool terminate_on_shutdown) { + LaunchWithPreloadedFiles(std::move(delegate), std::move(cmd_line), + /*files_to_preload=*/{}, terminate_on_shutdown); +} + +void BrowserChildProcessHostImpl::LaunchWithPreloadedFiles( + std::unique_ptr delegate, + std::unique_ptr cmd_line, + std::map files_to_preload, + bool terminate_on_shutdown) { GetContentClient()->browser()->AppendExtraCommandLineSwitches(cmd_line.get(), data_.id); LaunchWithoutExtraCommandLineSwitches( - std::move(delegate), std::move(cmd_line), terminate_on_shutdown); + std::move(delegate), std::move(cmd_line), std::move(files_to_preload), + terminate_on_shutdown); } const ChildProcessData& BrowserChildProcessHostImpl::GetData() { @@ -344,6 +354,7 @@ void BrowserChildProcessHostImpl::AddFilter(BrowserMessageFilter* filter) { void BrowserChildProcessHostImpl::LaunchWithoutExtraCommandLineSwitches( std::unique_ptr delegate, std::unique_ptr cmd_line, + std::map files_to_preload, bool terminate_on_shutdown) { DCHECK_CURRENTLY_ON(BrowserThread::IO); const base::CommandLine& browser_command_line = @@ -393,7 +404,7 @@ void BrowserChildProcessHostImpl::LaunchWithoutExtraCommandLineSwitches( base::BindRepeating(&BrowserChildProcessHostImpl::OnMojoError, weak_factory_.GetWeakPtr(), base::ThreadTaskRunnerHandle::Get()), - terminate_on_shutdown)); + std::move(files_to_preload), terminate_on_shutdown)); ShareMetricsAllocatorToProcess(); } diff --git a/content/browser/browser_child_process_host_impl.h b/content/browser/browser_child_process_host_impl.h index a3f11798f99421..f1f034bbe27ac1 100644 --- a/content/browser/browser_child_process_host_impl.h +++ b/content/browser/browser_child_process_host_impl.h @@ -88,6 +88,11 @@ class CONTENT_EXPORT BrowserChildProcessHostImpl void Launch(std::unique_ptr delegate, std::unique_ptr cmd_line, bool terminate_on_shutdown) override; + void LaunchWithPreloadedFiles( + std::unique_ptr delegate, + std::unique_ptr cmd_line, + std::map files_to_preload, + bool terminate_on_shutdown) override; const ChildProcessData& GetData() override; ChildProcessHost* GetHost() override; ChildProcessTerminationInfo GetTerminationInfo(bool known_dead) override; @@ -127,6 +132,7 @@ class CONTENT_EXPORT BrowserChildProcessHostImpl void LaunchWithoutExtraCommandLineSwitches( std::unique_ptr delegate, std::unique_ptr cmd_line, + std::map files_to_preload, bool terminate_on_shutdown); static void HistogramBadMessageTerminated(ProcessType process_type); diff --git a/content/browser/builtin_service_manifests.cc b/content/browser/builtin_service_manifests.cc index 075d46a6c62418..854eabdb88d0e5 100644 --- a/content/browser/builtin_service_manifests.cc +++ b/content/browser/builtin_service_manifests.cc @@ -8,7 +8,6 @@ #include "base/no_destructor.h" #include "build/build_config.h" #include "content/public/app/content_browser_manifest.h" -#include "content/public/app/content_renderer_manifest.h" #include "content/public/app/content_utility_manifest.h" #include "content/public/browser/content_browser_client.h" #include "content/public/common/content_client.h" @@ -43,7 +42,6 @@ const std::vector& GetBuiltinServiceManifests() { // browser process, but the distinction between "in-process" and // "out-of-process" manifests is temporary. For now, this is the right // place for these manifests. - GetContentRendererManifest(), GetContentUtilityManifest(), audio::GetManifest(IsAudioServiceOutOfProcess() diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 1d9e3e34ff3c55..757a82d1cdbfe0 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -36,6 +36,7 @@ ChildProcessLauncher::ChildProcessLauncher( Client* client, mojo::OutgoingInvitation mojo_invitation, const mojo::ProcessErrorCallback& process_error_callback, + std::map files_to_preload, bool terminate_on_shutdown) : client_(client), starting_(true), @@ -56,7 +57,8 @@ ChildProcessLauncher::ChildProcessLauncher( #if defined(OS_ANDROID) client_->CanUseWarmUpConnection(), #endif - std::move(mojo_invitation), process_error_callback); + std::move(mojo_invitation), process_error_callback, + std::move(files_to_preload)); helper_->StartLaunchOnClientThread(); } @@ -156,19 +158,6 @@ bool ChildProcessLauncher::TerminateProcess(const base::Process& process, return ChildProcessLauncherHelper::TerminateProcess(process, exit_code); } -// static -void ChildProcessLauncher::SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files) { - ChildProcessLauncherHelper::SetRegisteredFilesForService( - service_name, std::move(required_files)); -} - -// static -void ChildProcessLauncher::ResetRegisteredFilesForTesting() { - ChildProcessLauncherHelper::ResetRegisteredFilesForTesting(); -} - #if defined(OS_ANDROID) void ChildProcessLauncher::DumpProcessStack() { base::Process to_pass = process_.process.Duplicate(); diff --git a/content/browser/child_process_launcher.h b/content/browser/child_process_launcher.h index e7cf0258ccc446..05364ef4eacd73 100644 --- a/content/browser/child_process_launcher.h +++ b/content/browser/child_process_launcher.h @@ -164,6 +164,12 @@ class CONTENT_EXPORT ChildProcessLauncher { // If |process_error_callback| is provided, it will be called if a Mojo error // is encountered when processing messages from the child process. This // callback must be safe to call from any thread. + // + // |files_to_preload| is a map of key names to file paths. These files will be + // opened by the browser process and corresponding file descriptors inherited + // by the new child process, accessible using the corresponding key via some + // platform-specific mechanism (such as base::FileDescriptorStore on POSIX). + // Currently only supported on POSIX platforms. ChildProcessLauncher( std::unique_ptr delegate, std::unique_ptr cmd_line, @@ -171,6 +177,7 @@ class CONTENT_EXPORT ChildProcessLauncher { Client* client, mojo::OutgoingInvitation mojo_invitation, const mojo::ProcessErrorCallback& process_error_callback, + std::map files_to_preload, bool terminate_on_shutdown = true); ~ChildProcessLauncher(); @@ -209,16 +216,6 @@ class CONTENT_EXPORT ChildProcessLauncher { // previous client. Client* ReplaceClientForTest(Client* client); - // Sets the files that should be mapped when a new child process is created - // for the service |service_name|. - static void SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files); - - // Resets all files registered by |SetRegisteredFilesForService|. Used to - // support multiple shell context creation in unit_tests. - static void ResetRegisteredFilesForTesting(); - #if defined(OS_ANDROID) // Dumps the stack of the child process without crashing it. void DumpProcessStack(); diff --git a/content/browser/child_process_launcher_helper.cc b/content/browser/child_process_launcher_helper.cc index ae110462c96106..affe55785fb91b 100644 --- a/content/browser/child_process_launcher_helper.cc +++ b/content/browser/child_process_launcher_helper.cc @@ -75,7 +75,8 @@ ChildProcessLauncherHelper::ChildProcessLauncherHelper( bool can_use_warm_up_connection, #endif mojo::OutgoingInvitation mojo_invitation, - const mojo::ProcessErrorCallback& process_error_callback) + const mojo::ProcessErrorCallback& process_error_callback, + std::map files_to_preload) : child_process_id_(child_process_id), client_task_runner_(base::SequencedTaskRunnerHandle::Get()), command_line_(std::move(command_line)), @@ -83,7 +84,8 @@ ChildProcessLauncherHelper::ChildProcessLauncherHelper( child_process_launcher_(child_process_launcher), terminate_on_shutdown_(terminate_on_shutdown), mojo_invitation_(std::move(mojo_invitation)), - process_error_callback_(process_error_callback) + process_error_callback_(process_error_callback), + files_to_preload_(std::move(files_to_preload)) #if defined(OS_ANDROID) , can_use_warm_up_connection_(can_use_warm_up_connection) diff --git a/content/browser/child_process_launcher_helper.h b/content/browser/child_process_launcher_helper.h index 9a7ca166f56529..791efe5344afca 100644 --- a/content/browser/child_process_launcher_helper.h +++ b/content/browser/child_process_launcher_helper.h @@ -102,7 +102,8 @@ class ChildProcessLauncherHelper : bool is_pre_warmup_required, #endif mojo::OutgoingInvitation mojo_invitation, - const mojo::ProcessErrorCallback& process_error_callback); + const mojo::ProcessErrorCallback& process_error_callback, + std::map files_to_preload); // The methods below are defined in the order they are called. @@ -183,12 +184,6 @@ class ChildProcessLauncherHelper : base::Process process, const ChildProcessLauncherPriority& priority); - static void SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files); - - static void ResetRegisteredFilesForTesting(); - #if defined(OS_ANDROID) void OnChildProcessStarted(JNIEnv* env, jint handle); @@ -241,6 +236,7 @@ class ChildProcessLauncherHelper : bool terminate_on_shutdown_; mojo::OutgoingInvitation mojo_invitation_; const mojo::ProcessErrorCallback process_error_callback_; + const std::map files_to_preload_; #if defined(OS_MACOSX) std::unique_ptr seatbelt_exec_client_; diff --git a/content/browser/child_process_launcher_helper_android.cc b/content/browser/child_process_launcher_helper_android.cc index fd90d21bdf9634..37343252cc2923 100644 --- a/content/browser/child_process_launcher_helper_android.cc +++ b/content/browser/child_process_launcher_helper_android.cc @@ -74,10 +74,9 @@ ChildProcessLauncherHelper::GetFilesToMap() { CHECK(!command_line()->HasSwitch(switches::kSingleProcess)); std::unique_ptr files_to_register = - CreateDefaultPosixFilesToMap(child_process_id(), - mojo_channel_->remote_endpoint(), - true /* include_service_required_files */, - GetProcessType(), command_line()); + CreateDefaultPosixFilesToMap( + child_process_id(), mojo_channel_->remote_endpoint(), + files_to_preload_, GetProcessType(), command_line()); #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE base::MemoryMappedFile::Region icu_region; @@ -242,18 +241,6 @@ void ChildProcessLauncherHelper::SetProcessPriorityOnLauncherThread( priority.boost_for_pending_views, static_cast(priority.importance)); } -// static -void ChildProcessLauncherHelper::SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files) { - SetFilesToShareForServicePosix(service_name, std::move(required_files)); -} - -// static -void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() { - ResetFilesToShareForTestingPosix(); -} - // static base::File OpenFileToShare(const base::FilePath& path, base::MemoryMappedFile::Region* region) { diff --git a/content/browser/child_process_launcher_helper_fuchsia.cc b/content/browser/child_process_launcher_helper_fuchsia.cc index 204ff17a125c33..80257a9e9bd288 100644 --- a/content/browser/child_process_launcher_helper_fuchsia.cc +++ b/content/browser/child_process_launcher_helper_fuchsia.cc @@ -63,17 +63,6 @@ bool ChildProcessLauncherHelper::TerminateProcess(const base::Process& process, return process.Terminate(exit_code, false); } -// static -void ChildProcessLauncherHelper::SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files) { - NOTREACHED() << " for service " << service_name; -} - -// static -void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() { -} - void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { DCHECK(client_task_runner_->RunsTasksInCurrentSequence()); diff --git a/content/browser/child_process_launcher_helper_linux.cc b/content/browser/child_process_launcher_helper_linux.cc index 720b92a1a3a7ab..ea5258a03f83bc 100644 --- a/content/browser/child_process_launcher_helper_linux.cc +++ b/content/browser/child_process_launcher_helper_linux.cc @@ -37,10 +37,9 @@ void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { std::unique_ptr ChildProcessLauncherHelper::GetFilesToMap() { DCHECK(CurrentlyOnProcessLauncherTaskRunner()); - return CreateDefaultPosixFilesToMap(child_process_id(), - mojo_channel_->remote_endpoint(), - true /* include_service_required_files */, - GetProcessType(), command_line()); + return CreateDefaultPosixFilesToMap( + child_process_id(), mojo_channel_->remote_endpoint(), files_to_preload_, + GetProcessType(), command_line()); } bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( @@ -161,18 +160,6 @@ void ChildProcessLauncherHelper::SetProcessPriorityOnLauncherThread( process.SetProcessBackgrounded(priority.is_background()); } -// static -void ChildProcessLauncherHelper::SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files) { - SetFilesToShareForServicePosix(service_name, std::move(required_files)); -} - -// static -void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() { - ResetFilesToShareForTestingPosix(); -} - // static base::File OpenFileToShare(const base::FilePath& path, base::MemoryMappedFile::Region* region) { diff --git a/content/browser/child_process_launcher_helper_mac.cc b/content/browser/child_process_launcher_helper_mac.cc index a5dd42652dacd8..921e015ef01d8b 100644 --- a/content/browser/child_process_launcher_helper_mac.cc +++ b/content/browser/child_process_launcher_helper_mac.cc @@ -46,8 +46,7 @@ ChildProcessLauncherHelper::GetFilesToMap() { DCHECK(CurrentlyOnProcessLauncherTaskRunner()); return CreateDefaultPosixFilesToMap( child_process_id(), mojo_channel_->remote_endpoint(), - false /* include_service_required_files */, GetProcessType(), - command_line()); + /*files_to_preload=*/{}, GetProcessType(), command_line()); } bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( @@ -174,17 +173,6 @@ void ChildProcessLauncherHelper::SetProcessPriorityOnLauncherThread( } } -// static -void ChildProcessLauncherHelper::SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files) { - // No file passing from the manifest on Mac yet. - DCHECK(required_files.empty()); -} - -// static -void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() {} - // static base::File OpenFileToShare(const base::FilePath& path, base::MemoryMappedFile::Region* region) { diff --git a/content/browser/child_process_launcher_helper_posix.cc b/content/browser/child_process_launcher_helper_posix.cc index d52a5082cfad66..755c87dd43e947 100644 --- a/content/browser/child_process_launcher_helper_posix.cc +++ b/content/browser/child_process_launcher_helper_posix.cc @@ -24,30 +24,6 @@ namespace internal { namespace { -using RequiredFilesByServiceMap = - std::map>; - -RequiredFilesByServiceMap& GetRequiredFilesByServiceMap() { - static auto* required_files_by_service = new RequiredFilesByServiceMap(); - return *required_files_by_service; -} - -std::map& GetServiceNameByProcessTypeMap() { - static auto* service_name_resolver = new std::map( - {// The service names are defined in the JSON manifests, so we don't have - // a constant accessible for them. - // TODO(jcivelli): remove this map once the service name is accessible - // from the command line crbug.com/687250 - {switches::kGpuProcess, "content_gpu"}, - {switches::kPpapiPluginProcess, "content_plugin"}, - {switches::kRendererProcess, "content_renderer"}, - {switches::kUtilityProcess, "content_utility"}, - {"ppapi-broker", "ppapi_broker"}, - {"nacl-loader", "nacl_loader"}, - {"nacl-loader-nonsfi", "nacl_loader_nonsfi"}}); - return *service_name_resolver; -} - base::PlatformFile OpenFileIfNecessary(const base::FilePath& path, base::MemoryMappedFile::Region* region) { static auto* opened_files = new std::map< @@ -74,7 +50,7 @@ base::PlatformFile OpenFileIfNecessary(const base::FilePath& path, std::unique_ptr CreateDefaultPosixFilesToMap( int child_process_id, const mojo::PlatformChannelEndpoint& mojo_channel_remote_endpoint, - bool include_service_required_files, + std::map files_to_preload, const std::string& process_type, base::CommandLine* command_line) { std::unique_ptr files_to_register( @@ -97,60 +73,27 @@ std::unique_ptr CreateDefaultPosixFilesToMap( *command_line, child_process_id, files_to_register.get()); #endif - if (!include_service_required_files) - return files_to_register; - - // Also include the files specified in the services' manifests. - auto service_name_iter = GetServiceNameByProcessTypeMap().find(process_type); - DCHECK(service_name_iter != GetServiceNameByProcessTypeMap().end()) - << "No service found for process type " << process_type; - const std::string& service_name = service_name_iter->second; - auto files_iter = GetRequiredFilesByServiceMap().find(service_name); - if (files_iter != GetRequiredFilesByServiceMap().end()) { - const std::map& required_files_map = - files_iter->second; - base::GlobalDescriptors::Key key = kContentDynamicDescriptorStart; - service_manager::SharedFileSwitchValueBuilder file_switch_value_builder; - for (const auto& key_path_iter : required_files_map) { - base::MemoryMappedFile::Region region; - base::PlatformFile file = - OpenFileIfNecessary(key_path_iter.second, ®ion); - if (file == base::kInvalidPlatformFile) { - DLOG(WARNING) << "Ignoring invalid file " - << key_path_iter.second.value(); - continue; - } - file_switch_value_builder.AddEntry(key_path_iter.first, key); - files_to_register->ShareWithRegion(key, file, region); - key++; - DCHECK(key < kContentDynamicDescriptorMax); + // Also include the files specified explicitly by |files_to_preload|. + base::GlobalDescriptors::Key key = kContentDynamicDescriptorStart; + service_manager::SharedFileSwitchValueBuilder file_switch_value_builder; + for (const auto& key_path_iter : files_to_preload) { + base::MemoryMappedFile::Region region; + base::PlatformFile file = + OpenFileIfNecessary(key_path_iter.second, ®ion); + if (file == base::kInvalidPlatformFile) { + DLOG(WARNING) << "Ignoring invalid file " << key_path_iter.second.value(); + continue; } - command_line->AppendSwitchASCII(service_manager::switches::kSharedFiles, - file_switch_value_builder.switch_value()); + file_switch_value_builder.AddEntry(key_path_iter.first, key); + files_to_register->ShareWithRegion(key, file, region); + key++; + DCHECK(key < kContentDynamicDescriptorMax); } + command_line->AppendSwitchASCII(service_manager::switches::kSharedFiles, + file_switch_value_builder.switch_value()); return files_to_register; } -void SetFilesToShareForServicePosix( - const std::string& service_name, - std::map required_files) { - if (required_files.empty()) - return; - - if (!base::StartsWith(service_name, "content_", - base::CompareCase::INSENSITIVE_ASCII)) { - // Not a content child service, ignore. - return; - } - - DCHECK(GetRequiredFilesByServiceMap().count(service_name) == 0); - GetRequiredFilesByServiceMap()[service_name] = std::move(required_files); -} - -void ResetFilesToShareForTestingPosix() { - GetRequiredFilesByServiceMap().clear(); -} - } // namespace internal } // namespace content diff --git a/content/browser/child_process_launcher_helper_posix.h b/content/browser/child_process_launcher_helper_posix.h index 9622650d3de208..de5771a4832591 100644 --- a/content/browser/child_process_launcher_helper_posix.h +++ b/content/browser/child_process_launcher_helper_posix.h @@ -32,19 +32,10 @@ namespace internal { std::unique_ptr CreateDefaultPosixFilesToMap( int child_process_id, const mojo::PlatformChannelEndpoint& mojo_channel_remote_endpoint, - bool include_service_required_files, + std::map files_to_preload, const std::string& process_type, base::CommandLine* command_line); -// Called by the service manager to register the files that should be mapped for -// a service in the child process. -void SetFilesToShareForServicePosix( - const std::string& service_name, - std::map required_files); - -// Called from unit_tests in order to reset all previously registered files. -void ResetFilesToShareForTestingPosix(); - // Opens the file in read mode at the given path. Note that the path should be // relative and the way it is resolved is platform specific. // |region| is set to the region of the file that should be read. diff --git a/content/browser/child_process_launcher_helper_win.cc b/content/browser/child_process_launcher_helper_win.cc index c27d2056fdbb24..695ae7247c3df3 100644 --- a/content/browser/child_process_launcher_helper_win.cc +++ b/content/browser/child_process_launcher_helper_win.cc @@ -118,16 +118,5 @@ void ChildProcessLauncherHelper::SetProcessPriorityOnLauncherThread( process.SetProcessBackgrounded(priority.is_background()); } -// static -void ChildProcessLauncherHelper::SetRegisteredFilesForService( - const std::string& service_name, - std::map required_files) { - // No file passing from the manifest on Windows yet. - DCHECK(required_files.empty()); -} - -// static -void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() {} - } // namespace internal } // namespace content diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index 18d7fb173cd12e..b62500a0ae422b 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -1116,8 +1116,8 @@ bool GpuProcessHost::LaunchGpuProcess() { // AppendExtraCommandLineSwitches will be called again in process_->Launch(), // Call LaunchWithoutExtraCommandLineSwitches() so the command line switches // will not be appended twice. - process_->LaunchWithoutExtraCommandLineSwitches(std::move(delegate), - std::move(cmd_line), true); + process_->LaunchWithoutExtraCommandLineSwitches( + std::move(delegate), std::move(cmd_line), /*files_to_preload=*/{}, true); process_launched_ = true; if (kind_ == GPU_PROCESS_KIND_SANDBOXED) { diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 549387a2306f0b..08403ac3b857d7 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -137,6 +137,7 @@ #include "content/browser/storage_partition_impl.h" #include "content/browser/theme_helper.h" #include "content/browser/tracing/background_tracing_manager_impl.h" +#include "content/browser/v8_snapshot_files.h" #include "content/browser/webui/web_ui_controller_factory_registry.h" #include "content/common/child_process.mojom.h" #include "content/common/child_process_host_impl.h" @@ -144,7 +145,6 @@ #include "content/common/frame_messages.h" #include "content/common/in_process_child_thread_params.h" #include "content/common/resource_messages.h" -#include "content/common/service_manager/child_connection.h" #include "content/common/service_manager/service_manager_connection_impl.h" #include "content/common/service_worker/service_worker_utils.h" #include "content/common/view_messages.h" @@ -1671,7 +1671,7 @@ bool RenderProcessHostImpl::Init() { in_process_renderer_.reset(g_renderer_main_thread_factory( InProcessChildThreadParams( base::CreateSingleThreadTaskRunner({BrowserThread::IO}), - &mojo_invitation_, child_connection_->service_token()), + &mojo_invitation_), base::checked_cast(id_))); base::Thread::Options options; @@ -1711,7 +1711,8 @@ bool RenderProcessHostImpl::Init() { child_process_launcher_ = std::make_unique( std::make_unique(), std::move(cmd_line), GetID(), this, std::move(mojo_invitation_), - base::BindRepeating(&RenderProcessHostImpl::OnMojoError, id_)); + base::BindRepeating(&RenderProcessHostImpl::OnMojoError, id_), + GetV8SnapshotFilesToPreload()); channel_->Pause(); // In single process mode, browser-side tracing and memory will cover the @@ -1739,50 +1740,23 @@ void RenderProcessHostImpl::InitializeChannelProxy() { scoped_refptr io_task_runner = base::CreateSingleThreadTaskRunner({BrowserThread::IO}); - // Acquire a Connector which will route connections to a new instance of the - // renderer service. - service_manager::Connector* connector = - BrowserContext::GetConnectorFor(browser_context_); - if (!connector) { - // Note that some embedders (e.g. Android WebView) may not initialize a - // Connector per BrowserContext. In those cases we fall back to the - // browser-wide Connector. - connector = GetSystemConnector(); - if (!connector && !ServiceManagerConnection::GetForProcess()) { - // Additionally, some test code may not initialize the system Connector. - // We initialize one that the ChildConnection below can use. - // TODO(crbug.com/904240): Figure out why some unit tests fail when this - // doesn't create a full ServiceManagerConnection. - service_manager::mojom::ServicePtr unused_service; - ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( - mojo::MakeRequest(&unused_service), io_task_runner)); - connector = ServiceManagerConnection::GetForProcess()->GetConnector(); - } - } - - // Establish a ServiceManager connection for the new render service instance. + // Establish a ChildProcess interface connection to the new renderer. This is + // connected as the primordial message pipe via a Mojo invitation to the + // process. mojo_invitation_ = {}; - child_connection_ = std::make_unique( - service_manager::Identity( - mojom::kRendererServiceName, - BrowserContext::GetServiceInstanceGroupFor(GetBrowserContext()), - base::Token::CreateRandom(), base::Token::CreateRandom()), - &mojo_invitation_, connector, io_task_runner); - - // Send an interface request to bootstrap the IPC::Channel. Note that this - // request will happily sit on the pipe until the process is launched and - // connected to the ServiceManager. We take the other end immediately and - // plug it into a new ChannelProxy. - mojo::MessagePipe pipe; - BindInterface(IPC::mojom::ChannelBootstrap::Name_, std::move(pipe.handle1)); + child_process_.reset(); + child_process_.Bind(mojo::PendingRemote( + mojo_invitation_.AttachMessagePipe(0), /*version=*/0)); + + // Bootstrap the IPC Channel. + mojo::PendingRemote bootstrap; + child_process_->BootstrapLegacyIpc( + bootstrap.InitWithNewPipeAndPassReceiver()); std::unique_ptr channel_factory = IPC::ChannelMojo::CreateServerFactory( - std::move(pipe.handle0), io_task_runner, + bootstrap.PassPipe(), io_task_runner, base::ThreadTaskRunnerHandle::Get()); - child_process_.reset(); - content::BindInterface(this, child_process_.BindNewPipeAndPassReceiver()); - ResetChannelProxy(); // Do NOT expand ifdef or run time condition checks here! Synchronous @@ -2410,26 +2384,11 @@ int RenderProcessHostImpl::GetNextRoutingID() { return widget_helper_->GetNextRoutingID(); } -void RenderProcessHostImpl::BindInterface( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle interface_pipe) { - child_connection_->BindInterface(interface_name, std::move(interface_pipe)); -} - void RenderProcessHostImpl::BindReceiver( mojo::GenericPendingReceiver receiver) { child_process_->BindReceiver(std::move(receiver)); } -const service_manager::Identity& RenderProcessHostImpl::GetChildIdentity() { - // GetChildIdentity should only be called if the RPH is (or soon will be) - // backed by an actual renderer process. This helps prevent leaks similar to - // the ones raised in https://crbug.com/813045. - DCHECK(IsInitializedAndNotDead()); - - return child_connection_->child_identity(); -} - std::unique_ptr RenderProcessHostImpl::TakeMetricsAllocator() { return std::move(metrics_allocator_); @@ -2981,9 +2940,6 @@ void RenderProcessHostImpl::AppendRendererCommandLine( AppendCompositorCommandLineFlags(command_line); - command_line->AppendSwitchASCII( - service_manager::switches::kServiceRequestChannelToken, - child_connection_->service_token()); command_line->AppendSwitchASCII(switches::kRendererClientId, std::to_string(GetID())); @@ -3908,18 +3864,6 @@ RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { return GetAllHosts().Lookup(render_process_id); } -// static -RenderProcessHost* RenderProcessHost::FromRendererInstanceId( - const base::Token& instance_id) { - for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); - !i.IsAtEnd(); i.Advance()) { - RenderProcessHost* process = i.GetCurrentValue(); - if (process->GetChildIdentity().instance_id() == instance_id) - return process; - } - return nullptr; -} - // static bool RenderProcessHost::ShouldTryToUseExistingProcessHost( BrowserContext* browser_context, @@ -4601,11 +4545,6 @@ void RenderProcessHostImpl::OnProcessLaunched() { // preempt already queued messages. channel_->Unpause(false /* flush */); - if (child_connection_) { - child_connection_->SetProcess( - child_process_launcher_->GetProcess().Duplicate()); - } - if (coordinator_connector_receiver_.is_bound()) coordinator_connector_receiver_.Resume(); diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h index f31aaac5a10d03..b7fc9decc5f8ac 100644 --- a/content/browser/renderer_host/render_process_host_impl.h +++ b/content/browser/renderer_host/render_process_host_impl.h @@ -47,7 +47,6 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" -#include "content/public/common/service_manager_connection.h" #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_platform_file.h" #include "media/media_buildflags.h" @@ -67,7 +66,6 @@ #include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" #include "services/service_manager/public/cpp/binder_registry.h" -#include "services/service_manager/public/mojom/service.mojom.h" #include "services/tracing/public/mojom/traced_process.mojom.h" #include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h" #include "services/viz/public/mojom/gpu.mojom.h" @@ -104,7 +102,6 @@ class GpuClient; namespace content { class AgentMetricsCollectorHost; class BrowserPluginMessageFilter; -class ChildConnection; class CodeCacheHostImpl; class FileSystemManagerImpl; class IndexedDBDispatcherHost; @@ -230,10 +227,7 @@ class CONTENT_EXPORT RenderProcessHostImpl const WebRtcRtpPacketCallback& packet_callback) override; void EnableWebRtcEventLogOutput(int lid, int output_period_ms) override; void DisableWebRtcEventLogOutput(int lid) override; - void BindInterface(const std::string& interface_name, - mojo::ScopedMessagePipeHandle interface_pipe) override; void BindReceiver(mojo::GenericPendingReceiver receiver) override; - const service_manager::Identity& GetChildIdentity() override; std::unique_ptr TakeMetricsAllocator() override; const base::TimeTicks& GetInitTimeForNavigationMetrics() override; @@ -875,8 +869,6 @@ class CONTENT_EXPORT RenderProcessHostImpl mojo::OutgoingInvitation mojo_invitation_; - std::unique_ptr child_connection_; - size_t keep_alive_ref_count_; // Set in DisableKeepAliveRefCount(). When true, |keep_alive_ref_count_| must diff --git a/content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc b/content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc index be6d8b09985b38..d1e575d151d124 100644 --- a/content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc @@ -217,8 +217,7 @@ class RenderWidgetHostInputEventRouterTest : public testing::Test { // connected on the other end, as we really don't want it to respond // anyways. mojo::Remote input_target_client; - service_manager::InterfaceProvider().GetInterface( - input_target_client.BindNewPipeAndPassReceiver()); + ignore_result(input_target_client.BindNewPipeAndPassReceiver()); widget_host_root_->SetInputTargetClient(std::move(input_target_client)); EXPECT_EQ(view_root_.get(), diff --git a/content/browser/service_manager/service_manager_context.cc b/content/browser/service_manager/service_manager_context.cc index 1845da367fbcbf..bd9f7cf7940775 100644 --- a/content/browser/service_manager/service_manager_context.cc +++ b/content/browser/service_manager/service_manager_context.cc @@ -530,13 +530,6 @@ ServiceManagerContext::ServiceManagerContext( manifest.service_name); if (overlay) manifest.Amend(*overlay); - if (!manifest.preloaded_files.empty()) { - std::map preloaded_files_map; - for (const auto& info : manifest.preloaded_files) - preloaded_files_map.emplace(info.key, info.path); - ChildProcessLauncher::SetRegisteredFilesForService( - manifest.service_name, std::move(preloaded_files_map)); - } } for (auto& extra_manifest : GetContentClient()->browser()->GetExtraServiceManifests()) { diff --git a/content/browser/utility_process_host.cc b/content/browser/utility_process_host.cc index 40678a74d313b4..0df17d7cf8f612 100644 --- a/content/browser/utility_process_host.cc +++ b/content/browser/utility_process_host.cc @@ -20,6 +20,7 @@ #include "content/browser/browser_child_process_host_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/service_manager/service_manager_context.h" +#include "content/browser/v8_snapshot_files.h" #include "content/common/child_process_host_impl.h" #include "content/common/in_process_child_thread_params.h" #include "content/common/service_manager/child_connection.h" @@ -458,7 +459,8 @@ bool UtilityProcessHost::StartProcess() { std::unique_ptr delegate = std::make_unique( sandbox_type_, env_, *cmd_line); - process_->Launch(std::move(delegate), std::move(cmd_line), true); + process_->LaunchWithPreloadedFiles(std::move(delegate), std::move(cmd_line), + GetV8SnapshotFilesToPreload(), true); } return true; diff --git a/content/browser/v8_snapshot_files.cc b/content/browser/v8_snapshot_files.cc new file mode 100644 index 00000000000000..7ac0e1987ef602 --- /dev/null +++ b/content/browser/v8_snapshot_files.cc @@ -0,0 +1,46 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/v8_snapshot_files.h" + +#include "build/build_config.h" +#include "content/public/common/content_descriptor_keys.h" + +namespace content { + +std::map GetV8SnapshotFilesToPreload() { +#if defined(OS_LINUX) +#if defined(USE_V8_CONTEXT_SNAPSHOT) + return {{kV8ContextSnapshotDataDescriptor, + base::FilePath(FILE_PATH_LITERAL("v8_context_snapshot.bin"))}}; +#else + return {{kV8SnapshotDataDescriptor, + base::FilePath(FILE_PATH_LITERAL("snapshot_blob.bin"))}}; +#endif +#elif defined(OS_ANDROID) +#if defined(USE_V8_CONTEXT_SNAPSHOT) +#if defined(ARCH_CPU_64_BITS) + return { + {kV8Snapshot64DataDescriptor, + base::FilePath(FILE_PATH_LITERAL("assets/v8_context_snapshot_64.bin"))}}; +#else + return { + {kV8Snapshot32DataDescriptor, + base::FilePath(FILE_PATH_LITERAL("assets/v8_context_snapshot_32.bin"))}}; +#endif +#else +#if defined(ARCH_CPU_64_BITS) + return {{kV8Snapshot64DataDescriptor, + base::FilePath(FILE_PATH_LITERAL("assets/snapshot_blob_64.bin"))}}; +#else + return {{kV8Snapshot32DataDescriptor, + base::FilePath(FILE_PATH_LITERAL("assets/snapshot_blob_32.bin"))}}; +#endif +#endif +#else + return {}; +#endif +} + +} // namespace content diff --git a/content/browser/v8_snapshot_files.h b/content/browser/v8_snapshot_files.h new file mode 100644 index 00000000000000..77988476f6b3ad --- /dev/null +++ b/content/browser/v8_snapshot_files.h @@ -0,0 +1,25 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_V8_SNAPSHOT_FILES_H_ +#define CONTENT_BROWSER_V8_SNAPSHOT_FILES_H_ + +#include +#include + +#include "base/files/file_path.h" + +namespace content { + +// Returns a mapping of V8 snapshot files to be preloaded for child processes +// that use V8. Note that this is defined on all platforms even though it may +// be empty or unused on some. +// +// This mapping can be passed to +// |BrowserChildProcessHost::LaunchWithPreloadedFiles()|. +std::map GetV8SnapshotFilesToPreload(); + +} // namespace content + +#endif // CONTENT_BROWSER_V8_SNAPSHOT_FILES_H_ diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index 042f69bb7d39e7..fcec38ffa98a3d 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn @@ -33,7 +33,10 @@ source_set("common") { # In addition, targets outside of the content component (shell and tests) # must not link to this because it will duplicate the code in the component # build. - visibility = [ "//content/*" ] + visibility = [ + "//content/*", + "//tools/ipc_fuzzer/message_replay:ipc_fuzzer_replay", + ] sources = [ "accessibility_messages.h", diff --git a/content/public/app/BUILD.gn b/content/public/app/BUILD.gn index 1522e4167585b4..9009e9213518e2 100644 --- a/content/public/app/BUILD.gn +++ b/content/public/app/BUILD.gn @@ -182,7 +182,6 @@ source_set("content_browser_manifest") { ] deps = [ - ":v8_snapshot_overlay_manifest", "//base", "//content/public/common:service_names", "//services/content/public/cpp:manifest", @@ -193,23 +192,6 @@ source_set("content_browser_manifest") { ] } -source_set("content_renderer_manifest") { - sources = [ - "content_renderer_manifest.cc", - "content_renderer_manifest.h", - ] - - deps = [ - ":v8_snapshot_overlay_manifest", - "//base", - "//content/public/common:service_names", - ] - - public_deps = [ - "//services/service_manager/public/cpp", - ] -} - source_set("content_utility_manifest") { sources = [ "content_utility_manifest.cc", @@ -217,7 +199,6 @@ source_set("content_utility_manifest") { ] deps = [ - ":v8_snapshot_overlay_manifest", "//base", "//content/public/common:service_names", ] @@ -227,28 +208,9 @@ source_set("content_utility_manifest") { ] } -source_set("v8_snapshot_overlay_manifest") { - sources = [ - "v8_snapshot_overlay_manifest.cc", - "v8_snapshot_overlay_manifest.h", - ] - - deps = [ - "//base", - "//content/public/common:content_descriptor_keys", - ] - - public_deps = [ - "//services/service_manager/public/cpp", - ] - - configs += [ "//tools/v8_context_snapshot:use_v8_context_snapshot" ] -} - group("service_manifests") { public_deps = [ ":content_browser_manifest", - ":content_renderer_manifest", ":content_utility_manifest", ] } diff --git a/content/public/app/OWNERS b/content/public/app/OWNERS index fbdecad85f0452..94651f09ea8438 100644 --- a/content/public/app/OWNERS +++ b/content/public/app/OWNERS @@ -6,17 +6,8 @@ per-file content_browser_manifest.cc=file://ipc/SECURITY_OWNERS per-file content_browser_manifest.h=set noparent per-file content_browser_manifest.h=file://ipc/SECURITY_OWNERS -per-file content_renderer_manifest.cc=set noparent -per-file content_renderer_manifest.cc=file://ipc/SECURITY_OWNERS -per-file content_renderer_manifest.h=set noparent -per-file content_renderer_manifest.h=file://ipc/SECURITY_OWNERS - per-file content_utility_manifest.cc=set noparent per-file content_utility_manifest.cc=file://ipc/SECURITY_OWNERS per-file content_utility_manifest.h=set noparent per-file content_utility_manifest.h=file://ipc/SECURITY_OWNERS -per-file v8_snapshot_overlay_manifest.cc=set noparent -per-file v8_snapshot_overlay_manifest.cc=file://ipc/SECURITY_OWNERS -per-file v8_snapshot_overlay_manifest.h=set noparent -per-file v8_snapshot_overlay_manifest.h=file://ipc/SECURITY_OWNERS diff --git a/content/public/app/content_browser_manifest.cc b/content/public/app/content_browser_manifest.cc index 9010c1dfcd0a16..390d1d408a038d 100644 --- a/content/public/app/content_browser_manifest.cc +++ b/content/public/app/content_browser_manifest.cc @@ -121,7 +121,6 @@ const service_manager::Manifest& GetContentBrowserManifest() { .RequireCapability("file", "file:leveldb") .RequireCapability("network", "network_service") .RequireCapability("network", "test") - .RequireCapability(mojom::kRendererServiceName, "browser") .RequireCapability("media", "media:media") .RequireCapability("media_renderer", "media:media") .RequireCapability("*", "app") @@ -218,8 +217,6 @@ const service_manager::Manifest& GetContentBrowserManifest() { "network.mojom.RestrictedCookieManager", "blink.mojom.WebSocketConnector", "viz.mojom.Gpu"}) - .RequireInterfaceFilterCapability_Deprecated( - mojom::kRendererServiceName, "navigation:frame", "browser") .PackageService(content::GetManifest()) .Build()}; return *manifest; diff --git a/content/public/app/content_renderer_manifest.cc b/content/public/app/content_renderer_manifest.cc deleted file mode 100644 index 299e88f199ef4a..00000000000000 --- a/content/public/app/content_renderer_manifest.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/public/app/content_renderer_manifest.h" - -#include "base/no_destructor.h" -#include "content/public/app/v8_snapshot_overlay_manifest.h" -#include "content/public/common/service_names.mojom.h" -#include "services/service_manager/public/cpp/manifest_builder.h" - -namespace content { - -const service_manager::Manifest& GetContentRendererManifest() { - static base::NoDestructor manifest{ - service_manager::ManifestBuilder() - .WithServiceName(mojom::kRendererServiceName) - .WithDisplayName("Content (renderer process)") - .ExposeCapability( - "browser", - std::set{ - "blink.mojom.CodeCacheHost", - "blink.mojom.CrashMemoryMetricsReporter", - "blink.mojom.EmbeddedWorkerInstanceClient", - "blink.mojom.LeakDetector", - "blink.mojom.OomIntervention", - "blink.mojom.PeerConnectionManager", - "blink.mojom.SharedWorkerFactory", - "blink.mojom.WebDatabase", - "content.mojom.Child", - "content.mojom.ChildHistogramFetcher", - "content.mojom.ChildHistogramFetcherFactory", - "content.mojom.ChildProcess", - "content.mojom.FrameFactory", - "content.mojom.MhtmlFileWriter", - "content.mojom.RenderWidgetWindowTreeClientFactory", - "content.mojom.ResourceUsageReporter", - "IPC.mojom.ChannelBootstrap", - "visitedlink.mojom.VisitedLinkNotificationSink", - "web_cache.mojom.WebCache", - }) - .RequireCapability("font_service", "font_service") - .RequireCapability("*", "app") - .RequireCapability("metrics", "url_keyed_metrics") - .RequireCapability("ui", "discardable_memory") - .RequireCapability("ui", "gpu_client") - .RequireCapability("device", "device:hid") - .RequireCapability("device", "device:power_monitor") - .RequireCapability("device", "device:screen_orientation") - .RequireCapability("device", "device:time_zone_monitor") - .RequireCapability(mojom::kBrowserServiceName, "dwrite_font_proxy") - .RequireCapability(mojom::kSystemServiceName, "dwrite_font_proxy") - .RequireCapability(mojom::kSystemServiceName, "field_trials") - .RequireCapability(mojom::kBrowserServiceName, "renderer") - .RequireCapability(mojom::kSystemServiceName, "renderer") - .RequireCapability(mojom::kSystemServiceName, "sandbox_support") - .RequireInterfaceFilterCapability_Deprecated( - mojom::kBrowserServiceName, "navigation:shared_worker", - "renderer") - .RequireInterfaceFilterCapability_Deprecated( - mojom::kBrowserServiceName, "navigation:dedicated_worker", - "renderer") - .RequireInterfaceFilterCapability_Deprecated( - mojom::kBrowserServiceName, "navigation:service_worker", - "renderer") - .ExposeInterfaceFilterCapability_Deprecated( - "navigation:frame", "browser", - std::set{ - "blink.mojom.AppBannerController", - "blink.mojom.EngagementClient", "blink.mojom.ImageDownloader", - "blink.mojom.InstallationService", - "blink.mojom.ManifestManager", - "blink.mojom.MediaStreamDeviceObserver", - "blink.mojom.TextSuggestionBackend", - "blink.mojom.WebLaunchService", - "content.mojom.FrameInputHandler", - "content.mojom.FullscreenVideoElementHandler", - "content.mojom.Widget", "viz.mojom.InputTargetClient"}) - .RequireInterfaceFilterCapability_Deprecated( - mojom::kBrowserServiceName, "navigation:frame", "renderer") - .Build() - .Amend(GetV8SnapshotOverlayManifest())}; - return *manifest; -} - -} // namespace content diff --git a/content/public/app/content_renderer_manifest.h b/content/public/app/content_renderer_manifest.h deleted file mode 100644 index 3c06e50ea2e1ca..00000000000000 --- a/content/public/app/content_renderer_manifest.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_PUBLIC_APP_CONTENT_RENDERER_MANIFEST_H_ -#define CONTENT_PUBLIC_APP_CONTENT_RENDERER_MANIFEST_H_ - -#include "services/service_manager/public/cpp/manifest.h" - -namespace content { - -// Returns the service manifest for the "content_renderer" service. Every -// renderer process is an instance of this service, so this manifest determines -// what capabilities are directly exposed and required by renderer processes -// through the Service Manager. -const service_manager::Manifest& GetContentRendererManifest(); - -} // namespace content - -#endif // CONTENT_PUBLIC_APP_CONTENT_RENDERER_MANIFEST_H_ diff --git a/content/public/app/content_utility_manifest.cc b/content/public/app/content_utility_manifest.cc index 4926f03bb83069..187d57fc9421b5 100644 --- a/content/public/app/content_utility_manifest.cc +++ b/content/public/app/content_utility_manifest.cc @@ -5,7 +5,6 @@ #include "content/public/app/content_utility_manifest.h" #include "base/no_destructor.h" -#include "content/public/app/v8_snapshot_overlay_manifest.h" #include "content/public/common/service_names.mojom.h" #include "services/service_manager/public/cpp/manifest_builder.h" @@ -35,8 +34,7 @@ const service_manager::Manifest& GetContentUtilityManifest() { .RequireCapability(mojom::kSystemServiceName, "sandbox_support") .RequireCapability("*", "app") .RequireCapability("font_service", "font_service") - .Build() - .Amend(GetV8SnapshotOverlayManifest())}; + .Build()}; return *manifest; } diff --git a/content/public/app/v8_snapshot_overlay_manifest.cc b/content/public/app/v8_snapshot_overlay_manifest.cc deleted file mode 100644 index 636511a7de00cf..00000000000000 --- a/content/public/app/v8_snapshot_overlay_manifest.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/public/app/v8_snapshot_overlay_manifest.h" - -#include "base/files/file_path.h" -#include "base/no_destructor.h" -#include "build/build_config.h" -#include "content/public/common/content_descriptor_keys.h" -#include "services/service_manager/public/cpp/manifest_builder.h" - -namespace content { - -const service_manager::Manifest& GetV8SnapshotOverlayManifest() { - static base::NoDestructor manifest { - service_manager::ManifestBuilder() -#if defined(OS_LINUX) -#if defined(USE_V8_CONTEXT_SNAPSHOT) - .PreloadFile( - kV8ContextSnapshotDataDescriptor, - base::FilePath(FILE_PATH_LITERAL("v8_context_snapshot.bin"))) -#else - .PreloadFile(kV8SnapshotDataDescriptor, - base::FilePath(FILE_PATH_LITERAL("snapshot_blob.bin"))) -#endif // defined(USE_V8_CONTEXT_SNAPSHOT) -#elif defined(OS_ANDROID) -#if defined(USE_V8_CONTEXT_SNAPSHOT) -#if defined(ARCH_CPU_64_BITS) - .PreloadFile(kV8Snapshot64DataDescriptor, - base::FilePath(FILE_PATH_LITERAL( - "assets/v8_context_snapshot_64.bin"))) -#else - .PreloadFile(kV8Snapshot32DataDescriptor, - base::FilePath(FILE_PATH_LITERAL( - "assets/v8_context_snapshot_32.bin"))) -#endif -#else -#if defined(ARCH_CPU_64_BITS) - .PreloadFile( - kV8Snapshot64DataDescriptor, - base::FilePath(FILE_PATH_LITERAL("assets/snapshot_blob_64.bin"))) -#else - .PreloadFile( - kV8Snapshot32DataDescriptor, - base::FilePath(FILE_PATH_LITERAL("assets/snapshot_blob_32.bin"))) -#endif -#endif // defined(USE_V8_CONTEXT_SNAPSHOT) -#endif - .Build() - }; - return *manifest; -} - -} // namespace content diff --git a/content/public/app/v8_snapshot_overlay_manifest.h b/content/public/app/v8_snapshot_overlay_manifest.h deleted file mode 100644 index b06375f62ba6b6..00000000000000 --- a/content/public/app/v8_snapshot_overlay_manifest.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_PUBLIC_APP_V8_SNAPSHOT_OVERLAY_MANIFEST_H_ -#define CONTENT_PUBLIC_APP_V8_SNAPSHOT_OVERLAY_MANIFEST_H_ - -#include "services/service_manager/public/cpp/manifest.h" - -namespace content { - -// Returns a service manifest overlay that should be amended to the manifest of -// any service which initializes V8. This gives the service access to preloaded -// snapshot files on startup. -const service_manager::Manifest& GetV8SnapshotOverlayManifest(); - -} // namespace content - -#endif // CONTENT_PUBLIC_APP_V8_SNAPSHOT_OVERLAY_MANIFEST_H_ diff --git a/content/public/browser/browser_child_process_host.h b/content/public/browser/browser_child_process_host.h index 5c60ec0ffca799..41f2e9dda7945e 100644 --- a/content/public/browser/browser_child_process_host.h +++ b/content/public/browser/browser_child_process_host.h @@ -5,7 +5,9 @@ #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ #define CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ +#include #include +#include #include "base/callback.h" #include "base/environment.h" @@ -61,6 +63,16 @@ class CONTENT_EXPORT BrowserChildProcessHost : public IPC::Sender { std::unique_ptr cmd_line, bool terminate_on_shutdown) = 0; + // Same as above, but the process is launched with preloaded files from + // |files_to_preload| opened by the browser and passed as corresponding file + // descriptors in the child process. |files_to_preload| is currently ignored + // on platforms other than Linux and Android. + virtual void LaunchWithPreloadedFiles( + std::unique_ptr delegate, + std::unique_ptr cmd_line, + std::map files_to_preload, + bool terminate_on_shutdown) = 0; + virtual const ChildProcessData& GetData() = 0; // Returns the ChildProcessHost object used by this object. diff --git a/content/public/browser/render_process_host.h b/content/public/browser/render_process_host.h index d70b03becd7ae6..811a60d80b0a73 100644 --- a/content/public/browser/render_process_host.h +++ b/content/public/browser/render_process_host.h @@ -51,10 +51,6 @@ class TimeDelta; class Token; } -namespace service_manager { -class Identity; -} - namespace url { class Origin; } @@ -345,12 +341,6 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, virtual void EnableWebRtcEventLogOutput(int lid, int output_period_ms) = 0; virtual void DisableWebRtcEventLogOutput(int lid) = 0; - // Binds interfaces exposed to the browser process from the renderer. - // - // DEPRECATED: Use |BindReceiver()| instead. - virtual void BindInterface(const std::string& interface_name, - mojo::ScopedMessagePipeHandle interface_pipe) = 0; - // Asks the renderer process to bind |receiver|. |receiver| arrives in the // renderer process and is carried through the following flow, stopping if any // step decides to bind it: @@ -361,9 +351,6 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, // 4. Possibly more stpes, depending on the ChildThreadImpl subclass. virtual void BindReceiver(mojo::GenericPendingReceiver receiver) = 0; - // Can only be called when IsInitializedAndNotDead() is true. - virtual const service_manager::Identity& GetChildIdentity() = 0; - // Extracts any persistent-memory-allocator used for renderer metrics. // Ownership is passed to the caller. To support sharing of histogram data // between the Renderer and the Browser, the allocator is created when the diff --git a/content/public/common/service_names.mojom b/content/public/common/service_names.mojom index cd8f0c66be9356..996eedb62e0c26 100644 --- a/content/public/common/service_names.mojom +++ b/content/public/common/service_names.mojom @@ -19,10 +19,6 @@ const string kBrowserServiceName = "content_browser"; // instance which packages other browser-wide services. const string kPackagedServicesServiceName = "content_packaged_services"; -// The default service name used to identify render processes when connecting -// them to the Service Manager. -const string kRendererServiceName = "content_renderer"; - // The default service name used to identify utility processes when connecting // them to the Service Manager. const string kUtilityServiceName = "content_utility"; diff --git a/content/public/test/mock_render_process_host.cc b/content/public/test/mock_render_process_host.cc index 3d298cbe30c09c..eb78ee7ba99f8e 100644 --- a/content/public/test/mock_render_process_host.cc +++ b/content/public/test/mock_render_process_host.cc @@ -16,7 +16,6 @@ #include "base/stl_util.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" -#include "base/token.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h" @@ -35,8 +34,6 @@ #include "content/public/browser/render_widget_host_iterator.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/storage_partition.h" -#include "content/public/common/service_manager_connection.h" -#include "content/public/common/service_names.mojom.h" #include "content/test/not_implemented_network_url_loader_factory.h" #include "media/media_buildflags.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" @@ -68,11 +65,6 @@ MockRenderProcessHost::MockRenderProcessHost(BrowserContext* browser_context) is_unused_(true), keep_alive_ref_count_(0), foreground_service_worker_count_(0), - child_identity_( - mojom::kRendererServiceName, - BrowserContext::GetServiceInstanceGroupFor(browser_context), - base::Token::CreateRandom(), - base::Token::CreateRandom()), url_loader_factory_(nullptr) { // Child process security operations can't be unit tested unless we add // ourselves as an existing child process. @@ -345,14 +337,6 @@ base::TimeDelta MockRenderProcessHost::GetChildProcessIdleTime() { return base::TimeDelta::FromMilliseconds(0); } -void MockRenderProcessHost::BindInterface( - const std::string& interface_name, - mojo::ScopedMessagePipeHandle interface_pipe) { - auto it = binder_overrides_.find(interface_name); - if (it != binder_overrides_.end()) - it->second.Run(std::move(interface_pipe)); -} - void MockRenderProcessHost::BindReceiver( mojo::GenericPendingReceiver receiver) { auto it = binder_overrides_.find(*receiver.interface_name()); @@ -360,10 +344,6 @@ void MockRenderProcessHost::BindReceiver( it->second.Run(receiver.PassPipe()); } -const service_manager::Identity& MockRenderProcessHost::GetChildIdentity() { - return child_identity_; -} - std::unique_ptr MockRenderProcessHost::TakeMetricsAllocator() { return nullptr; diff --git a/content/public/test/mock_render_process_host.h b/content/public/test/mock_render_process_host.h index 59693132db2481..c4575bc766b061 100644 --- a/content/public/test/mock_render_process_host.h +++ b/content/public/test/mock_render_process_host.h @@ -29,8 +29,6 @@ #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "net/base/network_isolation_key.h" -#include "services/service_manager/public/cpp/identity.h" -#include "services/service_manager/public/cpp/interface_provider.h" #if defined(OS_ANDROID) #include "content/public/browser/android/child_process_importance.h" @@ -142,10 +140,7 @@ class MockRenderProcessHost : public RenderProcessHost { const WebRtcRtpPacketCallback& packet_callback) override; void EnableWebRtcEventLogOutput(int lid, int output_period_ms) override; void DisableWebRtcEventLogOutput(int lid) override; - void BindInterface(const std::string& interface_name, - mojo::ScopedMessagePipeHandle interface_pipe) override; void BindReceiver(mojo::GenericPendingReceiver receiver) override; - const service_manager::Identity& GetChildIdentity() override; std::unique_ptr TakeMetricsAllocator() override; const base::TimeTicks& GetInitTimeForNavigationMetrics() override; @@ -270,7 +265,6 @@ class MockRenderProcessHost : public RenderProcessHost { int foreground_service_worker_count_; std::unique_ptr> renderer_interface_; std::map binder_overrides_; - service_manager::Identity child_identity_; bool is_renderer_locked_to_site_ = false; network::mojom::URLLoaderFactory* url_loader_factory_; mojo::PendingReceiver cache_storage_receiver_; diff --git a/content/public/test/test_service_manager_context.cc b/content/public/test/test_service_manager_context.cc index 8f1261e1eb2ae7..c7d211629c4d0a 100644 --- a/content/public/test/test_service_manager_context.cc +++ b/content/public/test/test_service_manager_context.cc @@ -20,7 +20,6 @@ TestServiceManagerContext::TestServiceManagerContext() { } TestServiceManagerContext::~TestServiceManagerContext() { - ChildProcessLauncher::ResetRegisteredFilesForTesting(); ServiceManagerConnection::DestroyForProcess(); } diff --git a/content/renderer/render_thread_impl_browsertest.cc b/content/renderer/render_thread_impl_browsertest.cc index f71fbf08f2b1ae..e009558e858678 100644 --- a/content/renderer/render_thread_impl_browsertest.cc +++ b/content/renderer/render_thread_impl_browsertest.cc @@ -28,33 +28,25 @@ #include "base/threading/thread_task_runner_handle.h" #include "content/app/mojo/mojo_init.h" #include "content/common/in_process_child_thread_params.h" -#include "content/common/service_manager/child_connection.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" -#include "content/public/browser/system_connector.h" +#include "content/public/common/child_process_host.h" +#include "content/public/common/child_process_host_delegate.h" #include "content/public/common/content_client.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" -#include "content/public/common/service_names.mojom.h" #include "content/public/renderer/content_renderer_client.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test_utils.h" #include "content/public/test/test_content_client_initializer.h" #include "content/public/test/test_launcher.h" -#include "content/public/test/test_service_manager_context.h" #include "content/renderer/render_process_impl.h" #include "content/test/mock_render_process.h" #include "gpu/GLES2/gl2extchromium.h" #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" #include "gpu/config/gpu_switches.h" -#include "ipc/ipc.mojom.h" -#include "ipc/ipc_channel_mojo.h" -#include "mojo/core/embedder/embedder.h" -#include "mojo/core/embedder/scoped_ipc_support.h" -#include "mojo/public/cpp/system/invitation.h" -#include "services/service_manager/public/cpp/constants.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h" @@ -152,7 +144,8 @@ class QuitOnTestMsgFilter : public IPC::MessageFilter { base::OnceClosure quit_closure_; }; -class RenderThreadImplBrowserTest : public testing::Test { +class RenderThreadImplBrowserTest : public testing::Test, + public ChildProcessHostDelegate { public: RenderThreadImplBrowserTest() {} @@ -166,26 +159,9 @@ class RenderThreadImplBrowserTest : public testing::Test { base::CreateSingleThreadTaskRunner({BrowserThread::IO}); InitializeMojo(); - mojo_ipc_support_.reset(new mojo::core::ScopedIPCSupport( - io_task_runner, mojo::core::ScopedIPCSupport::ShutdownPolicy::FAST)); - shell_context_.reset(new TestServiceManagerContext); - mojo::OutgoingInvitation invitation; - child_connection_ = std::make_unique( - service_manager::Identity(mojom::kRendererServiceName, - service_manager::kSystemInstanceGroup, - base::Token{}, base::Token::CreateRandom()), - &invitation, GetSystemConnector(), io_task_runner); - - mojo::MessagePipe pipe; - child_connection_->BindInterface(IPC::mojom::ChannelBootstrap::Name_, - std::move(pipe.handle1)); - - channel_ = IPC::ChannelProxy::Create( - IPC::ChannelMojo::CreateServerFactory( - std::move(pipe.handle0), io_task_runner, - blink::scheduler::GetSingleThreadTaskRunnerForTesting()), - nullptr, io_task_runner, - blink::scheduler::GetSingleThreadTaskRunnerForTesting()); + process_host_ = + ChildProcessHost::Create(this, ChildProcessHost::IpcMode::kNormal); + process_host_->CreateChannelMojo(); mock_process_.reset(new MockRenderProcess); test_task_counter_ = base::MakeRefCounted(); @@ -211,8 +187,8 @@ class RenderThreadImplBrowserTest : public testing::Test { base::FieldTrialList::CreateTrialsFromCommandLine( *cmd, switches::kFieldTrialHandle, -1); thread_ = new RenderThreadImpl( - InProcessChildThreadParams(io_task_runner, &invitation, - child_connection_->service_token()), + InProcessChildThreadParams(io_task_runner, + &process_host_->GetMojoInvitation().value()), /*renderer_client_id=*/1, std::move(main_thread_scheduler)); cmd->InitFromArgv(old_argv); @@ -237,8 +213,12 @@ class RenderThreadImplBrowserTest : public testing::Test { } } + // ChildProcessHostDelegate implementation: + bool OnMessageReceived(const IPC::Message&) override { return true; } + const base::Process& GetProcess() override { return null_process_; } + protected: - IPC::Sender* sender() { return channel_.get(); } + IPC::Sender* sender() { return process_host_.get(); } void SetBackgroundState( mojom::RenderProcessBackgroundState background_state) { @@ -266,10 +246,8 @@ class RenderThreadImplBrowserTest : public testing::Test { std::unique_ptr content_renderer_client_; std::unique_ptr browser_threads_; - std::unique_ptr shell_context_; - std::unique_ptr child_connection_; - std::unique_ptr channel_; - std::unique_ptr mojo_ipc_support_; + const base::Process null_process_; + std::unique_ptr process_host_; std::unique_ptr mock_process_; scoped_refptr test_msg_filter_; diff --git a/content/shell/browser/shell_content_browser_client.cc b/content/shell/browser/shell_content_browser_client.cc index 9e466b13a7d8fe..6917eac93c9c14 100644 --- a/content/shell/browser/shell_content_browser_client.cc +++ b/content/shell/browser/shell_content_browser_client.cc @@ -163,20 +163,6 @@ const service_manager::Manifest& GetContentBrowserOverlayManifest() { return *manifest; } -const service_manager::Manifest& GetContentRendererOverlayManifest() { - static base::NoDestructor manifest{ - service_manager::ManifestBuilder() - .ExposeCapability( - "browser", - service_manager::Manifest::InterfaceList()) - .ExposeInterfaceFilterCapability_Deprecated( - "navigation:frame", "browser", - service_manager::Manifest::InterfaceList()) - .Build()}; - return *manifest; -} - } // namespace std::string GetShellUserAgent() { @@ -299,8 +285,6 @@ base::Optional ShellContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { if (name == content::mojom::kBrowserServiceName) return GetContentBrowserOverlayManifest(); - if (name == content::mojom::kRendererServiceName) - return GetContentRendererOverlayManifest(); return base::nullopt; } diff --git a/tools/ipc_fuzzer/message_replay/BUILD.gn b/tools/ipc_fuzzer/message_replay/BUILD.gn index cff5180fa200da..8086f208ac0f65 100644 --- a/tools/ipc_fuzzer/message_replay/BUILD.gn +++ b/tools/ipc_fuzzer/message_replay/BUILD.gn @@ -6,11 +6,13 @@ executable("ipc_fuzzer_replay") { testonly = true configs += [ "//tools/ipc_fuzzer:ipc_fuzzer_tool_config" ] deps = [ + "//content/common", "//mojo/core/embedder", "//tools/ipc_fuzzer/message_lib:ipc_message_lib", ] public_deps = [ "//ipc", + "//mojo/public/cpp/bindings", ] sources = [ "replay.cc", diff --git a/tools/ipc_fuzzer/message_replay/DEPS b/tools/ipc_fuzzer/message_replay/DEPS index f69c943f5598c3..9af6d1d3b258f6 100644 --- a/tools/ipc_fuzzer/message_replay/DEPS +++ b/tools/ipc_fuzzer/message_replay/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+chrome/common", + "+content/common", "+content/public/common", "+mojo/core/embedder", "+mojo/public", diff --git a/tools/ipc_fuzzer/message_replay/replay_process.cc b/tools/ipc_fuzzer/message_replay/replay_process.cc index bf561454a2af12..7ca93cd0ef5582 100644 --- a/tools/ipc_fuzzer/message_replay/replay_process.cc +++ b/tools/ipc_fuzzer/message_replay/replay_process.cc @@ -17,14 +17,17 @@ #include "base/run_loop.h" #include "build/build_config.h" #include "chrome/common/chrome_switches.h" -#include "content/public/common/connection_filter.h" +#include "content/common/child_process.mojom-test-utils.h" #include "content/public/common/content_switches.h" -#include "content/public/common/service_manager_connection.h" #include "ipc/ipc.mojom.h" #include "ipc/ipc_channel_mojo.h" #include "mojo/core/embedder/configuration.h" #include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/scoped_ipc_support.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/remote.h" +#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel_endpoint.h" #include "mojo/public/cpp/system/invitation.h" @@ -36,30 +39,39 @@ #endif namespace ipc_fuzzer { + namespace { -class IPCChannelBootstrapper : public content::ConnectionFilter { +// Used to simulate a basic child process IPC endpoint and bootstrap the legacy +// IPC channel driven by this process. +class FakeChildProcessImpl + : public content::mojom::ChildProcessInterceptorForTesting { public: - explicit IPCChannelBootstrapper( - mojo::ScopedMessagePipeHandle bootstrap_handle) - : bootstrap_handle_(std::move(bootstrap_handle)) {} + explicit FakeChildProcessImpl( + mojo::PendingRemote legacy_ipc_bootstrap) + : legacy_ipc_bootstrap_(std::move(legacy_ipc_bootstrap)) { + ignore_result(disconnected_process_.BindNewPipeAndPassReceiver()); + } - private: - void OnBindInterface(const service_manager::BindSourceInfo& source_info, - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe, - service_manager::Connector* connector) override { - if (interface_name != IPC::mojom::ChannelBootstrap::Name_) - return; - - DCHECK(bootstrap_handle_.is_valid()); - mojo::FuseMessagePipes(std::move(*interface_pipe), - std::move(bootstrap_handle_)); + // content::mojom::ChildProcessInterceptorForTesting overrides: + content::mojom::ChildProcess* GetForwardingInterface() override { + return disconnected_process_.get(); } - mojo::ScopedMessagePipeHandle bootstrap_handle_; + void Initialize(mojo::PendingRemote + bootstrap) override { + bootstrap_.Bind(std::move(bootstrap)); + } - DISALLOW_COPY_AND_ASSIGN(IPCChannelBootstrapper); + void BootstrapLegacyIpc( + mojo::PendingReceiver receiver) override { + mojo::FusePipes(std::move(receiver), std::move(legacy_ipc_bootstrap_)); + } + + private: + mojo::PendingRemote legacy_ipc_bootstrap_; + mojo::Remote bootstrap_; + mojo::Remote disconnected_process_; }; } // namespace @@ -140,19 +152,15 @@ bool ReplayProcess::Initialize(int argc, const char** argv) { void ReplayProcess::OpenChannel() { DCHECK(mojo_invitation_); - service_manager_connection_ = content::ServiceManagerConnection::Create( - service_manager::mojom::ServiceRequest( - mojo_invitation_->ExtractMessagePipe( - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - service_manager::switches::kServiceRequestChannelToken))), - io_thread_.task_runner()); - mojo::MessagePipe ipc_pipe; - service_manager_connection_->AddConnectionFilter( - std::make_unique(std::move(ipc_pipe.handle0))); - service_manager_connection_->Start(); + mojo::PendingRemote bootstrap; + auto bootstrap_receiver = bootstrap.InitWithNewPipeAndPassReceiver(); + mojo::MakeSelfOwnedReceiver( + std::make_unique(std::move(bootstrap)), + mojo::PendingReceiver( + mojo_invitation_->ExtractMessagePipe(0))); channel_ = IPC::ChannelProxy::Create( IPC::ChannelMojo::CreateClientFactory( - std::move(ipc_pipe.handle1), io_thread_.task_runner(), + bootstrap_receiver.PassPipe(), io_thread_.task_runner(), base::ThreadTaskRunnerHandle::Get()), this, io_thread_.task_runner(), base::ThreadTaskRunnerHandle::Get()); } diff --git a/tools/ipc_fuzzer/message_replay/replay_process.h b/tools/ipc_fuzzer/message_replay/replay_process.h index f8ba5fb7b54b1c..7f855ccc9dcdcd 100644 --- a/tools/ipc_fuzzer/message_replay/replay_process.h +++ b/tools/ipc_fuzzer/message_replay/replay_process.h @@ -19,10 +19,6 @@ #include "ipc/ipc_message.h" #include "tools/ipc_fuzzer/message_lib/message_file.h" -namespace content { -class ServiceManagerConnection; -} - namespace mojo { class IncomingInvitation; namespace core { @@ -60,8 +56,6 @@ class ReplayProcess : public IPC::Listener { std::unique_ptr mojo_ipc_support_; std::unique_ptr mojo_invitation_; - std::unique_ptr - service_manager_connection_; std::unique_ptr channel_; base::SingleThreadTaskExecutor main_task_executor_; base::Thread io_thread_;