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