1 // Copyright (c) 2012 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.
5 #ifndef COMPONENTS_NACL_ZYGOTE_NACL_FORK_DELEGATE_LINUX_H_
6 #define COMPONENTS_NACL_ZYGOTE_NACL_FORK_DELEGATE_LINUX_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "content/public/common/zygote_fork_delegate_linux.h"
25 // Appends any ZygoteForkDelegate instances needed by NaCl to |*delegates|.
26 void AddNaClZygoteForkDelegates(
27 ScopedVector
<content::ZygoteForkDelegate
>* delegates
);
29 // The NaClForkDelegate is created during Chrome linux zygote
30 // initialization, and provides "fork()" functionality with
31 // NaCl specific process characteristics (specifically address
32 // space layout) as an alternative to forking the zygote.
33 // A new delegate is passed in as an argument to ZygoteMain().
34 class NaClForkDelegate
: public content::ZygoteForkDelegate
{
36 explicit NaClForkDelegate(bool nonsfi_mode
);
37 ~NaClForkDelegate() override
;
39 void Init(int sandboxdesc
, bool enable_layer1_sandbox
) override
;
40 void InitialUMA(std::string
* uma_name
,
42 int* uma_boundary_value
) override
;
43 bool CanHelp(const std::string
& process_type
,
44 std::string
* uma_name
,
46 int* uma_boundary_value
) override
;
47 pid_t
Fork(const std::string
& process_type
,
48 const std::vector
<int>& fds
,
49 const std::string
& channel_id
) override
;
50 bool GetTerminationStatus(pid_t pid
,
52 base::TerminationStatus
* status
,
53 int* exit_code
) override
;
56 static void AddPassthroughEnvToOptions(base::LaunchOptions
* options
);
58 // These values are reported via UMA and hence they become permanent
59 // constants. Old values cannot be reused, only new ones added.
60 enum NaClHelperStatus
{
61 kNaClHelperUnused
= 0,
62 kNaClHelperMissing
= 1,
63 kNaClHelperBootstrapMissing
= 2,
64 kNaClHelperValgrind
= 3,
65 kNaClHelperLaunchFailed
= 4,
66 kNaClHelperAckFailed
= 5,
67 kNaClHelperSuccess
= 6,
68 kNaClHelperStatusBoundary
// Must be one greater than highest value used.
71 const bool nonsfi_mode_
;
72 NaClHelperStatus status_
;
75 FRIEND_TEST_ALL_PREFIXES(NaClForkDelegateLinuxTest
, EnvPassthrough
);
77 DISALLOW_COPY_AND_ASSIGN(NaClForkDelegate
);
82 #endif // COMPONENTS_NACL_ZYGOTE_NACL_FORK_DELEGATE_LINUX_H_