process_handle_fuchsia.cc 783 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2017 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. #include "base/process/process_handle.h"
  5. #include <lib/zx/process.h>
  6. #include <zircon/process.h>
  7. #include "base/fuchsia/koid.h"
  8. #include "base/logging.h"
  9. namespace base {
  10. ProcessId GetCurrentProcId() {
  11. return GetProcId(GetCurrentProcessHandle());
  12. }
  13. ProcessHandle GetCurrentProcessHandle() {
  14. // Note that zx_process_self() returns a real handle, and ownership is not
  15. // transferred to the caller (i.e. this should never be closed).
  16. return zx_process_self();
  17. }
  18. ProcessId GetProcId(ProcessHandle process) {
  19. return GetKoid(*zx::unowned_process(process)).value_or(ZX_KOID_INVALID);
  20. }
  21. } // namespace base