default_job.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifndef BASE_FUCHSIA_DEFAULT_JOB_H_
  5. #define BASE_FUCHSIA_DEFAULT_JOB_H_
  6. #include <lib/zx/job.h>
  7. #include "base/base_export.h"
  8. namespace base {
  9. // Gets and sets the job object used for creating new child processes,
  10. // and looking them up by their process IDs.
  11. // zx::job::default_job() will be returned if no job is explicitly set here.
  12. // Only valid handles may be passed to SetDefaultJob().
  13. BASE_EXPORT zx::unowned_job GetDefaultJob();
  14. BASE_EXPORT void SetDefaultJob(zx::job job);
  15. // Replaces the current default job (if any) with the specified zx::job, and
  16. // restores the original default job when going out-of-scope.
  17. // Note that replacing the default job is not thread-safe!
  18. class BASE_EXPORT ScopedDefaultJobForTest {
  19. public:
  20. ScopedDefaultJobForTest(zx::job new_default_job);
  21. ScopedDefaultJobForTest(const ScopedDefaultJobForTest&) = delete;
  22. ScopedDefaultJobForTest& operator=(const ScopedDefaultJobForTest&) = delete;
  23. ~ScopedDefaultJobForTest();
  24. private:
  25. zx::job old_default_job_;
  26. };
  27. } // namespace base
  28. #endif // BASE_FUCHSIA_DEFAULT_JOB_H_