OLD | NEW |
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 <string> | 9 #include <string> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "headless/public/headless_export.h" | 14 #include "headless/public/headless_export.h" |
15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class MessagePump; | 19 class MessagePump; |
20 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
21 } | 21 } |
22 | 22 |
23 namespace gfx { | 23 namespace gfx { |
24 class Size; | 24 class Size; |
25 } | 25 } |
26 | 26 |
27 namespace headless { | 27 namespace headless { |
28 class HeadlessWebContents; | 28 class HeadlessWebContents; |
29 | 29 |
30 // This class represents the global headless browser instance. To get a pointer | 30 // This class represents the global headless browser instance. To get a pointer |
31 // to one, call |HeadlessBrowserMain| to initiate the browser main loop. An | 31 // to one, call |HeadlessBrowserMain| to initiate the browser main loop. An |
32 // instance of |HeadlessBrowser| will be passed to the callback given to that | 32 // instance of |HeadlessBrowser| will be passed to the callback given to that |
33 // function. | 33 // function. |
34 class HEADLESS_EXPORT HeadlessBrowser { | 34 class HEADLESS_EXPORT HeadlessBrowser { |
35 public: | 35 public: |
36 struct Options; | 36 struct Options; |
37 | 37 |
38 // Create a new browser tab. |size| is in physical pixels. | 38 // Create a new browser tab. |size| is in physical pixels. |
39 virtual scoped_ptr<HeadlessWebContents> CreateWebContents( | 39 virtual std::unique_ptr<HeadlessWebContents> CreateWebContents( |
40 const gfx::Size& size) = 0; | 40 const gfx::Size& size) = 0; |
41 | 41 |
42 // Returns a task runner for submitting work to the browser main thread. | 42 // Returns a task runner for submitting work to the browser main thread. |
43 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() | 43 virtual scoped_refptr<base::SingleThreadTaskRunner> BrowserMainThread() |
44 const = 0; | 44 const = 0; |
45 | 45 |
46 // Requests browser to stop as soon as possible. |Run| will return as soon as | 46 // Requests browser to stop as soon as possible. |Run| will return as soon as |
47 // browser stops. | 47 // browser stops. |
48 virtual void Shutdown() = 0; | 48 virtual void Shutdown() = 0; |
49 | 49 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // |on_browser_start_callback| callback. Note that since this function executes | 107 // |on_browser_start_callback| callback. Note that since this function executes |
108 // the main loop, it will only return after HeadlessBrowser::Shutdown() is | 108 // the main loop, it will only return after HeadlessBrowser::Shutdown() is |
109 // called, returning the exit code for the process. | 109 // called, returning the exit code for the process. |
110 int HeadlessBrowserMain( | 110 int HeadlessBrowserMain( |
111 const HeadlessBrowser::Options& options, | 111 const HeadlessBrowser::Options& options, |
112 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); | 112 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); |
113 | 113 |
114 } // namespace headless | 114 } // namespace headless |
115 | 115 |
116 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 116 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
OLD | NEW |