| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
| 6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // the count of how many outstanding "things" are keeping the page alive. | 85 // the count of how many outstanding "things" are keeping the page alive. |
| 86 // When this reaches 0, we will begin the process of shutting down the page. | 86 // When this reaches 0, we will begin the process of shutting down the page. |
| 87 // "Things" include pending events, resource loads, and API calls. | 87 // "Things" include pending events, resource loads, and API calls. |
| 88 int GetLazyKeepaliveCount(const Extension* extension); | 88 int GetLazyKeepaliveCount(const Extension* extension); |
| 89 int IncrementLazyKeepaliveCount(const Extension* extension); | 89 int IncrementLazyKeepaliveCount(const Extension* extension); |
| 90 int DecrementLazyKeepaliveCount(const Extension* extension); | 90 int DecrementLazyKeepaliveCount(const Extension* extension); |
| 91 | 91 |
| 92 void IncrementLazyKeepaliveCountForView( | 92 void IncrementLazyKeepaliveCountForView( |
| 93 content::RenderViewHost* render_view_host); | 93 content::RenderViewHost* render_view_host); |
| 94 | 94 |
| 95 // Keeps a background page alive. Unlike IncrementLazyKeepaliveCount, these |
| 96 // impulses will only keep the page alive for a limited amount of time unless |
| 97 // called regularly. |
| 98 void KeepaliveImpulse(const Extension* extension); |
| 99 |
| 95 // Handles a response to the ShouldSuspend message, used for lazy background | 100 // Handles a response to the ShouldSuspend message, used for lazy background |
| 96 // pages. | 101 // pages. |
| 97 void OnShouldSuspendAck(const std::string& extension_id, int sequence_id); | 102 void OnShouldSuspendAck(const std::string& extension_id, int sequence_id); |
| 98 | 103 |
| 99 // Same as above, for the Suspend message. | 104 // Same as above, for the Suspend message. |
| 100 void OnSuspendAck(const std::string& extension_id); | 105 void OnSuspendAck(const std::string& extension_id); |
| 101 | 106 |
| 102 // Tracks network requests for a given RenderViewHost, used to know | 107 // Tracks network requests for a given RenderViewHost, used to know |
| 103 // when network activity is idle for lazy background pages. | 108 // when network activity is idle for lazy background pages. |
| 104 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); | 109 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; | 162 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; |
| 158 typedef std::map<content::RenderViewHost*, | 163 typedef std::map<content::RenderViewHost*, |
| 159 extensions::ViewType> ExtensionRenderViews; | 164 extensions::ViewType> ExtensionRenderViews; |
| 160 | 165 |
| 161 // Called just after |host| is created so it can be registered in our lists. | 166 // Called just after |host| is created so it can be registered in our lists. |
| 162 void OnBackgroundHostCreated(ExtensionHost* host); | 167 void OnBackgroundHostCreated(ExtensionHost* host); |
| 163 | 168 |
| 164 // Close the given |host| iff it's a background page. | 169 // Close the given |host| iff it's a background page. |
| 165 void CloseBackgroundHost(ExtensionHost* host); | 170 void CloseBackgroundHost(ExtensionHost* host); |
| 166 | 171 |
| 172 // Internal implementation of DecrementLazyKeepaliveCount with an |
| 173 // |extension_id| known to have a lazy background page. |
| 174 int DecrementLazyKeepaliveCountById(std::string extension_id); |
| 175 |
| 176 // Checks if keepalive impulses have occured, and adjusts keep alive count. |
| 177 void OnKeepaliveImpulseCheck(); |
| 178 |
| 167 // These are called when the extension transitions between idle and active. | 179 // These are called when the extension transitions between idle and active. |
| 168 // They control the process of closing the background page when idle. | 180 // They control the process of closing the background page when idle. |
| 169 void OnLazyBackgroundPageIdle(const std::string& extension_id, | 181 void OnLazyBackgroundPageIdle(const std::string& extension_id, |
| 170 int sequence_id); | 182 int sequence_id); |
| 171 void OnLazyBackgroundPageActive(const std::string& extension_id); | 183 void OnLazyBackgroundPageActive(const std::string& extension_id); |
| 172 void CloseLazyBackgroundPageNow(const std::string& extension_id, | 184 void CloseLazyBackgroundPageNow(const std::string& extension_id, |
| 173 int sequence_id); | 185 int sequence_id); |
| 174 | 186 |
| 175 // Potentially registers a RenderViewHost, if it is associated with an | 187 // Potentially registers a RenderViewHost, if it is associated with an |
| 176 // extension. Does nothing if this is not an extension renderer. | 188 // extension. Does nothing if this is not an extension renderer. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; | 224 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; |
| 213 | 225 |
| 214 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 226 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
| 215 | 227 |
| 216 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 228 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
| 217 }; | 229 }; |
| 218 | 230 |
| 219 } // namespace extensions | 231 } // namespace extensions |
| 220 | 232 |
| 221 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 233 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
| OLD | NEW |