0

Remove uses of a deprecated function in cast.

CreateProcessHostForBuiltinServiceInstance is only called for
ExecutionMode::kOutOfProcessBuiltin (see
services/service_manager/service_manager.cc). Cast never uses that mode;
there are no instances of kOutOfProcessBuiltin being used in chromium or
in the internal cast codebase.

Bug: 1328879, 977637
Change-Id: I23ef669290c860d6d976f9d21fcd351f62ba6f0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5254861
Reviewed-by: Vigen Issahhanjan <vigeni@google.com>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Antonio Rivera <antoniori@google.com>
Cr-Commit-Position: refs/heads/main@{#1256846}
This commit is contained in:
Antonio Rivera
2024-02-06 17:40:04 +00:00
committed by Chromium LUCI CQ
parent caea468bb6
commit 7167f6ab09
6 changed files with 4 additions and 87 deletions

@ -18,6 +18,7 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_pump_type.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/process/process_handle.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/deferred_sequenced_task_runner.h"
@ -98,38 +99,6 @@ void DestroyConnectorOnIOThread() {
g_io_thread_connector.Get().reset();
}
// A ServiceProcessHost implementation which delegates to Content-managed
// processes, either via a new UtilityProcessHost to launch new service
// processes, or the existing GpuProcessHost to run service instances in the GPU
// process.
class ContentChildServiceProcessHost
: public service_manager::ServiceProcessHost {
public:
ContentChildServiceProcessHost() = default;
ContentChildServiceProcessHost(const ContentChildServiceProcessHost&) =
delete;
ContentChildServiceProcessHost& operator=(
const ContentChildServiceProcessHost&) = delete;
~ContentChildServiceProcessHost() override = default;
// service_manager::ServiceProcessHost:
mojo::PendingRemote<service_manager::mojom::Service> Launch(
const service_manager::Identity& identity,
sandbox::mojom::Sandbox sandbox_type,
const std::u16string& display_name,
LaunchCallback callback) override {
// Start a new process for this service.
mojo::PendingRemote<service_manager::mojom::Service> remote;
content::LaunchUtilityProcessServiceDeprecated(
identity.name(), display_name, sandbox_type,
remote.InitWithNewPipeAndPassReceiver().PassPipe(),
std::move(callback));
return remote;
}
};
// A ServiceProcessHost implementation which uses the Service Manager's builtin
// service executable launcher. Not yet intended for use in production Chrome,
// hence availability is gated behind a flag.
@ -198,7 +167,9 @@ class BrowserServiceManagerDelegate
std::unique_ptr<service_manager::ServiceProcessHost>
CreateProcessHostForBuiltinServiceInstance(
const service_manager::Identity& identity) override {
return std::make_unique<ContentChildServiceProcessHost>();
// Cast only uses the default kInProcessBuiltin mode. This function should
// only be called for kOutOfProcessBuiltin mode.
NOTREACHED_NORETURN();
}
std::unique_ptr<service_manager::ServiceProcessHost>

@ -17,7 +17,6 @@ cast_source_set("service") {
public_deps = [
"//media/mojo/mojom",
"//media/mojo/services",
"//services/service_manager/public/cpp",
]
deps = [

@ -30,7 +30,6 @@
#include "media/base/media_log.h"
#include "media/base/media_resource.h"
#include "media/base/renderer_client.h"
#include "services/service_manager/public/mojom/interface_provider.mojom.h"
namespace chromecast {
namespace media {

@ -13,7 +13,6 @@
#include "base/process/process.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "build/chromecast_buildflags.h"
#include "content/browser/utility_process_host.h"
#include "content/common/child_process.mojom.h"
#include "content/public/browser/browser_task_traits.h"
@ -26,10 +25,6 @@
#include "mojo/public/cpp/bindings/remote.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#if BUILDFLAG(IS_CASTOS) || BUILDFLAG(IS_CAST_ANDROID)
#include "base/process/process_handle.h"
#endif
namespace content {
namespace {
@ -243,28 +238,4 @@ void ServiceProcessHost::Launch(mojo::GenericPendingReceiver receiver,
}
}
// TODO(crbug.com/1328879): Remove this method when fixing the bug.
#if BUILDFLAG(IS_CASTOS) || BUILDFLAG(IS_CAST_ANDROID)
void LaunchUtilityProcessServiceDeprecated(
const std::string& service_name,
const std::u16string& display_name,
sandbox::mojom::Sandbox sandbox_type,
mojo::ScopedMessagePipeHandle service_pipe,
base::OnceCallback<void(base::ProcessId)> callback) {
UtilityProcessHost* host = new UtilityProcessHost();
host->SetName(display_name);
host->SetMetricsName(service_name);
host->SetSandboxType(sandbox_type);
host->Start();
host->RunServiceDeprecated(
service_name, std::move(service_pipe),
base::BindOnce(
[](base::OnceCallback<void(base::ProcessId)> callback,
const std::optional<base::ProcessId> pid) {
std::move(callback).Run(pid.value_or(base::kNullProcessId));
},
std::move(callback)));
}
#endif
} // namespace content

@ -16,7 +16,6 @@
#include "base/observer_list_types.h"
#include "base/process/process_handle.h"
#include "base/strings/string_piece.h"
#include "build/chromecast_buildflags.h"
#include "content/common/content_export.h"
#include "content/public/browser/service_process_info.h"
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
@ -25,11 +24,6 @@
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "url/gurl.h"
// TODO(crbug.com/1328879): Remove this when fixing the bug.
#if BUILDFLAG(IS_CASTOS) || BUILDFLAG(IS_CAST_ANDROID)
#include "mojo/public/cpp/system/message_pipe.h"
#endif // BUILDFLAG(IS_CASTOS) || BUILDFLAG(IS_CAST_ANDROID)
#if BUILDFLAG(IS_WIN)
#include "base/files/file_path.h"
#include "base/types/pass_key.h"
@ -211,19 +205,6 @@ class CONTENT_EXPORT ServiceProcessHost {
sandbox::mojom::Sandbox sandbox);
};
// TODO(crbug.com/1328879): Remove this method when fixing the bug.
#if BUILDFLAG(IS_CASTOS) || BUILDFLAG(IS_CAST_ANDROID)
// DEPRECATED. DO NOT USE THIS. This is a helper for any remaining service
// launching code which uses an older code path to launch services in a utility
// process. All new code must use ServiceProcessHost instead of this API.
void CONTENT_EXPORT LaunchUtilityProcessServiceDeprecated(
const std::string& service_name,
const std::u16string& display_name,
sandbox::mojom::Sandbox sandbox_type,
mojo::ScopedMessagePipeHandle service_pipe,
base::OnceCallback<void(base::ProcessId)> callback);
#endif // BUILDFLAG(IS_CASTOS) || BUILDFLAG(IS_CAST_ANDROID)
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_SERVICE_PROCESS_HOST_H_

@ -244,10 +244,6 @@ source_set("common_sources") {
":main_function_params",
":renderer_type",
":switches",
# TODO(crbug.com/977637): Remove when
# content::LaunchUtilityProcessServiceDeprecated() gets removed.
"//build:chromecast_buildflags",
"//content/common",
"//content/public/common/zygote:buildflags",
"//ipc",