| 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/process.h" | 12 #include "base/singleton.h" |
| 13 | |
| 14 template<typename Type> | |
| 15 struct DefaultSingletonTraits; | |
| 16 | 13 |
| 17 // http://code.google.com/p/chromium/wiki/LinuxZygote | 14 // http://code.google.com/p/chromium/wiki/LinuxZygote |
| 18 | 15 |
| 19 // The zygote host is the interface, in the browser process, to the zygote | 16 // The zygote host is the interface, in the browser process, to the zygote |
| 20 // process. | 17 // process. |
| 21 class ZygoteHost { | 18 class ZygoteHost { |
| 22 public: | 19 public: |
| 23 ~ZygoteHost(); | 20 ~ZygoteHost(); |
| 24 | 21 |
| 25 pid_t ForkRenderer(const std::vector<std::string>& command_line, | 22 pid_t ForkRenderer(const std::vector<std::string>& command_line, |
| 26 const base::GlobalDescriptors::Mapping& mapping); | 23 const base::GlobalDescriptors::Mapping& mapping); |
| 27 void EnsureProcessTerminated(pid_t process); | 24 void EnsureProcessTerminated(pid_t process); |
| 28 | 25 |
| 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 | |
| 34 // These are the command codes used on the wire between the browser and the | 26 // These are the command codes used on the wire between the browser and the |
| 35 // zygote. | 27 // zygote. |
| 36 enum { | 28 enum { |
| 37 kCmdFork = 0, // Fork off a new renderer. | 29 kCmdFork = 0, // Fork off a new renderer. |
| 38 kCmdReap = 1, // Reap a renderer child. | 30 kCmdReap = 1, // Reap a renderer child. |
| 39 kCmdDidProcessCrash = 2, // Check if child process crashed. | |
| 40 }; | 31 }; |
| 41 | 32 |
| 42 private: | 33 private: |
| 43 friend struct DefaultSingletonTraits<ZygoteHost>; | 34 friend struct DefaultSingletonTraits<ZygoteHost>; |
| 44 ZygoteHost(); | 35 ZygoteHost(); |
| 45 void LaunchZygoteProcess(); | 36 void LaunchZygoteProcess(); |
| 46 | 37 |
| 47 int control_fd_; // the socket to the zygote | 38 int control_fd_; // the socket to the zygote |
| 48 }; | 39 }; |
| 49 | 40 |
| 50 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ | 41 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ |
| OLD | NEW |