OLD | NEW |
1 // Copyright 2013 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 CONTENT_SHELL_BROWSER_SHELL_URL_REQUEST_CONTEXT_GETTER_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_URL_REQUEST_CONTEXT_GETTER_H_ |
6 #define CONTENT_SHELL_BROWSER_SHELL_URL_REQUEST_CONTEXT_GETTER_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_URL_REQUEST_CONTEXT_GETTER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
| 14 #include "headless/public/headless_browser.h" |
14 #include "net/proxy/proxy_config_service.h" | 15 #include "net/proxy/proxy_config_service.h" |
15 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
16 #include "net/url_request/url_request_job_factory.h" | 17 #include "net/url_request/url_request_job_factory.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class MessageLoop; | 20 class MessageLoop; |
20 } | 21 } |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 class HostResolver; | 24 class HostResolver; |
24 class MappedHostResolver; | 25 class MappedHostResolver; |
25 class NetworkDelegate; | 26 class NetworkDelegate; |
26 class NetLog; | 27 class NetLog; |
27 class ProxyConfigService; | 28 class ProxyConfigService; |
28 class ProxyService; | 29 class ProxyService; |
29 class URLRequestContextStorage; | 30 class URLRequestContextStorage; |
30 } | 31 } |
31 | 32 |
32 namespace content { | 33 namespace headless { |
33 | 34 |
34 class ShellURLRequestContextGetter : public net::URLRequestContextGetter { | 35 class HeadlessURLRequestContextGetter : public net::URLRequestContextGetter { |
35 public: | 36 public: |
36 ShellURLRequestContextGetter( | 37 HeadlessURLRequestContextGetter( |
37 bool ignore_certificate_errors, | 38 bool ignore_certificate_errors, |
38 const base::FilePath& base_path, | 39 const base::FilePath& base_path, |
39 base::MessageLoop* io_loop, | 40 base::MessageLoop* io_loop, |
40 base::MessageLoop* file_loop, | 41 base::MessageLoop* file_loop, |
41 ProtocolHandlerMap* protocol_handlers, | 42 content::ProtocolHandlerMap* protocol_handlers, |
42 URLRequestInterceptorScopedVector request_interceptors, | 43 content::URLRequestInterceptorScopedVector request_interceptors, |
43 net::NetLog* net_log); | 44 net::NetLog* net_log, |
| 45 const HeadlessBrowser::Options& options); |
44 | 46 |
45 // net::URLRequestContextGetter implementation. | 47 // net::URLRequestContextGetter implementation: |
46 net::URLRequestContext* GetURLRequestContext() override; | 48 net::URLRequestContext* GetURLRequestContext() override; |
47 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 49 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
48 const override; | 50 const override; |
49 | 51 |
50 net::HostResolver* host_resolver(); | 52 net::HostResolver* host_resolver() const; |
51 | 53 |
52 protected: | 54 protected: |
53 ~ShellURLRequestContextGetter() override; | 55 ~HeadlessURLRequestContextGetter() override; |
54 | 56 |
55 // Used by subclasses to create their own implementation of NetworkDelegate | 57 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate(); |
56 // and net::ProxyService. | 58 scoped_ptr<net::ProxyConfigService> GetProxyConfigService(); |
57 virtual scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate(); | 59 scoped_ptr<net::ProxyService> GetProxyService(); |
58 virtual scoped_ptr<net::ProxyConfigService> GetProxyConfigService(); | |
59 virtual scoped_ptr<net::ProxyService> GetProxyService(); | |
60 | 60 |
61 private: | 61 private: |
62 bool ignore_certificate_errors_; | 62 bool ignore_certificate_errors_; |
63 base::FilePath base_path_; | 63 base::FilePath base_path_; |
64 base::MessageLoop* io_loop_; | 64 base::MessageLoop* io_loop_; |
65 base::MessageLoop* file_loop_; | 65 base::MessageLoop* file_loop_; |
66 net::NetLog* net_log_; | 66 net::NetLog* net_log_; |
| 67 HeadlessBrowser::Options options_; |
67 | 68 |
68 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | 69 scoped_ptr<net::ProxyConfigService> proxy_config_service_; |
69 scoped_ptr<net::NetworkDelegate> network_delegate_; | 70 scoped_ptr<net::NetworkDelegate> network_delegate_; |
70 scoped_ptr<net::URLRequestContextStorage> storage_; | 71 scoped_ptr<net::URLRequestContextStorage> storage_; |
71 scoped_ptr<net::URLRequestContext> url_request_context_; | 72 scoped_ptr<net::URLRequestContext> url_request_context_; |
72 ProtocolHandlerMap protocol_handlers_; | 73 content::ProtocolHandlerMap protocol_handlers_; |
73 URLRequestInterceptorScopedVector request_interceptors_; | 74 content::URLRequestInterceptorScopedVector request_interceptors_; |
74 | 75 |
75 DISALLOW_COPY_AND_ASSIGN(ShellURLRequestContextGetter); | 76 DISALLOW_COPY_AND_ASSIGN(HeadlessURLRequestContextGetter); |
76 }; | 77 }; |
77 | 78 |
78 } // namespace content | 79 } // namespace headless |
79 | 80 |
80 #endif // CONTENT_SHELL_BROWSER_SHELL_URL_REQUEST_CONTEXT_GETTER_H_ | 81 #endif // HEADLESS_LIB_BROWSER_HEADLESS_URL_REQUEST_CONTEXT_GETTER_H_ |
OLD | NEW |