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

Unified Diff: headless/public/headless_browser.h

Issue 2081423004: headless: Add a dedicated child process entrypoint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneccessary include Created 4 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
« no previous file with comments | « headless/lib/browser/headless_browser_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/headless_browser.h
diff --git a/headless/public/headless_browser.h b/headless/public/headless_browser.h
index d3db68d21f1638bcdf4264f0b4e5f015a8d5f781..1711dc0da2df3d5056c8c54f94e5761872d3477d 100644
--- a/headless/public/headless_browser.h
+++ b/headless/public/headless_browser.h
@@ -145,11 +145,33 @@ class HeadlessBrowser::Options::Builder {
DISALLOW_COPY_AND_ASSIGN(Builder);
};
+// The headless browser may need to create child processes (e.g., a renderer
+// which runs web content). This is done by re-executing the parent process as
+// a zygote[1] and forking each child process from that zygote.
+//
+// For this to work, the embedder should call RunChildProcess as soon as
+// possible (i.e., before creating any threads) to pass control to the headless
+// library. In a browser process this function will return immediately, but in a
+// child process it will never return. For example:
+//
+// int main(int argc, const char** argv) {
+// headless::RunChildProcessIfNeeded(argc, argv);
+// headless::HeadlessBrowser::Options::Builder builder(argc, argv);
+// return headless::HeadlessBrowserMain(
+// builder.Build(),
+// base::Callback<void(headless::HeadlessBrowser*)>());
+// }
+//
+// [1]
+// https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote.md
+void RunChildProcessIfNeeded(int argc, const char** argv);
+
// Main entry point for running the headless browser. This function constructs
// the headless browser instance, passing it to the given
// |on_browser_start_callback| callback. Note that since this function executes
// the main loop, it will only return after HeadlessBrowser::Shutdown() is
-// called, returning the exit code for the process.
+// called, returning the exit code for the process. It is not possible to
+// initialize the browser again after it has been torn down.
int HeadlessBrowserMain(
HeadlessBrowser::Options options,
const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback);
« no previous file with comments | « headless/lib/browser/headless_browser_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698