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