| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/global_descriptors_posix.h" | 14 #include "base/global_descriptors_posix.h" |
| 15 #include "base/lock.h" | 15 #include "base/lock.h" |
| 16 #include "base/process.h" | 16 #include "base/process.h" |
| 17 | 17 |
| 18 template<typename Type> | 18 template<typename Type> |
| 19 struct DefaultSingletonTraits; | 19 struct DefaultSingletonTraits; |
| 20 | 20 |
| 21 static const char kZygoteMagic[] = "ZYGOTE_OK"; | 21 static const char kZygoteMagic[] = "ZYGOTE_OK"; |
| 22 | 22 |
| 23 // http://code.google.com/p/chromium/wiki/LinuxZygote | 23 // http://code.google.com/p/chromium/wiki/LinuxZygote |
| 24 | 24 |
| 25 // The zygote host is the interface, in the browser process, to the zygote | 25 // The zygote host is the interface, in the browser process, to the zygote |
| 26 // process. | 26 // process. |
| 27 class ZygoteHost { | 27 class ZygoteHost { |
| 28 public: | 28 public: |
| 29 // Returns the singleton instance. |
| 30 static ZygoteHost* GetInstance(); |
| 31 |
| 29 void Init(const std::string& sandbox_cmd); | 32 void Init(const std::string& sandbox_cmd); |
| 30 | 33 |
| 31 // Tries to start a renderer process. Returns its pid on success, otherwise | 34 // Tries to start a renderer process. Returns its pid on success, otherwise |
| 32 // base::kNullProcessHandle; | 35 // base::kNullProcessHandle; |
| 33 pid_t ForkRenderer(const std::vector<std::string>& command_line, | 36 pid_t ForkRenderer(const std::vector<std::string>& command_line, |
| 34 const base::GlobalDescriptors::Mapping& mapping); | 37 const base::GlobalDescriptors::Mapping& mapping); |
| 35 void EnsureProcessTerminated(pid_t process); | 38 void EnsureProcessTerminated(pid_t process); |
| 36 | 39 |
| 37 // Get the termination status (exit code) of the process and return true if | 40 // Get the termination status (exit code) of the process and return true if |
| 38 // the status indicates the process crashed. |child_exited| is set to true | 41 // the status indicates the process crashed. |child_exited| is set to true |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Lock control_lock_; | 87 Lock control_lock_; |
| 85 pid_t pid_; | 88 pid_t pid_; |
| 86 bool init_; | 89 bool init_; |
| 87 bool using_suid_sandbox_; | 90 bool using_suid_sandbox_; |
| 88 std::string sandbox_binary_; | 91 std::string sandbox_binary_; |
| 89 bool have_read_sandbox_status_word_; | 92 bool have_read_sandbox_status_word_; |
| 90 int sandbox_status_; | 93 int sandbox_status_; |
| 91 }; | 94 }; |
| 92 | 95 |
| 93 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ | 96 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ |
| OLD | NEW |