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_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ |
6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <unordered_map> | 10 #include <unordered_map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
15 #include "content/public/browser/content_browser_client.h" | 15 #include "content/public/browser/content_browser_client.h" |
16 #include "content/public/browser/resource_context.h" | 16 #include "content/public/browser/resource_context.h" |
17 #include "headless/lib/browser/headless_browser_context_options.h" | 17 #include "headless/lib/browser/headless_browser_context_options.h" |
18 #include "headless/lib/browser/headless_url_request_context_getter.h" | 18 #include "headless/lib/browser/headless_url_request_context_getter.h" |
19 #include "headless/public/headless_browser.h" | 19 #include "headless/public/headless_browser.h" |
20 #include "headless/public/headless_browser_context.h" | 20 #include "headless/public/headless_browser_context.h" |
21 | 21 |
22 namespace headless { | 22 namespace headless { |
23 class HeadlessBrowserImpl; | 23 class HeadlessBrowserImpl; |
| 24 class HeadlessDownloadManagerDelegate; |
24 class HeadlessResourceContext; | 25 class HeadlessResourceContext; |
25 class HeadlessWebContentsImpl; | 26 class HeadlessWebContentsImpl; |
26 | 27 |
27 class HeadlessBrowserContextImpl : public HeadlessBrowserContext, | 28 class HeadlessBrowserContextImpl : public HeadlessBrowserContext, |
28 public content::BrowserContext { | 29 public content::BrowserContext { |
29 public: | 30 public: |
30 ~HeadlessBrowserContextImpl() override; | 31 ~HeadlessBrowserContextImpl() override; |
31 | 32 |
32 static HeadlessBrowserContextImpl* From( | 33 static HeadlessBrowserContextImpl* From( |
33 HeadlessBrowserContext* browser_context); | 34 HeadlessBrowserContext* browser_context); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 HeadlessBrowserImpl* browser, | 97 HeadlessBrowserImpl* browser, |
97 std::unique_ptr<HeadlessBrowserContextOptions> context_options); | 98 std::unique_ptr<HeadlessBrowserContextOptions> context_options); |
98 | 99 |
99 // Performs initialization of the HeadlessBrowserContextImpl while IO is still | 100 // Performs initialization of the HeadlessBrowserContextImpl while IO is still |
100 // allowed on the current thread. | 101 // allowed on the current thread. |
101 void InitWhileIOAllowed(); | 102 void InitWhileIOAllowed(); |
102 | 103 |
103 HeadlessBrowserImpl* browser_; // Not owned. | 104 HeadlessBrowserImpl* browser_; // Not owned. |
104 std::unique_ptr<HeadlessBrowserContextOptions> context_options_; | 105 std::unique_ptr<HeadlessBrowserContextOptions> context_options_; |
105 std::unique_ptr<HeadlessResourceContext> resource_context_; | 106 std::unique_ptr<HeadlessResourceContext> resource_context_; |
| 107 std::unique_ptr<HeadlessDownloadManagerDelegate> download_manager_delegate_; |
106 base::FilePath path_; | 108 base::FilePath path_; |
107 | 109 |
108 std::unordered_map<std::string, std::unique_ptr<HeadlessWebContents>> | 110 std::unordered_map<std::string, std::unique_ptr<HeadlessWebContents>> |
109 web_contents_map_; | 111 web_contents_map_; |
110 | 112 |
111 // Guards |frame_tree_node_map_| from being concurrently written on the UI | 113 // Guards |frame_tree_node_map_| from being concurrently written on the UI |
112 // thread and read on the IO thread. | 114 // thread and read on the IO thread. |
113 // TODO(alexclarke): Remove if we can add FrameTreeNode ID to | 115 // TODO(alexclarke): Remove if we can add FrameTreeNode ID to |
114 // URLRequestUserData. See https://crbug.com/715541 | 116 // URLRequestUserData. See https://crbug.com/715541 |
115 mutable base::Lock frame_tree_node_map_lock_; | 117 mutable base::Lock frame_tree_node_map_lock_; |
116 std::map<std::pair<int, int>, int> frame_tree_node_map_; | 118 std::map<std::pair<int, int>, int> frame_tree_node_map_; |
117 | 119 |
118 std::unique_ptr<content::PermissionManager> permission_manager_; | 120 std::unique_ptr<content::PermissionManager> permission_manager_; |
119 | 121 |
120 std::string id_; | 122 std::string id_; |
121 | 123 |
122 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl); | 124 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl); |
123 }; | 125 }; |
124 | 126 |
125 } // namespace headless | 127 } // namespace headless |
126 | 128 |
127 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ | 129 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ |
OLD | NEW |