OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 26 matching lines...) Expand all Loading... |
37 typedef std::set<ExtensionHost*> ExtensionHostSet; | 37 typedef std::set<ExtensionHost*> ExtensionHostSet; |
38 typedef ExtensionHostSet::const_iterator const_iterator; | 38 typedef ExtensionHostSet::const_iterator const_iterator; |
39 | 39 |
40 static ExtensionProcessManager* Create(Profile* profile); | 40 static ExtensionProcessManager* Create(Profile* profile); |
41 virtual ~ExtensionProcessManager(); | 41 virtual ~ExtensionProcessManager(); |
42 | 42 |
43 const ExtensionHostSet& background_hosts() const { | 43 const ExtensionHostSet& background_hosts() const { |
44 return background_hosts_; | 44 return background_hosts_; |
45 } | 45 } |
46 | 46 |
47 const ExtensionHostSet& platform_app_hosts() const { | |
48 return platform_app_hosts_; | |
49 } | |
50 | |
51 typedef std::set<content::RenderViewHost*> ViewSet; | 47 typedef std::set<content::RenderViewHost*> ViewSet; |
52 const ViewSet GetAllViews() const; | 48 const ViewSet GetAllViews() const; |
53 | 49 |
54 // Creates a new ExtensionHost with its associated view, grouping it in the | 50 // Creates a new ExtensionHost with its associated view, grouping it in the |
55 // appropriate SiteInstance (and therefore process) based on the URL and | 51 // appropriate SiteInstance (and therefore process) based on the URL and |
56 // profile. | 52 // profile. |
57 virtual ExtensionHost* CreateViewHost(const Extension* extension, | 53 virtual ExtensionHost* CreateViewHost(const Extension* extension, |
58 const GURL& url, | 54 const GURL& url, |
59 Browser* browser, | 55 Browser* browser, |
60 content::ViewType view_type); | 56 content::ViewType view_type); |
61 ExtensionHost* CreateViewHost(const GURL& url, | 57 ExtensionHost* CreateViewHost(const GURL& url, |
62 Browser* browser, | 58 Browser* browser, |
63 content::ViewType view_type); | 59 content::ViewType view_type); |
64 ExtensionHost* CreatePopupHost(const Extension* extension, | 60 ExtensionHost* CreatePopupHost(const Extension* extension, |
65 const GURL& url, | 61 const GURL& url, |
66 Browser* browser); | 62 Browser* browser); |
67 ExtensionHost* CreatePopupHost(const GURL& url, Browser* browser); | 63 ExtensionHost* CreatePopupHost(const GURL& url, Browser* browser); |
68 ExtensionHost* CreateDialogHost(const GURL& url, Browser* browser); | 64 ExtensionHost* CreateDialogHost(const GURL& url, Browser* browser); |
69 ExtensionHost* CreateInfobarHost(const Extension* extension, | 65 ExtensionHost* CreateInfobarHost(const Extension* extension, |
70 const GURL& url, | 66 const GURL& url, |
71 Browser* browser); | 67 Browser* browser); |
72 ExtensionHost* CreateInfobarHost(const GURL& url, | 68 ExtensionHost* CreateInfobarHost(const GURL& url, |
73 Browser* browser); | 69 Browser* browser); |
74 ExtensionHost* CreateShellHost(const Extension* extension, const GURL& url); | |
75 | 70 |
76 // Open the extension's options page. | 71 // Open the extension's options page. |
77 void OpenOptionsPage(const Extension* extension, Browser* browser); | 72 void OpenOptionsPage(const Extension* extension, Browser* browser); |
78 | 73 |
79 // Creates a new UI-less extension instance. Like CreateViewHost, but not | 74 // Creates a new UI-less extension instance. Like CreateViewHost, but not |
80 // displayed anywhere. | 75 // displayed anywhere. |
81 virtual void CreateBackgroundHost(const Extension* extension, | 76 virtual void CreateBackgroundHost(const Extension* extension, |
82 const GURL& url); | 77 const GURL& url); |
83 | 78 |
84 // Gets the ExtensionHost for the background page for an extension, or NULL if | 79 // Gets the ExtensionHost for the background page for an extension, or NULL if |
(...skipping 27 matching lines...) Expand all Loading... |
112 bool IsBackgroundHostClosing(const std::string& extension_id); | 107 bool IsBackgroundHostClosing(const std::string& extension_id); |
113 | 108 |
114 // Getter and setter for the lazy background page's keepalive count. This is | 109 // Getter and setter for the lazy background page's keepalive count. This is |
115 // the count of how many outstanding "things" are keeping the page alive. | 110 // the count of how many outstanding "things" are keeping the page alive. |
116 // When this reaches 0, we will begin the process of shutting down the page. | 111 // When this reaches 0, we will begin the process of shutting down the page. |
117 // "Things" include pending events, resource loads, and API calls. | 112 // "Things" include pending events, resource loads, and API calls. |
118 int GetLazyKeepaliveCount(const Extension* extension); | 113 int GetLazyKeepaliveCount(const Extension* extension); |
119 int IncrementLazyKeepaliveCount(const Extension* extension); | 114 int IncrementLazyKeepaliveCount(const Extension* extension); |
120 int DecrementLazyKeepaliveCount(const Extension* extension); | 115 int DecrementLazyKeepaliveCount(const Extension* extension); |
121 | 116 |
| 117 void IncrementLazyKeepaliveCountForView( |
| 118 content::RenderViewHost* render_view_host); |
| 119 |
122 // Handles a response to the ShouldUnload message, used for lazy background | 120 // Handles a response to the ShouldUnload message, used for lazy background |
123 // pages. | 121 // pages. |
124 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id); | 122 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id); |
125 | 123 |
126 // Same as above, for the Unload message. | 124 // Same as above, for the Unload message. |
127 void OnUnloadAck(const std::string& extension_id); | 125 void OnUnloadAck(const std::string& extension_id); |
128 | 126 |
129 // Tracks network requests for a given RenderViewHost, used to know | 127 // Tracks network requests for a given RenderViewHost, used to know |
130 // when network activity is idle for lazy background pages. | 128 // when network activity is idle for lazy background pages. |
131 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); | 129 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); |
(...skipping 15 matching lines...) Expand all Loading... |
147 | 145 |
148 // Gets the profile associated with site_instance_ and all other | 146 // Gets the profile associated with site_instance_ and all other |
149 // related SiteInstances. | 147 // related SiteInstances. |
150 Profile* GetProfile() const; | 148 Profile* GetProfile() const; |
151 | 149 |
152 content::NotificationRegistrar registrar_; | 150 content::NotificationRegistrar registrar_; |
153 | 151 |
154 // The set of ExtensionHosts running viewless background extensions. | 152 // The set of ExtensionHosts running viewless background extensions. |
155 ExtensionHostSet background_hosts_; | 153 ExtensionHostSet background_hosts_; |
156 | 154 |
157 // The set of ExtensionHosts running platform apps. | |
158 ExtensionHostSet platform_app_hosts_; | |
159 | |
160 // A SiteInstance related to the SiteInstance for all extensions in | 155 // A SiteInstance related to the SiteInstance for all extensions in |
161 // this profile. We create it in such a way that a new | 156 // this profile. We create it in such a way that a new |
162 // browsing instance is created. This controls process grouping. | 157 // browsing instance is created. This controls process grouping. |
163 scoped_refptr<content::SiteInstance> site_instance_; | 158 scoped_refptr<content::SiteInstance> site_instance_; |
164 | 159 |
165 private: | 160 private: |
166 // Extra information we keep for each extension's background page. | 161 // Extra information we keep for each extension's background page. |
167 struct BackgroundPageData; | 162 struct BackgroundPageData; |
168 typedef std::string ExtensionId; | 163 typedef std::string ExtensionId; |
169 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; | 164 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // The time to delay between sending a ShouldUnload message and | 201 // The time to delay between sending a ShouldUnload message and |
207 // sending a Unload message; read from command-line switch. | 202 // sending a Unload message; read from command-line switch. |
208 base::TimeDelta event_page_unloading_time_; | 203 base::TimeDelta event_page_unloading_time_; |
209 | 204 |
210 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; | 205 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; |
211 | 206 |
212 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); | 207 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); |
213 }; | 208 }; |
214 | 209 |
215 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 210 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
OLD | NEW |