| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ | 5 #ifndef CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ |
| 6 #define CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ | 6 #define CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/global_descriptors_posix.h" | 11 #include "base/global_descriptors_posix.h" |
| 12 #include "base/singleton.h" | 12 #include "base/process.h" |
| 13 |
| 14 template<typename Type> |
| 15 struct DefaultSingletonTraits; |
| 13 | 16 |
| 14 // http://code.google.com/p/chromium/wiki/LinuxZygote | 17 // http://code.google.com/p/chromium/wiki/LinuxZygote |
| 15 | 18 |
| 16 // The zygote host is the interface, in the browser process, to the zygote | 19 // The zygote host is the interface, in the browser process, to the zygote |
| 17 // process. | 20 // process. |
| 18 class ZygoteHost { | 21 class ZygoteHost { |
| 19 public: | 22 public: |
| 20 ~ZygoteHost(); | 23 ~ZygoteHost(); |
| 21 | 24 |
| 22 pid_t ForkRenderer(const std::vector<std::string>& command_line, | 25 pid_t ForkRenderer(const std::vector<std::string>& command_line, |
| 23 const base::GlobalDescriptors::Mapping& mapping); | 26 const base::GlobalDescriptors::Mapping& mapping); |
| 24 void EnsureProcessTerminated(pid_t process); | 27 void EnsureProcessTerminated(pid_t process); |
| 25 | 28 |
| 29 // Get the termination status (exit code) of the process and return true if |
| 30 // the status indicates the process crashed. |child_exited| is set to true |
| 31 // iff the child process has terminated. (|child_exited| may be NULL.) |
| 32 bool DidProcessCrash(base::ProcessHandle handle, bool* child_exited); |
| 33 |
| 26 // These are the command codes used on the wire between the browser and the | 34 // These are the command codes used on the wire between the browser and the |
| 27 // zygote. | 35 // zygote. |
| 28 enum { | 36 enum { |
| 29 kCmdFork = 0, // Fork off a new renderer. | 37 kCmdFork = 0, // Fork off a new renderer. |
| 30 kCmdReap = 1, // Reap a renderer child. | 38 kCmdReap = 1, // Reap a renderer child. |
| 39 kCmdDidProcessCrash = 2, // Check if child process crashed. |
| 31 }; | 40 }; |
| 32 | 41 |
| 33 private: | 42 private: |
| 34 friend struct DefaultSingletonTraits<ZygoteHost>; | 43 friend struct DefaultSingletonTraits<ZygoteHost>; |
| 35 ZygoteHost(); | 44 ZygoteHost(); |
| 36 void LaunchZygoteProcess(); | 45 void LaunchZygoteProcess(); |
| 37 | 46 |
| 38 int control_fd_; // the socket to the zygote | 47 int control_fd_; // the socket to the zygote |
| 39 }; | 48 }; |
| 40 | 49 |
| 41 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ | 50 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ |
| OLD | NEW |