Chromium Code Reviews| Index: chrome/nacl/nacl_helper_linux.cc |
| diff --git a/chrome/nacl/nacl_helper_linux.cc b/chrome/nacl/nacl_helper_linux.cc |
| index 53d247dfef101012fbbfa19496ee0f6ebfc26871..fb847be567b27348ed51f76f25c362cfa737c5b8 100644 |
| --- a/chrome/nacl/nacl_helper_linux.cc |
| +++ b/chrome/nacl/nacl_helper_linux.cc |
| @@ -30,6 +30,7 @@ |
| #include "base/rand_util.h" |
| #include "components/nacl/loader/nacl_listener.h" |
| #include "components/nacl/loader/nacl_sandbox_linux.h" |
| +#include "content/public/common/zygote_fork_delegate_linux.h" |
| #include "crypto/nss_util.h" |
| #include "ipc/ipc_descriptors.h" |
| #include "ipc/ipc_switches.h" |
| @@ -56,8 +57,9 @@ void BecomeNaClLoader(const std::vector<int>& child_fds, |
| LOG(ERROR) << "Could not initialize NaCl's second " |
| << "layer sandbox (seccomp-bpf)."; |
| } |
| - base::GlobalDescriptors::GetInstance()->Set(kPrimaryIPCChannel, |
| - child_fds[kNaClBrowserFDIndex]); |
| + base::GlobalDescriptors::GetInstance()->Set( |
| + kPrimaryIPCChannel, |
| + child_fds[content::ZygoteForkDelegate::kBrowserFDIndex]); |
| base::MessageLoopForIO main_message_loop; |
| NaClListener listener; |
| @@ -70,6 +72,8 @@ void BecomeNaClLoader(const std::vector<int>& child_fds, |
| // Start the NaCl loader in a child created by the NaCl loader Zygote. |
| void ChildNaClLoaderInit(const std::vector<int>& child_fds, |
| const NaClLoaderSystemInfo& system_info) { |
| + int parent_fd = child_fds[content::ZygoteForkDelegate::kParentFDIndex]; |
|
jln (very slow on Chromium)
2013/10/07 18:12:06
Do you want to make these const?
Mark Seaborn
2013/10/08 18:31:06
I don't normally do that for local variables, but
|
| + int dummy_fd = child_fds[content::ZygoteForkDelegate::kDummyFDIndex]; |
| bool validack = false; |
| const size_t kMaxReadSize = 1024; |
| char buffer[kMaxReadSize]; |
| @@ -77,8 +81,7 @@ void ChildNaClLoaderInit(const std::vector<int>& child_fds, |
| // should not fork any child processes (which the seccomp |
| // sandbox does) until then, because that can interfere with the |
| // parent's discovery of our PID. |
| - const int nread = HANDLE_EINTR(read(child_fds[kNaClParentFDIndex], buffer, |
| - kMaxReadSize)); |
| + const int nread = HANDLE_EINTR(read(parent_fd, buffer, kMaxReadSize)); |
| const std::string switch_prefix = std::string("--") + |
| switches::kProcessChannelID + std::string("="); |
| const size_t len = switch_prefix.length(); |
| @@ -95,10 +98,10 @@ void ChildNaClLoaderInit(const std::vector<int>& child_fds, |
| validack = true; |
| } |
| } |
| - if (HANDLE_EINTR(close(child_fds[kNaClDummyFDIndex])) != 0) |
| - LOG(ERROR) << "close(child_fds[kNaClDummyFDIndex]) failed"; |
| - if (HANDLE_EINTR(close(child_fds[kNaClParentFDIndex])) != 0) |
| - LOG(ERROR) << "close(child_fds[kNaClParentFDIndex]) failed"; |
| + if (HANDLE_EINTR(close(dummy_fd)) != 0) |
| + LOG(ERROR) << "close(dummy_fd) failed"; |
| + if (HANDLE_EINTR(close(parent_fd)) != 0) |
| + LOG(ERROR) << "close(parent_fd) failed"; |
| if (validack) { |
| BecomeNaClLoader(child_fds, system_info); |
| } else { |
| @@ -113,7 +116,7 @@ void ChildNaClLoaderInit(const std::vector<int>& child_fds, |
| bool HandleForkRequest(const std::vector<int>& child_fds, |
| const NaClLoaderSystemInfo& system_info, |
| Pickle* output_pickle) { |
| - if (kNaClParentFDIndex + 1 != child_fds.size()) { |
| + if (content::ZygoteForkDelegate::kParentFDIndex + 1 != child_fds.size()) { |
|
jln (very slow on Chromium)
2013/10/07 18:12:06
kNumPassedFds ? (see comment at the enum declarati
Mark Seaborn
2013/10/08 18:31:06
Done.
|
| LOG(ERROR) << "nacl_helper: unexpected number of fds, got " |
| << child_fds.size(); |
| return false; |