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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « headless/lib/browser/headless_browser_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ 5 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ 6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 Builder& SetProtocolHandlers(ProtocolHandlerMap protocol_handlers); 138 Builder& SetProtocolHandlers(ProtocolHandlerMap protocol_handlers);
139 139
140 Options Build(); 140 Options Build();
141 141
142 private: 142 private:
143 Options options_; 143 Options options_;
144 144
145 DISALLOW_COPY_AND_ASSIGN(Builder); 145 DISALLOW_COPY_AND_ASSIGN(Builder);
146 }; 146 };
147 147
148 // The headless browser may need to create child processes (e.g., a renderer
149 // which runs web content). This is done by re-executing the parent process as
150 // a zygote[1] and forking each child process from that zygote.
151 //
152 // For this to work, the embedder should call RunChildProcess as soon as
153 // possible (i.e., before creating any threads) to pass control to the headless
154 // library. In a browser process this function will return immediately, but in a
155 // child process it will never return. For example:
156 //
157 // int main(int argc, const char** argv) {
158 // headless::RunChildProcessIfNeeded(argc, argv);
159 // headless::HeadlessBrowser::Options::Builder builder(argc, argv);
160 // return headless::HeadlessBrowserMain(
161 // builder.Build(),
162 // base::Callback<void(headless::HeadlessBrowser*)>());
163 // }
164 //
165 // [1]
166 // https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote.md
167 void RunChildProcessIfNeeded(int argc, const char** argv);
168
148 // Main entry point for running the headless browser. This function constructs 169 // Main entry point for running the headless browser. This function constructs
149 // the headless browser instance, passing it to the given 170 // the headless browser instance, passing it to the given
150 // |on_browser_start_callback| callback. Note that since this function executes 171 // |on_browser_start_callback| callback. Note that since this function executes
151 // the main loop, it will only return after HeadlessBrowser::Shutdown() is 172 // the main loop, it will only return after HeadlessBrowser::Shutdown() is
152 // called, returning the exit code for the process. 173 // called, returning the exit code for the process. It is not possible to
174 // initialize the browser again after it has been torn down.
153 int HeadlessBrowserMain( 175 int HeadlessBrowserMain(
154 HeadlessBrowser::Options options, 176 HeadlessBrowser::Options options,
155 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); 177 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback);
156 178
157 } // namespace headless 179 } // namespace headless
158 180
159 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ 181 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
OLDNEW
« 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