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

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: Remove direct dom interaction 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
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/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "headless/public/headless_export.h"
12
13 namespace base {
14 class SingleThreadTaskRunner;
15
16 namespace trace_event {
17 class TraceConfig;
18 }
19 }
20
21 namespace gfx {
22 class Size;
23 }
24
25 namespace net {
26 class URLRequestContextGetter;
27 }
28
29 namespace headless {
30 class WebContents;
31
32 class HEADLESS_EXPORT HeadlessBrowser {
33 public:
34 static HeadlessBrowser* Get();
35
36 struct Options;
37
38 // Create a new browser tab.
39 virtual scoped_ptr<WebContents> CreateWebContents(const gfx::Size& size) = 0;
Sami 2015/12/01 14:03:57 Which of these methods are safe to call before ent
altimin 2015/12/01 15:17:29 Great idea. Done.
40
41 virtual scoped_refptr<base::SingleThreadTaskRunner> browser_main_thread() = 0;
42 virtual scoped_refptr<base::SingleThreadTaskRunner>
43 renderer_main_thread() = 0;
44
45 // Main routine for running browser.
46 // Takes command line args and callback to run as soon as browser starts.
47 // Should be called from main in the following manner:
48 // int main(int argc, const char** argv) {
49 // return headless::HeadlessBrowser::Get()->Run(
50 // argc, argv, base::Bind(function_to_be_run_on_browser_start));
Sami 2015/12/01 14:03:57 This comment looks out of date. We could move the
altimin 2015/12/01 15:17:28 Done.
51 // }
52 virtual int Run(const Options& options,
53 const base::Closure& on_browser_start_callback) = 0;
54
55 // Requests browser to stop as soon as possible.
Sami 2015/12/01 14:03:57 Might want to mention that this causes |Run| to re
altimin 2015/12/01 15:17:29 Done.
56 virtual void Stop() = 0;
57
58 virtual void StartTracing(const base::trace_event::TraceConfig& trace_config,
59 const base::Closure& tracing_started) = 0;
Sami 2015/12/01 14:03:57 Let's name callbacks consistently: either everythi
altimin 2015/12/01 15:17:28 Done.
60 virtual void StopTracing(const std::string& log_file_name,
61 const base::Closure& tracing_stopped) = 0;
62
63 protected:
64 virtual ~HeadlessBrowser() {}
Sami 2015/12/01 14:03:57 DISALLOW_COPY_AND_ASSIGN
altimin 2015/12/01 15:17:28 Done.
65 };
66
67 struct HeadlessBrowser::Options {
68 Options(Options&&);
Sami 2015/12/01 14:03:57 Missing a move assignment operator.
altimin 2015/12/01 15:17:29 Done.
69 ~Options();
70
71 class Builder;
72
73 // Command line options to be passed to browser.
74 int argc;
75 const char** argv;
76
77 scoped_ptr<std::string> user_agent;
Sami 2015/12/01 14:03:57 Can we make this a regular string that's initializ
altimin 2015/12/01 15:17:28 Done.
78
79 // If not null, create start devtools for remote debugging
Sami 2015/12/01 14:03:57 A heap allocation seems overkill here. Could we ma
altimin 2015/12/01 15:17:28 Done.
80 // on specified port.
81 scoped_ptr<int> devtools_http_port;
82
83 // Using URLRequestContextGetter we can provide our own implementation of
Sami 2015/12/01 14:03:57 nit: instead of talking about 'we' (who?) how abou
altimin 2015/12/01 15:17:29 Done.
84 // entire network stack.
85 // If null, default Chromium network settings will be used.
86 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter;
87
88 private:
89 Options(int argc, const char** argv);
Sami 2015/12/01 14:03:57 DISALLOW_COPY_AND_ASSIGN? Not sure how that intera
altimin 2015/12/01 15:17:29 Done.
90 };
91
92 class HeadlessBrowser::Options::Builder {
93 public:
94 Builder(int argc, const char** argv);
95 ~Builder();
96
97 Builder& SetUserAgent(const std::string& user_agent);
98 Builder& EnableDevtoolsServer(int port);
Sami 2015/12/01 14:03:57 s/Devtools/DevTools/
altimin 2015/12/01 15:17:29 Done.
99 Builder& SetURLRequestContextGetter(
100 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
101
102 Options Build();
103
104 private:
105 Options options_;
106 };
Sami 2015/12/01 14:03:57 DISALLOW_COPY_AND_ASSIGN
altimin 2015/12/01 15:17:29 Done.
107
108 } // namespace headless
109
110 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698