// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_PROCESS_HOST_H_ #define CONTENT_PUBLIC_BROWSER_SERVICE_PROCESS_HOST_H_ #include <memory> #include <optional> #include <string> #include <utility> #include <vector> #include "base/command_line.h" #include "base/functional/callback.h" #include "base/observer_list_types.h" #include "base/process/process_handle.h" #include "content/common/content_export.h" #include "content/public/browser/service_process_info.h" #include "mojo/public/cpp/bindings/generic_pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "sandbox/policy/mojom/sandbox.mojom.h" #include "url/gurl.h" #if BUILDFLAG(IS_WIN) #include "base/files/file_path.h" #include "base/types/pass_key.h" #endif // BUILDFLAG(IS_WIN) namespace base { class Process; } // namespace base namespace content { // Passkeys for service process host Options. class ServiceProcessHostGpuClient; class ServiceProcessHostPreloadLibraries; // Sandbox type for ServiceProcessHost::Launch<remote>() is found by // template matching on |remote|. Consult [email protected] and // add a [ServiceSandbox=type] mojom attribute. template <typename Interface> inline sandbox::mojom::Sandbox GetServiceSandboxType() { … } // ServiceProcessHost is used to launch new service processes given basic // parameters like sandbox type, as well as a primordial Mojo interface to drive // the service's behavior. See |Launch()| methods below for more details. // // Typical usage might look something like: // // constexpr auto kFooServiceIdleTimeout = base::Seconds(5); // auto foo_service = ServiceProcessHost::Launch<foo::mojom::FooService>( // ServiceProcessHost::Options() // .WithDisplayName(IDS_FOO_SERVICE_DISPLAY_NAME) // .Pass()); // foo_service.set_idle_handler( // kFooServiceIdleTimeout, // base::BindRepeating( // /* Something to reset |foo_service|, killing the process. */)); // foo_service->DoWork(); // class CONTENT_EXPORT ServiceProcessHost { … }; } // namespace content #endif // CONTENT_PUBLIC_BROWSER_SERVICE_PROCESS_HOST_H_