| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_ |
| 6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_ | 6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/process/kill.h" | 12 #include "base/process/kill.h" |
| 13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/common/result_codes.h" | 16 #include "content/public/common/result_codes.h" |
| 17 #include "mojo/edk/embedder/embedder.h" | 17 #include "mojo/edk/embedder/embedder.h" |
| 18 #include "mojo/edk/embedder/scoped_platform_handle.h" | 18 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 19 #include "services/catalog/public/cpp/manifest_parsing_util.h" | 19 #include "services/catalog/public/cpp/manifest_parsing_util.h" |
| 20 | 20 |
| 21 #if defined(OS_ANDROID) |
| 22 #include "base/android/scoped_java_ref.h" |
| 23 #endif |
| 24 |
| 21 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 22 #include "sandbox/win/src/sandbox_types.h" | 26 #include "sandbox/win/src/sandbox_types.h" |
| 23 #else | 27 #else |
| 24 #include "content/public/browser/file_descriptor_info.h" | 28 #include "content/public/browser/file_descriptor_info.h" |
| 25 #endif | 29 #endif |
| 26 | 30 |
| 27 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
| 28 #include "content/public/common/zygote_handle.h" | 32 #include "content/public/common/zygote_handle.h" |
| 29 #endif | 33 #endif |
| 30 | 34 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 130 |
| 127 // Note that this could be called before PostLaunchOnLauncherThread() is | 131 // Note that this could be called before PostLaunchOnLauncherThread() is |
| 128 // called. | 132 // called. |
| 129 void PostLaunchOnClientThread(ChildProcessLauncherHelper::Process process, | 133 void PostLaunchOnClientThread(ChildProcessLauncherHelper::Process process, |
| 130 int error_code); | 134 int error_code); |
| 131 | 135 |
| 132 int client_thread_id() const { return client_thread_id_; } | 136 int client_thread_id() const { return client_thread_id_; } |
| 133 | 137 |
| 134 // Returns the termination status and sets |exit_code| if non null. | 138 // Returns the termination status and sets |exit_code| if non null. |
| 135 // See ChildProcessLauncher::GetChildTerminationStatus for more info. | 139 // See ChildProcessLauncher::GetChildTerminationStatus for more info. |
| 136 static base::TerminationStatus GetTerminationStatus( | 140 base::TerminationStatus GetTerminationStatus( |
| 137 const ChildProcessLauncherHelper::Process& process, | 141 const ChildProcessLauncherHelper::Process& process, |
| 138 bool known_dead, | 142 bool known_dead, |
| 139 int* exit_code); | 143 int* exit_code); |
| 140 | 144 |
| 141 // Terminates |process|. | 145 // Terminates |process|. |
| 142 // Returns true if the process was stopped, false if the process had not been | 146 // Returns true if the process was stopped, false if the process had not been |
| 143 // started yet or could not be stopped. | 147 // started yet or could not be stopped. |
| 144 // Note that |exit_code| and |wait| are not used on Android. | 148 // Note that |exit_code| and |wait| are not used on Android. |
| 145 static bool TerminateProcess(const base::Process& process, | 149 static bool TerminateProcess(const base::Process& process, |
| 146 int exit_code, | 150 int exit_code, |
| 147 bool wait); | 151 bool wait); |
| 148 | 152 |
| 149 // Terminates the process with the normal exit code and ensures it has been | 153 // Terminates the process with the normal exit code and ensures it has been |
| 150 // stopped. By returning a normal exit code this ensures UMA won't treat this | 154 // stopped. By returning a normal exit code this ensures UMA won't treat this |
| 151 // as a crash. | 155 // as a crash. |
| 152 // Returns immediately and perform the work on the launcher thread. | 156 // Returns immediately and perform the work on the launcher thread. |
| 153 static void ForceNormalProcessTerminationAsync( | 157 static void ForceNormalProcessTerminationAsync( |
| 154 ChildProcessLauncherHelper::Process process); | 158 ChildProcessLauncherHelper::Process process); |
| 155 | 159 |
| 156 static void SetProcessBackgroundedOnLauncherThread( | 160 void SetProcessBackgroundedOnLauncherThread(base::Process process, |
| 157 base::Process process, bool background); | 161 bool background); |
| 158 | 162 |
| 159 static void SetRegisteredFilesForService( | 163 static void SetRegisteredFilesForService( |
| 160 const std::string& service_name, | 164 const std::string& service_name, |
| 161 catalog::RequiredFileMap required_files); | 165 catalog::RequiredFileMap required_files); |
| 162 | 166 |
| 163 static void ResetRegisteredFilesForTesting(); | 167 static void ResetRegisteredFilesForTesting(); |
| 164 | 168 |
| 165 private: | 169 private: |
| 166 friend class base::RefCountedThreadSafe<ChildProcessLauncherHelper>; | 170 friend class base::RefCountedThreadSafe<ChildProcessLauncherHelper>; |
| 167 | 171 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 182 | 186 |
| 183 const int child_process_id_; | 187 const int child_process_id_; |
| 184 const BrowserThread::ID client_thread_id_; | 188 const BrowserThread::ID client_thread_id_; |
| 185 base::TimeTicks begin_launch_time_; | 189 base::TimeTicks begin_launch_time_; |
| 186 std::unique_ptr<base::CommandLine> command_line_; | 190 std::unique_ptr<base::CommandLine> command_line_; |
| 187 std::unique_ptr<SandboxedProcessLauncherDelegate> delegate_; | 191 std::unique_ptr<SandboxedProcessLauncherDelegate> delegate_; |
| 188 base::WeakPtr<ChildProcessLauncher> child_process_launcher_; | 192 base::WeakPtr<ChildProcessLauncher> child_process_launcher_; |
| 189 mojo::edk::ScopedPlatformHandle mojo_client_handle_; | 193 mojo::edk::ScopedPlatformHandle mojo_client_handle_; |
| 190 mojo::edk::ScopedPlatformHandle mojo_server_handle_; | 194 mojo::edk::ScopedPlatformHandle mojo_server_handle_; |
| 191 bool terminate_on_shutdown_; | 195 bool terminate_on_shutdown_; |
| 196 |
| 197 #if defined(OS_ANDROID) |
| 198 base::android::ScopedJavaGlobalRef<jobject> java_peer_; |
| 199 #endif |
| 192 }; | 200 }; |
| 193 | 201 |
| 194 } // namespace internal | 202 } // namespace internal |
| 195 | 203 |
| 196 } // namespace content | 204 } // namespace content |
| 197 | 205 |
| 198 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_ | 206 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_ |
| OLD | NEW |