| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 content::RenderViewHost* render_view_host); | 106 content::RenderViewHost* render_view_host); |
| 107 | 107 |
| 108 // Returns true if the (lazy) background host for the given extension has | 108 // Returns true if the (lazy) background host for the given extension has |
| 109 // already been sent the unload event and is shutting down. | 109 // already been sent the unload event and is shutting down. |
| 110 bool IsBackgroundHostClosing(const std::string& extension_id); | 110 bool IsBackgroundHostClosing(const std::string& extension_id); |
| 111 | 111 |
| 112 // Getter and setter for the lazy background page's keepalive count. This is | 112 // Getter and setter for the lazy background page's keepalive count. This is |
| 113 // the count of how many outstanding "things" are keeping the page alive. | 113 // the count of how many outstanding "things" are keeping the page alive. |
| 114 // When this reaches 0, we will begin the process of shutting down the page. | 114 // When this reaches 0, we will begin the process of shutting down the page. |
| 115 // "Things" include pending events, resource loads, and API calls. | 115 // "Things" include pending events, resource loads, and API calls. |
| 116 // The |cancel_suspend| option defaults to false and indicates whether |
| 117 // incrementing the keepalive count should prevent it from being suspended. |
| 116 int GetLazyKeepaliveCount(const extensions::Extension* extension); | 118 int GetLazyKeepaliveCount(const extensions::Extension* extension); |
| 117 int IncrementLazyKeepaliveCount(const extensions::Extension* extension); | 119 int IncrementLazyKeepaliveCount(const extensions::Extension* extension); |
| 120 int IncrementLazyKeepaliveCount(const extensions::Extension* extension, |
| 121 bool cancel_suspend); |
| 118 int DecrementLazyKeepaliveCount(const extensions::Extension* extension); | 122 int DecrementLazyKeepaliveCount(const extensions::Extension* extension); |
| 119 | 123 |
| 120 void IncrementLazyKeepaliveCountForView( | 124 void IncrementLazyKeepaliveCountForView( |
| 121 content::RenderViewHost* render_view_host); | 125 content::RenderViewHost* render_view_host); |
| 122 | 126 |
| 123 // Handles a response to the ShouldUnload message, used for lazy background | 127 // Handles a response to the ShouldUnload message, used for lazy background |
| 124 // pages. | 128 // pages. |
| 125 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id); | 129 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id); |
| 126 | 130 |
| 127 // Same as above, for the Unload message. | 131 // Same as above, for the Unload message. |
| 128 void OnUnloadAck(const std::string& extension_id); | 132 void OnUnloadAck(const std::string& extension_id); |
| 129 | 133 |
| 130 // Tracks network requests for a given RenderViewHost, used to know | 134 // Tracks network requests for a given RenderViewHost, used to know |
| 131 // when network activity is idle for lazy background pages. | 135 // when network activity is idle for lazy background pages. |
| 132 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); | 136 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); |
| 133 void OnNetworkRequestDone(content::RenderViewHost* render_view_host); | 137 void OnNetworkRequestDone(content::RenderViewHost* render_view_host); |
| 134 | 138 |
| 139 // Prevent the specified extension from being suspended. |
| 140 void CancelSuspend(const std::string& extension_id); |
| 141 |
| 135 protected: | 142 protected: |
| 136 explicit ExtensionProcessManager(Profile* profile); | 143 explicit ExtensionProcessManager(Profile* profile); |
| 137 | 144 |
| 138 // Called just after |host| is created so it can be registered in our lists. | 145 // Called just after |host| is created so it can be registered in our lists. |
| 139 void OnExtensionHostCreated(ExtensionHost* host, bool is_background); | 146 void OnExtensionHostCreated(ExtensionHost* host, bool is_background); |
| 140 | 147 |
| 141 // Called on browser shutdown to close our extension hosts. | 148 // Called on browser shutdown to close our extension hosts. |
| 142 void CloseBackgroundHosts(); | 149 void CloseBackgroundHosts(); |
| 143 | 150 |
| 144 // content::NotificationObserver: | 151 // content::NotificationObserver: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 185 |
| 179 // Ensure browser object is not null except for certain situations. | 186 // Ensure browser object is not null except for certain situations. |
| 180 void EnsureBrowserWhenRequired(Browser* browser, | 187 void EnsureBrowserWhenRequired(Browser* browser, |
| 181 chrome::ViewType view_type); | 188 chrome::ViewType view_type); |
| 182 | 189 |
| 183 // These are called when the extension transitions between idle and active. | 190 // These are called when the extension transitions between idle and active. |
| 184 // They control the process of closing the background page when idle. | 191 // They control the process of closing the background page when idle. |
| 185 void OnLazyBackgroundPageIdle(const std::string& extension_id, | 192 void OnLazyBackgroundPageIdle(const std::string& extension_id, |
| 186 int sequence_id); | 193 int sequence_id); |
| 187 void OnLazyBackgroundPageActive(const std::string& extension_id); | 194 void OnLazyBackgroundPageActive(const std::string& extension_id); |
| 188 void CloseLazyBackgroundPageNow(const std::string& extension_id); | 195 void MaybePostOnLazyBackgroundPageIdle(const std::string& extension_id); |
| 196 void CloseLazyBackgroundPageNow(const std::string& extension_id, |
| 197 int sequence_id); |
| 189 | 198 |
| 190 // Updates a potentially-registered RenderViewHost once it has been | 199 // Updates a potentially-registered RenderViewHost once it has been |
| 191 // associated with a WebContents. This allows us to gather information that | 200 // associated with a WebContents. This allows us to gather information that |
| 192 // was not available when the host was first registered. | 201 // was not available when the host was first registered. |
| 193 void UpdateRegisteredRenderView(content::RenderViewHost* render_view_host); | 202 void UpdateRegisteredRenderView(content::RenderViewHost* render_view_host); |
| 194 | 203 |
| 195 // Clears background page data for this extension. | 204 // Clears background page data for this extension. |
| 196 void ClearBackgroundPageData(const std::string& extension_id); | 205 void ClearBackgroundPageData(const std::string& extension_id); |
| 197 | 206 |
| 198 BackgroundPageDataMap background_page_data_; | 207 BackgroundPageDataMap background_page_data_; |
| 199 | 208 |
| 200 // The time to delay between an extension becoming idle and | 209 // The time to delay between an extension becoming idle and |
| 201 // sending a ShouldUnload message; read from command-line switch. | 210 // sending a ShouldUnload message; read from command-line switch. |
| 202 base::TimeDelta event_page_idle_time_; | 211 base::TimeDelta event_page_idle_time_; |
| 203 | 212 |
| 204 // The time to delay between sending a ShouldUnload message and | 213 // The time to delay between sending a ShouldUnload message and |
| 205 // sending a Unload message; read from command-line switch. | 214 // sending a Unload message; read from command-line switch. |
| 206 base::TimeDelta event_page_unloading_time_; | 215 base::TimeDelta event_page_unloading_time_; |
| 207 | 216 |
| 208 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; | 217 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; |
| 209 | 218 |
| 210 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); | 219 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); |
| 211 }; | 220 }; |
| 212 | 221 |
| 213 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 222 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
| OLD | NEW |