Index: headless/lib/browser/headless_browser_context.h |
diff --git a/headless/lib/browser/headless_browser_context.h b/headless/lib/browser/headless_browser_context.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bc486737079e73d708d53807e16df789f5a3a4d7 |
--- /dev/null |
+++ b/headless/lib/browser/headless_browser_context.h |
@@ -0,0 +1,96 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
+#define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
+ |
+#include "base/files/file_path.h" |
+#include "content/public/browser/browser_context.h" |
+#include "content/public/browser/content_browser_client.h" |
+#include "content/public/browser/resource_context.h" |
+#include "headless/lib/browser/headless_url_request_context_getter.h" |
+#include "headless/public/headless_browser.h" |
+ |
+namespace headless { |
+ |
+class HeadlessBrowserContext : public content::BrowserContext { |
+ public: |
+ HeadlessBrowserContext(const HeadlessBrowser::Options& options); |
+ ~HeadlessBrowserContext() override; |
+ |
+ // 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
|
+ scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( |
+ const base::FilePath& partition_path) override; |
+ base::FilePath GetPath() const override; |
+ bool IsOffTheRecord() const override; |
+ net::URLRequestContextGetter* GetRequestContext() override; |
+ net::URLRequestContextGetter* GetRequestContextForRenderProcess( |
+ int renderer_child_id) override; |
+ net::URLRequestContextGetter* GetMediaRequestContext() override; |
+ net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( |
+ int renderer_child_id) override; |
+ net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition( |
+ const base::FilePath& partition_path, |
+ bool in_memory) override; |
+ content::ResourceContext* GetResourceContext() override; |
+ content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; |
+ content::BrowserPluginGuestManager* GetGuestManager() override; |
+ storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; |
+ content::PushMessagingService* GetPushMessagingService() override; |
+ content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; |
+ content::PermissionManager* GetPermissionManager() override; |
+ content::BackgroundSyncController* GetBackgroundSyncController() override; |
+ |
+ 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.
|
+ content::ProtocolHandlerMap* protocol_handlers, |
+ content::URLRequestInterceptorScopedVector request_interceptors); |
+ |
+ const HeadlessBrowser::Options& options() const { return options_; } |
+ |
+ private: |
+ // Contains net::URLRequestContextGetter required for resource loading. |
+ class HeadlessResourceContext : public content::ResourceContext { |
+ public: |
+ HeadlessResourceContext(); |
+ ~HeadlessResourceContext() override; |
+ |
+ // ResourceContext implementation: |
+ net::HostResolver* GetHostResolver() override; |
+ net::URLRequestContext* GetRequestContext() override; |
+ |
+ void set_url_request_context_getter(net::URLRequestContextGetter* getter) { |
+ getter_ = getter; |
+ } |
+ |
+ private: |
+ 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.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(HeadlessResourceContext); |
+ }; |
+ |
+ // Used by HeadlessBrowserContext to initiate and set different types of |
+ // URLRequestContextGetter. |
+ virtual HeadlessURLRequestContextGetter* CreateURLRequestContextGetter( |
+ 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.
|
+ content::URLRequestInterceptorScopedVector request_interceptors); |
+ |
+ 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).
|
+ url_request_getter_ = getter; |
+ } |
+ |
+ // Performs initialization of the HeadlessBrowserContext while IO is still |
+ // allowed on the current thread. |
+ void InitWhileIOAllowed(); |
+ |
+ base::FilePath path_; |
+ scoped_ptr<HeadlessResourceContext> resource_context_; |
+ scoped_refptr<net::URLRequestContextGetter> url_request_getter_; |
+ HeadlessBrowser::Options options_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext); |
+}; |
+ |
+} // namespace headless |
+ |
+#endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |