OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/app/nacl_fork_delegate_linux.h" | 5 #include "chrome/app/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/resource.h> | 9 #include <sys/resource.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
11 | 11 |
| 12 #include <set> |
| 13 |
12 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
13 #include "base/command_line.h" | 15 #include "base/command_line.h" |
14 #include "base/eintr_wrapper.h" | 16 #include "base/eintr_wrapper.h" |
15 #include "base/logging.h" | 17 #include "base/logging.h" |
16 #include "base/file_path.h" | 18 #include "base/file_path.h" |
17 #include "base/path_service.h" | 19 #include "base/path_service.h" |
18 #include "base/process_util.h" | 20 #include "base/process_util.h" |
19 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 21 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
20 #include "content/common/unix_domain_socket_posix.h" | 22 #include "content/common/unix_domain_socket_posix.h" |
21 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
(...skipping 18 matching lines...) Expand all Loading... |
40 VLOG(1) << "NaClForkDelegate::Init()"; | 42 VLOG(1) << "NaClForkDelegate::Init()"; |
41 int fds[2]; | 43 int fds[2]; |
42 | 44 |
43 sandboxed_ = sandboxed; | 45 sandboxed_ = sandboxed; |
44 // Confirm a couple hard-wired assumptions. | 46 // Confirm a couple hard-wired assumptions. |
45 // The NaCl constants are from chrome/nacl/nacl_linux_helper.h | 47 // The NaCl constants are from chrome/nacl/nacl_linux_helper.h |
46 DCHECK(kNaClBrowserDescriptor == browserdesc); | 48 DCHECK(kNaClBrowserDescriptor == browserdesc); |
47 DCHECK(kNaClSandboxDescriptor == sandboxdesc); | 49 DCHECK(kNaClSandboxDescriptor == sandboxdesc); |
48 | 50 |
49 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); | 51 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); |
50 base::file_handle_mapping_vector fds_to_map; | 52 base::FileHandleMappingVector fds_to_map; |
51 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); | 53 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); |
52 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); | 54 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); |
53 | 55 |
54 status_ = kNaClHelperUnused; | 56 status_ = kNaClHelperUnused; |
55 FilePath helper_exe; | 57 FilePath helper_exe; |
56 FilePath helper_bootstrap_exe; | 58 FilePath helper_bootstrap_exe; |
57 if (!PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe)) { | 59 if (!PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe)) { |
58 status_ = kNaClHelperMissing; | 60 status_ = kNaClHelperMissing; |
59 } else if (!PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, | 61 } else if (!PathService::Get(chrome::FILE_NACL_HELPER_BOOTSTRAP, |
60 &helper_bootstrap_exe)) { | 62 &helper_bootstrap_exe)) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 161 |
160 bool NaClForkDelegate::AckChild(const int fd, | 162 bool NaClForkDelegate::AckChild(const int fd, |
161 const std::string& channel_switch) { | 163 const std::string& channel_switch) { |
162 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), | 164 int nwritten = HANDLE_EINTR(write(fd, channel_switch.c_str(), |
163 channel_switch.length())); | 165 channel_switch.length())); |
164 if (nwritten != static_cast<int>(channel_switch.length())) { | 166 if (nwritten != static_cast<int>(channel_switch.length())) { |
165 return false; | 167 return false; |
166 } | 168 } |
167 return true; | 169 return true; |
168 } | 170 } |
OLD | NEW |