service_process_host.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_SERVICE_MANAGER_SERVICE_PROCESS_HOST_H_
  5. #define SERVICES_SERVICE_MANAGER_SERVICE_PROCESS_HOST_H_
  6. #include <string>
  7. #include "base/callback.h"
  8. #include "base/process/process_handle.h"
  9. #include "mojo/public/cpp/bindings/pending_remote.h"
  10. #include "sandbox/policy/mojom/sandbox.mojom.h"
  11. #include "services/service_manager/public/cpp/identity.h"
  12. #include "services/service_manager/public/mojom/service.mojom.h"
  13. namespace service_manager {
  14. // Interface which can be implemented to control launch and lifetime of service
  15. // processes.
  16. //
  17. // TODO(https://crbug.com/781334): This should be the singular implementation of
  18. // a service process host. More stuff needs to move out of Content first, so
  19. // until then this exists so Service Manager can delegate.
  20. class ServiceProcessHost {
  21. public:
  22. virtual ~ServiceProcessHost() {}
  23. // Launches the service process. If called and successful, the process should
  24. // be terminated on ServiceProcessHost destruction at the latest.
  25. //
  26. // Returns a valid remote endpoint for the Service.
  27. //
  28. // |callback| is eventually called with the ProcessId, which may be
  29. // |base::kNullProcessId| if launching failed.
  30. using LaunchCallback = base::OnceCallback<void(base::ProcessId)>;
  31. virtual mojo::PendingRemote<mojom::Service> Launch(
  32. const Identity& identity,
  33. sandbox::mojom::Sandbox sandbox_type,
  34. const std::u16string& display_name,
  35. LaunchCallback callback) = 0;
  36. };
  37. } // namespace service_manager
  38. #endif // SERVICES_SERVICE_MANAGER_SERVICE_PROCESS_HOST_H_