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 "content/browser/zygote_host_linux.h" | 5 #include "content/browser/zygote_host_linux.h" |
6 | 6 |
7 #include <sys/socket.h> | 7 #include <sys/socket.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 | 11 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 int fds[2]; | 89 int fds[2]; |
90 #if defined(OS_FREEBSD) || defined(OS_OPENBSD) | 90 #if defined(OS_FREEBSD) || defined(OS_OPENBSD) |
91 // The BSDs often don't support SOCK_SEQPACKET yet, so fall back to | 91 // The BSDs often don't support SOCK_SEQPACKET yet, so fall back to |
92 // SOCK_DGRAM if necessary. | 92 // SOCK_DGRAM if necessary. |
93 if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) != 0) | 93 if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) != 0) |
94 CHECK(socketpair(PF_UNIX, SOCK_DGRAM, 0, fds) == 0); | 94 CHECK(socketpair(PF_UNIX, SOCK_DGRAM, 0, fds) == 0); |
95 #else | 95 #else |
96 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); | 96 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); |
97 #endif | 97 #endif |
98 base::file_handle_mapping_vector fds_to_map; | 98 base::FileHandleMappingVector fds_to_map; |
99 fds_to_map.push_back(std::make_pair(fds[1], 3)); | 99 fds_to_map.push_back(std::make_pair(fds[1], 3)); |
100 | 100 |
101 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 101 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
102 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { | 102 if (browser_command_line.HasSwitch(switches::kZygoteCmdPrefix)) { |
103 cmd_line.PrependWrapper( | 103 cmd_line.PrependWrapper( |
104 browser_command_line.GetSwitchValueNative(switches::kZygoteCmdPrefix)); | 104 browser_command_line.GetSwitchValueNative(switches::kZygoteCmdPrefix)); |
105 } | 105 } |
106 // Append any switches from the browser process that need to be forwarded on | 106 // Append any switches from the browser process that need to be forwarded on |
107 // to the zygote/renderers. | 107 // to the zygote/renderers. |
108 // Should this list be obtained from browser_render_process_host.cc? | 108 // Should this list be obtained from browser_render_process_host.cc? |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (!UnixDomainSocket::SendMsg(control_fd_, pickle.data(), pickle.size(), | 266 if (!UnixDomainSocket::SendMsg(control_fd_, pickle.data(), pickle.size(), |
267 fds)) | 267 fds)) |
268 return base::kNullProcessHandle; | 268 return base::kNullProcessHandle; |
269 | 269 |
270 // Read the reply, which pickles the PID and an optional UMA enumeration. | 270 // Read the reply, which pickles the PID and an optional UMA enumeration. |
271 static const unsigned kMaxReplyLength = 2048; | 271 static const unsigned kMaxReplyLength = 2048; |
272 char buf[kMaxReplyLength]; | 272 char buf[kMaxReplyLength]; |
273 const ssize_t len = ReadReply(buf, sizeof(buf)); | 273 const ssize_t len = ReadReply(buf, sizeof(buf)); |
274 | 274 |
275 Pickle reply_pickle(buf, len); | 275 Pickle reply_pickle(buf, len); |
276 void *iter = NULL; | 276 void* iter = NULL; |
277 if (len <= 0 || !reply_pickle.ReadInt(&iter, &pid)) | 277 if (len <= 0 || !reply_pickle.ReadInt(&iter, &pid)) |
278 return base::kNullProcessHandle; | 278 return base::kNullProcessHandle; |
279 | 279 |
280 // If there is a nonempty UMA name string, then there is a UMA | 280 // If there is a nonempty UMA name string, then there is a UMA |
281 // enumeration to record. | 281 // enumeration to record. |
282 std::string uma_name; | 282 std::string uma_name; |
283 int uma_sample; | 283 int uma_sample; |
284 int uma_boundary_value; | 284 int uma_boundary_value; |
285 if (reply_pickle.ReadString(&iter, &uma_name) && | 285 if (reply_pickle.ReadString(&iter, &uma_name) && |
286 !uma_name.empty() && | 286 !uma_name.empty() && |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { | 436 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { |
437 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; | 437 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; |
438 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 438 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
439 } | 439 } |
440 | 440 |
441 if (exit_code) | 441 if (exit_code) |
442 *exit_code = tmp_exit_code; | 442 *exit_code = tmp_exit_code; |
443 | 443 |
444 return static_cast<base::TerminationStatus>(status); | 444 return static_cast<base::TerminationStatus>(status); |
445 } | 445 } |
OLD | NEW |