OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/nacl_fork_delegate_linux.h" | 5 #include "chrome/common/nacl_fork_delegate_linux.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 DCHECK(kNaClBrowserDescriptor == browserdesc); | 40 DCHECK(kNaClBrowserDescriptor == browserdesc); |
41 DCHECK(kNaClSandboxDescriptor == sandboxdesc); | 41 DCHECK(kNaClSandboxDescriptor == sandboxdesc); |
42 | 42 |
43 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); | 43 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); |
44 base::file_handle_mapping_vector fds_to_map; | 44 base::file_handle_mapping_vector fds_to_map; |
45 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); | 45 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); |
46 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); | 46 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); |
47 // TODO(bradchen): To make this the default for release builds, | 47 // TODO(bradchen): To make this the default for release builds, |
48 // remove command line switch. | 48 // remove command line switch. |
49 ready_ = false; | 49 ready_ = false; |
50 const bool use_helper = CommandLine::ForCurrentProcess()->HasSwitch( | 50 // Use helper if kNaClLinuxHelper switch is not found. |
| 51 const bool use_helper = !CommandLine::ForCurrentProcess()->HasSwitch( |
51 switches::kNaClLinuxHelper); | 52 switches::kNaClLinuxHelper); |
52 FilePath helper_exe; | 53 FilePath helper_exe; |
53 FilePath helper_bootstrap_exe; | 54 FilePath helper_bootstrap_exe; |
54 if (use_helper && | 55 if (use_helper && |
55 PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe) && | 56 PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe) && |
56 PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, | 57 PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, |
57 &helper_bootstrap_exe)) { | 58 &helper_bootstrap_exe)) { |
58 CommandLine::StringVector argv = CommandLine::ForCurrentProcess()->argv(); | 59 CommandLine::StringVector argv = CommandLine::ForCurrentProcess()->argv(); |
59 argv[0] = helper_bootstrap_exe.value(); | 60 argv[0] = helper_bootstrap_exe.value(); |
60 argv[1] = helper_exe.value(); | 61 argv[1] = helper_exe.value(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 123 |
123 bool NaClForkDelegate::AckChild(const int fd, | 124 bool NaClForkDelegate::AckChild(const int fd, |
124 const std::string& channel_switch) { | 125 const std::string& channel_switch) { |
125 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), | 126 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), |
126 channel_switch.length())); | 127 channel_switch.length())); |
127 if (nwritten != static_cast<int>(channel_switch.length())) { | 128 if (nwritten != static_cast<int>(channel_switch.length())) { |
128 return false; | 129 return false; |
129 } | 130 } |
130 return true; | 131 return true; |
131 } | 132 } |
OLD | NEW |