OLD | NEW |
---|---|
(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_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ | |
6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ | |
7 | |
8 #include "base/files/file_path.h" | |
9 #include "content/public/browser/browser_context.h" | |
10 #include "content/public/browser/content_browser_client.h" | |
11 #include "content/public/browser/resource_context.h" | |
12 #include "headless/lib/browser/headless_url_request_context_getter.h" | |
13 #include "headless/public/headless_browser.h" | |
14 | |
15 namespace headless { | |
16 | |
17 class HeadlessBrowserContext : public content::BrowserContext { | |
18 public: | |
19 HeadlessBrowserContext(const HeadlessBrowser::Options& options); | |
20 ~HeadlessBrowserContext() override; | |
21 | |
22 // BrowserContext implementation | |
alex clarke (OOO till 29th)
2016/02/10 13:20:33
nit: Doesn't this usually end with a : ?
Sami
2016/02/10 16:43:32
Done. Tried to be more consistent about this. Unfo
| |
23 scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( | |
24 const base::FilePath& partition_path) override; | |
25 base::FilePath GetPath() const override; | |
26 bool IsOffTheRecord() const override; | |
27 net::URLRequestContextGetter* GetRequestContext() override; | |
28 net::URLRequestContextGetter* GetRequestContextForRenderProcess( | |
29 int renderer_child_id) override; | |
30 net::URLRequestContextGetter* GetMediaRequestContext() override; | |
31 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( | |
32 int renderer_child_id) override; | |
33 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition( | |
34 const base::FilePath& partition_path, | |
35 bool in_memory) override; | |
36 content::ResourceContext* GetResourceContext() override; | |
37 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; | |
38 content::BrowserPluginGuestManager* GetGuestManager() override; | |
39 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; | |
40 content::PushMessagingService* GetPushMessagingService() override; | |
41 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; | |
42 content::PermissionManager* GetPermissionManager() override; | |
43 content::BackgroundSyncController* GetBackgroundSyncController() override; | |
44 | |
45 net::URLRequestContextGetter* CreateRequestContext( | |
alex clarke (OOO till 29th)
2016/02/10 13:20:33
Please document the ownership of the pointer retur
Sami
2016/02/10 16:43:33
Done.
| |
46 content::ProtocolHandlerMap* protocol_handlers, | |
47 content::URLRequestInterceptorScopedVector request_interceptors); | |
48 | |
49 const HeadlessBrowser::Options& options() const { return options_; } | |
50 | |
51 private: | |
52 // Contains net::URLRequestContextGetter required for resource loading. | |
53 class HeadlessResourceContext : public content::ResourceContext { | |
54 public: | |
55 HeadlessResourceContext(); | |
56 ~HeadlessResourceContext() override; | |
57 | |
58 // ResourceContext implementation: | |
59 net::HostResolver* GetHostResolver() override; | |
60 net::URLRequestContext* GetRequestContext() override; | |
61 | |
62 void set_url_request_context_getter(net::URLRequestContextGetter* getter) { | |
63 getter_ = getter; | |
64 } | |
65 | |
66 private: | |
67 net::URLRequestContextGetter* getter_; | |
alex clarke (OOO till 29th)
2016/02/10 13:20:33
please document ownership of getter_
Sami
2016/02/10 16:43:32
Done.
| |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(HeadlessResourceContext); | |
70 }; | |
71 | |
72 // Used by HeadlessBrowserContext to initiate and set different types of | |
73 // URLRequestContextGetter. | |
74 virtual HeadlessURLRequestContextGetter* CreateURLRequestContextGetter( | |
75 content::ProtocolHandlerMap* protocol_handlers, | |
alex clarke (OOO till 29th)
2016/02/10 13:20:33
Does this take ownership of |protocol_handlers|?
Sami
2016/02/10 16:43:32
No, although it does clear it :\ Added a commment.
| |
76 content::URLRequestInterceptorScopedVector request_interceptors); | |
77 | |
78 void set_url_request_context_getter(HeadlessURLRequestContextGetter* getter) { | |
alex clarke (OOO till 29th)
2016/02/10 13:20:33
This takes ownership of getter should we pass in a
Sami
2016/02/10 16:43:33
Done (refptr).
| |
79 url_request_getter_ = getter; | |
80 } | |
81 | |
82 // Performs initialization of the HeadlessBrowserContext while IO is still | |
83 // allowed on the current thread. | |
84 void InitWhileIOAllowed(); | |
85 | |
86 base::FilePath path_; | |
87 scoped_ptr<HeadlessResourceContext> resource_context_; | |
88 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; | |
89 HeadlessBrowser::Options options_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext); | |
92 }; | |
93 | |
94 } // namespace headless | |
95 | |
96 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ | |
OLD | NEW |