| OLD | NEW |
| 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
| 6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_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/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
| 15 #include "base/process/process.h" | 15 #include "base/process/process.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/sequence_checker.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "content/browser/child_process_launcher_helper.h" | 18 #include "content/browser/child_process_launcher_helper.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/common/result_codes.h" | 21 #include "content/public/common/result_codes.h" |
| 22 #include "mojo/edk/embedder/outgoing_broker_client_invitation.h" | 22 #include "mojo/edk/embedder/outgoing_broker_client_invitation.h" |
| 23 #include "mojo/edk/embedder/scoped_platform_handle.h" | 23 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class CommandLine; | 26 class CommandLine; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 47 static_assert(static_cast<int>(LAUNCH_RESULT_START) > | 47 static_assert(static_cast<int>(LAUNCH_RESULT_START) > |
| 48 static_cast<int>(sandbox::SBOX_ERROR_LAST), | 48 static_cast<int>(sandbox::SBOX_ERROR_LAST), |
| 49 "LaunchResultCode must not overlap with sandbox::ResultCode"); | 49 "LaunchResultCode must not overlap with sandbox::ResultCode"); |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 // Launches a process asynchronously and notifies the client of the process | 52 // Launches a process asynchronously and notifies the client of the process |
| 53 // handle when it's available. It's used to avoid blocking the calling thread | 53 // handle when it's available. It's used to avoid blocking the calling thread |
| 54 // on the OS since often it can take > 100 ms to create the process. | 54 // on the OS since often it can take > 100 ms to create the process. |
| 55 class CONTENT_EXPORT ChildProcessLauncher : public base::NonThreadSafe { | 55 class CONTENT_EXPORT ChildProcessLauncher { |
| 56 public: | 56 public: |
| 57 class CONTENT_EXPORT Client { | 57 class CONTENT_EXPORT Client { |
| 58 public: | 58 public: |
| 59 // Will be called on the thread that the ChildProcessLauncher was | 59 // Will be called on the thread that the ChildProcessLauncher was |
| 60 // constructed on. | 60 // constructed on. |
| 61 virtual void OnProcessLaunched() = 0; | 61 virtual void OnProcessLaunched() = 0; |
| 62 | 62 |
| 63 virtual void OnProcessLaunchFailed(int error_code) {}; | 63 virtual void OnProcessLaunchFailed(int error_code) {}; |
| 64 | 64 |
| 65 protected: | 65 protected: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 std::unique_ptr<mojo::edk::OutgoingBrokerClientInvitation> | 165 std::unique_ptr<mojo::edk::OutgoingBrokerClientInvitation> |
| 166 broker_client_invitation_; | 166 broker_client_invitation_; |
| 167 const mojo::edk::ProcessErrorCallback process_error_callback_; | 167 const mojo::edk::ProcessErrorCallback process_error_callback_; |
| 168 | 168 |
| 169 // Controls whether the child process should be terminated on browser | 169 // Controls whether the child process should be terminated on browser |
| 170 // shutdown. Default behavior is to terminate the child. | 170 // shutdown. Default behavior is to terminate the child. |
| 171 const bool terminate_child_on_shutdown_; | 171 const bool terminate_child_on_shutdown_; |
| 172 | 172 |
| 173 scoped_refptr<internal::ChildProcessLauncherHelper> helper_; | 173 scoped_refptr<internal::ChildProcessLauncherHelper> helper_; |
| 174 | 174 |
| 175 SEQUENCE_CHECKER(sequence_checker_); |
| 176 |
| 175 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; | 177 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; |
| 176 | 178 |
| 177 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); | 179 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
| 178 }; | 180 }; |
| 179 | 181 |
| 180 } // namespace content | 182 } // namespace content |
| 181 | 183 |
| 182 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 184 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
| OLD | NEW |