| 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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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: |
| 66 virtual ~Client() {} | 66 virtual ~Client() {} |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 enum { DEFAULT_PARAM_ID = 0 }; |
| 70 |
| 69 // Launches the process asynchronously, calling the client when the result is | 71 // Launches the process asynchronously, calling the client when the result is |
| 70 // ready. Deleting this object before the process is created is safe, since | 72 // ready. Deleting this object before the process is created is safe, since |
| 71 // the callback won't be called. If the process is still running by the time | 73 // the callback won't be called. If the process is still running by the time |
| 72 // this object destructs, it will be terminated. | 74 // this object destructs, it will be terminated. |
| 73 // Takes ownership of cmd_line. | 75 // Takes ownership of cmd_line. |
| 74 // | 76 // |
| 75 // If |process_error_callback| is provided, it will be called if a Mojo error | 77 // If |process_error_callback| is provided, it will be called if a Mojo error |
| 76 // is encountered when processing messages from the child process. This | 78 // is encountered when processing messages from the child process. This |
| 77 // callback must be safe to call from any thread. | 79 // callback must be safe to call from any thread. |
| 78 ChildProcessLauncher( | 80 ChildProcessLauncher( |
| 79 std::unique_ptr<SandboxedProcessLauncherDelegate> delegate, | 81 std::unique_ptr<SandboxedProcessLauncherDelegate> delegate, |
| 80 std::unique_ptr<base::CommandLine> cmd_line, | 82 std::unique_ptr<base::CommandLine> cmd_line, |
| 81 int child_process_id, | 83 int child_process_id, |
| 82 Client* client, | 84 Client* client, |
| 83 std::unique_ptr<mojo::edk::PendingProcessConnection> pending_connection, | 85 std::unique_ptr<mojo::edk::PendingProcessConnection> pending_connection, |
| 84 const mojo::edk::ProcessErrorCallback& process_error_callback, | 86 const mojo::edk::ProcessErrorCallback& process_error_callback, |
| 85 bool terminate_on_shutdown = true); | 87 bool terminate_on_shutdown = true, |
| 88 int param_id = DEFAULT_PARAM_ID); |
| 86 ~ChildProcessLauncher(); | 89 ~ChildProcessLauncher(); |
| 87 | 90 |
| 88 // True if the process is being launched and so the handle isn't available. | 91 // True if the process is being launched and so the handle isn't available. |
| 89 bool IsStarting(); | 92 bool IsStarting(); |
| 90 | 93 |
| 91 // Getter for the process. Only call after the process has started. | 94 // Getter for the process. Only call after the process has started. |
| 92 const base::Process& GetProcess() const; | 95 const base::Process& GetProcess() const; |
| 93 | 96 |
| 94 // Call this when the child process exits to know what happened to it. | 97 // Call this when the child process exits to know what happened to it. |
| 95 // |known_dead| can be true if we already know the process is dead as it can | 98 // |known_dead| can be true if we already know the process is dead as it can |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 scoped_refptr<internal::ChildProcessLauncherHelper> helper_; | 165 scoped_refptr<internal::ChildProcessLauncherHelper> helper_; |
| 163 | 166 |
| 164 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; | 167 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; |
| 165 | 168 |
| 166 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); | 169 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
| 167 }; | 170 }; |
| 168 | 171 |
| 169 } // namespace content | 172 } // namespace content |
| 170 | 173 |
| 171 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 174 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
| OLD | NEW |