| 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> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 HeadlessBrowserContext::Builder* builder); | 38 HeadlessBrowserContext::Builder* builder); |
| 39 | 39 |
| 40 // HeadlessBrowserContext implementation: | 40 // HeadlessBrowserContext implementation: |
| 41 HeadlessWebContents::Builder CreateWebContentsBuilder() override; | 41 HeadlessWebContents::Builder CreateWebContentsBuilder() override; |
| 42 std::vector<HeadlessWebContents*> GetAllWebContents() override; | 42 std::vector<HeadlessWebContents*> GetAllWebContents() override; |
| 43 HeadlessWebContents* GetWebContentsForDevToolsAgentHostId( | 43 HeadlessWebContents* GetWebContentsForDevToolsAgentHostId( |
| 44 const std::string& devtools_agent_host_id) override; | 44 const std::string& devtools_agent_host_id) override; |
| 45 void Close() override; | 45 void Close() override; |
| 46 const std::string& Id() const override; | 46 const std::string& Id() const override; |
| 47 | 47 |
| 48 void SetFrameTreeNodeId(int render_process_id, |
| 49 int render_frame_id, |
| 50 int frame_tree_node_id); |
| 51 |
| 52 void RemoveFrameTreeNode(int render_process_id, int render_frame_id); |
| 53 |
| 48 // BrowserContext implementation: | 54 // BrowserContext implementation: |
| 49 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( | 55 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( |
| 50 const base::FilePath& partition_path) override; | 56 const base::FilePath& partition_path) override; |
| 51 base::FilePath GetPath() const override; | 57 base::FilePath GetPath() const override; |
| 52 bool IsOffTheRecord() const override; | 58 bool IsOffTheRecord() const override; |
| 53 content::ResourceContext* GetResourceContext() override; | 59 content::ResourceContext* GetResourceContext() override; |
| 54 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; | 60 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; |
| 55 content::BrowserPluginGuestManager* GetGuestManager() override; | 61 content::BrowserPluginGuestManager* GetGuestManager() override; |
| 56 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; | 62 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; |
| 57 content::PushMessagingService* GetPushMessagingService() override; | 63 content::PushMessagingService* GetPushMessagingService() override; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 HeadlessWebContents* CreateWebContents(HeadlessWebContents::Builder* builder); | 80 HeadlessWebContents* CreateWebContents(HeadlessWebContents::Builder* builder); |
| 75 // Register web contents which were created not through Headless API | 81 // Register web contents which were created not through Headless API |
| 76 // (calling window.open() is a best example for this). | 82 // (calling window.open() is a best example for this). |
| 77 void RegisterWebContents( | 83 void RegisterWebContents( |
| 78 std::unique_ptr<HeadlessWebContentsImpl> web_contents); | 84 std::unique_ptr<HeadlessWebContentsImpl> web_contents); |
| 79 void DestroyWebContents(HeadlessWebContentsImpl* web_contents); | 85 void DestroyWebContents(HeadlessWebContentsImpl* web_contents); |
| 80 | 86 |
| 81 HeadlessBrowserImpl* browser() const; | 87 HeadlessBrowserImpl* browser() const; |
| 82 const HeadlessBrowserContextOptions* options() const; | 88 const HeadlessBrowserContextOptions* options() const; |
| 83 | 89 |
| 90 // Returns the frame tree node id for the corresponding RenderFrameHost or -1 |
| 91 // if it can't be found. Can be called on any thread. |
| 92 int GetFrameTreeNodeId(int render_process_id, int render_frame_id) const; |
| 93 |
| 84 private: | 94 private: |
| 85 HeadlessBrowserContextImpl( | 95 HeadlessBrowserContextImpl( |
| 86 HeadlessBrowserImpl* browser, | 96 HeadlessBrowserImpl* browser, |
| 87 std::unique_ptr<HeadlessBrowserContextOptions> context_options); | 97 std::unique_ptr<HeadlessBrowserContextOptions> context_options); |
| 88 | 98 |
| 89 // Performs initialization of the HeadlessBrowserContextImpl while IO is still | 99 // Performs initialization of the HeadlessBrowserContextImpl while IO is still |
| 90 // allowed on the current thread. | 100 // allowed on the current thread. |
| 91 void InitWhileIOAllowed(); | 101 void InitWhileIOAllowed(); |
| 92 | 102 |
| 93 HeadlessBrowserImpl* browser_; // Not owned. | 103 HeadlessBrowserImpl* browser_; // Not owned. |
| 94 std::unique_ptr<HeadlessBrowserContextOptions> context_options_; | 104 std::unique_ptr<HeadlessBrowserContextOptions> context_options_; |
| 95 std::unique_ptr<HeadlessResourceContext> resource_context_; | 105 std::unique_ptr<HeadlessResourceContext> resource_context_; |
| 96 base::FilePath path_; | 106 base::FilePath path_; |
| 97 | 107 |
| 98 std::unordered_map<std::string, std::unique_ptr<HeadlessWebContents>> | 108 std::unordered_map<std::string, std::unique_ptr<HeadlessWebContents>> |
| 99 web_contents_map_; | 109 web_contents_map_; |
| 100 | 110 |
| 111 mutable base::Lock frame_tree_node_map_lock_; // Guards frame_tree_node_map_ |
| 112 std::map<std::pair<int, int>, int> frame_tree_node_map_; |
| 113 |
| 101 std::unique_ptr<content::PermissionManager> permission_manager_; | 114 std::unique_ptr<content::PermissionManager> permission_manager_; |
| 102 | 115 |
| 103 std::string id_; | 116 std::string id_; |
| 104 | 117 |
| 105 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl); | 118 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl); |
| 106 }; | 119 }; |
| 107 | 120 |
| 108 } // namespace headless | 121 } // namespace headless |
| 109 | 122 |
| 110 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ | 123 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ |
| OLD | NEW |