Chromium Code Reviews| Index: content/browser/child_process_launcher.h |
| diff --git a/content/browser/child_process_launcher.h b/content/browser/child_process_launcher.h |
| index 7ce780551f462f9c458b730b9ed0ef3a1cadd03c..2fffd2cd2b25b07453351df461a702bc47527b77 100644 |
| --- a/content/browser/child_process_launcher.h |
| +++ b/content/browser/child_process_launcher.h |
| @@ -21,12 +21,17 @@ class SandboxedProcessLauncherDelegate; |
| // on the OS since often it can take > 100 ms to create the process. |
| class CONTENT_EXPORT ChildProcessLauncher { |
| public: |
| + // An interface for receiving callbacks with process-launching status. Will |
| + // be called on the thread that the ChildProcessLauncher was constructed on. |
| + // Note that only OnProcessLaunched is required. |
| class CONTENT_EXPORT Client { |
| public: |
| - // Will be called on the thread that the ChildProcessLauncher was |
| - // constructed on. |
| + // Called when the process is launched. |
| virtual void OnProcessLaunched() = 0; |
| + // Called if an error occurs launching the process. |
| + virtual void OnProcessLaunchFailure() {}; |
| + |
| protected: |
| virtual ~Client() {} |
| }; |
| @@ -36,24 +41,14 @@ class CONTENT_EXPORT ChildProcessLauncher { |
| // the callback won't be called. If the process is still running by the time |
| // this object destructs, it will be terminated. |
|
mef
2014/01/17 16:57:06
I think this comment is out of date, especially re
Drew Haven
2014/01/22 23:14:25
Right. This is an interface now, so it doesn't ta
|
| // Takes ownership of cmd_line. |
| - ChildProcessLauncher( |
| -#if defined(OS_WIN) |
| - SandboxedProcessLauncherDelegate* delegate, |
| -#elif defined(OS_POSIX) |
| - bool use_zygote, |
| - const base::EnvironmentMap& environ, |
| - int ipcfd, |
| -#endif |
| - CommandLine* cmd_line, |
| - int child_process_id, |
| - Client* client); |
| - ~ChildProcessLauncher(); |
| + ChildProcessLauncher() {}; |
| + virtual ~ChildProcessLauncher() {}; |
| // True if the process is being launched and so the handle isn't available. |
| - bool IsStarting(); |
| + virtual bool IsStarting() = 0; |
| // Getter for the process handle. Only call after the process has started. |
| - base::ProcessHandle GetHandle(); |
| + virtual base::ProcessHandle GetHandle() = 0; |
| // Call this when the child process exits to know what happened to it. |
| // |known_dead| can be true if we already know the process is dead as it can |
| @@ -66,22 +61,39 @@ class CONTENT_EXPORT ChildProcessLauncher { |
| // |exit_code| is the exit code of the process if it exited (e.g. status from |
| // waitpid if on posix, from GetExitCodeProcess on Windows). |exit_code| may |
| // be NULL. |
| - base::TerminationStatus GetChildTerminationStatus(bool known_dead, |
| - int* exit_code); |
| + virtual base::TerminationStatus GetChildTerminationStatus(bool known_dead, |
| + int* exit_code) = 0; |
| // Changes whether the process runs in the background or not. Only call |
| // this after the process has started. |
| - void SetProcessBackgrounded(bool background); |
| + virtual void SetProcessBackgrounded(bool background) = 0; |
| // Controls whether the child process should be terminated on browser |
| // shutdown. |
| - void SetTerminateChildOnShutdown(bool terminate_on_shutdown); |
| + virtual void SetTerminateChildOnShutdown(bool terminate_on_shutdown) = 0; |
| - private: |
| - class Context; |
| + // Create a standard ChildProcessLauncher. |
| + static ChildProcessLauncher* Create( |
| +#if defined(OS_WIN) |
| + SandboxedProcessLauncherDelegate* delegate, |
| +#elif defined(OS_POSIX) |
| + bool use_zygote, |
| + const base::EnvironmentMap& environ, |
| + int ipcfd, |
| +#endif |
| + CommandLine* cmd_line, |
| + int child_process_id, |
| + Client* client); |
| - scoped_refptr<Context> context_; |
| +#if defined(OS_WIN) |
| + // Create a ChildProcessLauncher that attempts to create an elevated process. |
| + static ChildProcessLauncher* CreateElevated( |
| + CommandLine* cmd_line, |
| + int child_process_id, |
| + Client* client); |
| +#endif |
| + private: |
| DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
| }; |