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

Side by Side Diff: headless/public/headless_browser.h

Issue 1461693003: [headless] Initial skeleton of headless/public/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes Created 5 years 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/BUILD.gn ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "headless/public/headless_export.h"
13
14 namespace base {
15 class SingleThreadTaskRunner;
16
17 namespace trace_event {
18 class TraceConfig;
19 }
20 }
21
22 namespace gfx {
23 class Size;
24 }
25
26 namespace net {
27 class URLRequestContextGetter;
28 }
29
30 namespace headless {
31 class WebContents;
32
33 class HEADLESS_EXPORT HeadlessBrowser {
34 public:
35 static HeadlessBrowser* Get();
36
37 struct Options;
38
39 // Main routine for running browser.
40 // Takes command line args and callback to run as soon as browser starts.
41 static int Run(
42 const Options& options,
43 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback);
44
45 // Create a new browser tab.
46 virtual scoped_ptr<WebContents> CreateWebContents(const gfx::Size& size) = 0;
47
48 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() = 0;
49 virtual scoped_refptr<base::SingleThreadTaskRunner> RendererMainThread() = 0;
50
51 // Requests browser to stop as soon as possible.
52 // |Run| will return as soon as browser stops.
53 virtual void Stop() = 0;
54
55 virtual void StartTracing(const base::trace_event::TraceConfig& trace_config,
56 const base::Closure& on_tracing_started) = 0;
57 virtual void StopTracing(const std::string& log_file_name,
58 const base::Closure& on_tracing_stopped) = 0;
59
60 protected:
61 virtual ~HeadlessBrowser() {}
62
63 private:
64 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowser);
65 };
66
67 struct HeadlessBrowser::Options {
68 Options(Options&&);
alex clarke (OOO till 29th) 2015/12/01 20:07:30 Do we actually need an explicit move and assignmen
altimin 2015/12/02 12:44:07 Thanks for the remark. The reason behind explicit
69 Options& operator=(Options&&) = default;
70 ~Options();
71
72 class Builder;
73
74 // Command line options to be passed to browser.
75 int argc;
76 const char** argv;
77
78 std::string user_agent;
79
80 static const int kInvalidPort = -1;
81 // If not null, create start devtools for remote debugging
82 // on specified port.
83 int devtools_http_port;
84
85 // Optional URLRequestContextGetter for customizing network stack.
86 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter;
87
88 private:
89 Options(int argc, const char** argv);
90
91 DISALLOW_COPY_AND_ASSIGN(Options);
alex clarke (OOO till 29th) 2015/12/01 20:07:30 It feels a bit odd to use this macro and also defi
altimin 2015/12/02 12:44:07 Done.
92 };
93
94 class HeadlessBrowser::Options::Builder {
95 public:
96 Builder(int argc, const char** argv);
97 ~Builder();
98
99 Builder& SetUserAgent(const std::string& user_agent);
100 Builder& EnableDevToolsServer(int port);
101 Builder& SetURLRequestContextGetter(
102 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
103
104 Options Build();
105
106 private:
107 Options options_;
108
109 DISALLOW_COPY_AND_ASSIGN(Builder);
Sami 2015/12/02 13:37:14 Is there a reason we couldn't keep this?
altimin 2015/12/02 13:43:41 My bad, I wanted to remove this from Options.
110 };
111
112 } // namespace headless
113
114 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
OLDNEW
« no previous file with comments | « headless/BUILD.gn ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698