default_job.h 1.1 KB

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