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

Unified Diff: headless/public/headless_browser.h

Issue 1674263002: headless: Initial headless embedder API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added navigation test. Created 4 years, 10 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: headless/public/headless_browser.h
diff --git a/headless/public/headless_browser.h b/headless/public/headless_browser.h
index a94a90c7541df50567bad71262beff2b6aa2d40c..e1da59d1162ec6bc529d28e0ff8b812734b4c959 100644
--- a/headless/public/headless_browser.h
+++ b/headless/public/headless_browser.h
@@ -5,13 +5,17 @@
#ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
#define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
+#include <string>
+
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "headless/public/headless_export.h"
+#include "net/url_request/url_request_context_getter.h"
namespace base {
+class MessagePump;
class SingleThreadTaskRunner;
namespace trace_event {
@@ -28,22 +32,21 @@ class URLRequestContextGetter;
}
namespace headless {
-class WebContents;
+class HeadlessWebContents;
class HEADLESS_EXPORT HeadlessBrowser {
public:
- static HeadlessBrowser* Get();
-
struct Options;
// Main routine for running browser.
// Takes command line args and callback to run as soon as browser starts.
- static int Run(
- const Options& options,
- const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback);
+ using StartCallback = base::Callback<void(HeadlessBrowser*)>;
+ static int Run(const Options& options,
+ const StartCallback& on_browser_start_callback);
- // Create a new browser tab.
- virtual scoped_ptr<WebContents> CreateWebContents(const gfx::Size& size) = 0;
+ // Create a new browser tab. |size| is in physical pixels.
+ virtual scoped_ptr<HeadlessWebContents> CreateWebContents(
+ const gfx::Size& size) = 0;
virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() = 0;
virtual scoped_refptr<base::SingleThreadTaskRunner> RendererMainThread() = 0;
@@ -58,12 +61,14 @@ class HEADLESS_EXPORT HeadlessBrowser {
const base::Closure& on_tracing_stopped) = 0;
protected:
+ HeadlessBrowser() {}
virtual ~HeadlessBrowser() {}
private:
DISALLOW_COPY_AND_ASSIGN(HeadlessBrowser);
};
+// Embedding API overrides for the headless browser.
struct HeadlessBrowser::Options {
~Options();
@@ -77,19 +82,20 @@ struct HeadlessBrowser::Options {
std::string navigator_platform;
static const int kInvalidPort = -1;
- // If not null, create start devtools for remote debugging
- // on specified port.
int devtools_http_port;
- // Optional URLRequestContextGetter for customizing network stack.
- // Allows overriding:
+ // Optional URLRequestContextGetter for customizing network stack. Allows
+ // overriding, e.g.:
// - Cookie storage
// - HTTP cache
// - SSL config
// - Proxy service
+ //
+ // See HeadlessNetwork for more details.
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter;
- scoped_ptr<base::MessagePump> message_pump;
+ // Optional message pump that overrides the default. Must outlive the browser.
+ base::MessagePump* message_pump;
private:
Options(int argc, const char** argv);
@@ -104,6 +110,7 @@ class HeadlessBrowser::Options::Builder {
Builder& EnableDevToolsServer(int port);
Builder& SetURLRequestContextGetter(
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
+ Builder& SetMessagePump(base::MessagePump* message_pump);
Options Build();

Powered by Google App Engine
This is Rietveld 408576698