process_lifecycle.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2021 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 BASE_FUCHSIA_PROCESS_LIFECYCLE_H_
  5. #define BASE_FUCHSIA_PROCESS_LIFECYCLE_H_
  6. #include <fuchsia/process/lifecycle/cpp/fidl.h>
  7. #include <lib/fidl/cpp/binding.h>
  8. #include "base/base_export.h"
  9. #include "base/callback.h"
  10. namespace base {
  11. // Registers a fuchsia.process.lifecycle.Lifecycle protocol implementation to
  12. // receive graceful termination requests from the Component Framework v2
  13. // ELF executable runner.
  14. //
  15. // The implementation consumes the PA_LIFECYCLE handle, which the ELF runner
  16. // will provide only if the Component manifest contains a lifecycle/stop_event
  17. // registration.
  18. class BASE_EXPORT ProcessLifecycle final
  19. : public fuchsia::process::lifecycle::Lifecycle {
  20. public:
  21. explicit ProcessLifecycle(base::OnceClosure on_stop);
  22. ~ProcessLifecycle() override;
  23. ProcessLifecycle(const ProcessLifecycle&) = delete;
  24. ProcessLifecycle& operator=(const ProcessLifecycle&) = delete;
  25. // fuchsia::process::lifecycle::Lifecycle implementation.
  26. void Stop() override;
  27. private:
  28. base::OnceClosure on_stop_;
  29. fidl::Binding<fuchsia::process::lifecycle::Lifecycle> binding_;
  30. };
  31. } // namespace base
  32. #endif // BASE_FUCHSIA_PROCESS_LIFECYCLE_H_