Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1266)

Unified Diff: content/browser/child_process_launcher.h

Issue 16267002: Re-fix http://crbug.com/87176, and add a test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Second round of creis comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_launcher.h
diff --git a/content/browser/child_process_launcher.h b/content/browser/child_process_launcher.h
index f1c8f0df0f4ad178d08c970e565ec51d21069a16..d9aa3a75e4720e0a38e71e9c09a1eebea9ad420c 100644
--- a/content/browser/child_process_launcher.h
+++ b/content/browser/child_process_launcher.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/process_util.h"
#include "content/common/content_export.h"
@@ -18,6 +19,9 @@ class SandboxedProcessLauncherDelegate;
// Launches a process asynchronously and notifies the client of the process
// handle when it's available. It's used to avoid blocking the calling thread
// on the OS since often it can take > 100 ms to create the process.
+//
+// Call NewChildProcessLauncher to get the default implementation,
+// which launches a real process.
class CONTENT_EXPORT ChildProcessLauncher {
public:
class CONTENT_EXPORT Client {
@@ -30,29 +34,13 @@ class CONTENT_EXPORT ChildProcessLauncher {
virtual ~Client() {}
};
- // Launches the process asynchronously, calling the client when the result is
- // ready. Deleting this object before the process is created is safe, since
- // the callback won't be called. If the process is still running by the time
- // this object destructs, it will be terminated.
- // Takes ownership of cmd_line.
- ChildProcessLauncher(
-#if defined(OS_WIN)
- SandboxedProcessLauncherDelegate* delegate,
-#elif defined(OS_POSIX)
- bool use_zygote,
- const base::EnvironmentVector& environ,
- int ipcfd,
-#endif
- CommandLine* cmd_line,
- int child_process_id,
- Client* client);
- ~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
@@ -60,25 +48,35 @@ 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);
-
- private:
- class Context;
-
- scoped_refptr<Context> context_;
-
- DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher);
+ virtual void SetTerminateChildOnShutdown(bool terminate_on_shutdown) = 0;
};
+// Launches the process asynchronously, calling the client when the result is
+// ready. Deleting this object before the process is created is safe, since
+// the callback won't be called. If the process is still running by the time
+// this object destructs, it will be terminated.
+// Takes ownership of cmd_line.
+scoped_ptr<ChildProcessLauncher> NewChildProcessLauncher(
+#if defined(OS_WIN)
+ SandboxedProcessLauncherDelegate* delegate,
+#elif defined(OS_POSIX)
+ bool use_zygote,
+ const base::EnvironmentVector& environ,
+ int ipcfd,
+#endif
+ CommandLine* cmd_line,
+ int child_process_id,
+ ChildProcessLauncher::Client* client);
+
} // namespace content
#endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_

Powered by Google App Engine
This is Rietveld 408576698