[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 5 | #ifndef EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
| 6 | #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 7 | |
[email protected] | 4577622 | 2009-07-15 20:21:58 | [diff] [blame] | 8 | #include <map> |
[email protected] | 8a17bd5 | 2009-06-06 08:19:49 | [diff] [blame] | 9 | #include <set> |
[email protected] | 4577622 | 2009-07-15 20:21:58 | [diff] [blame] | 10 | #include <string> |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 11 | |
[email protected] | a23f62e | 2013-04-26 13:13:02 | [diff] [blame] | 12 | #include "base/callback.h" |
[email protected] | 1790275 | 2011-08-31 22:52:54 | [diff] [blame] | 13 | #include "base/compiler_specific.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 14 | #include "base/memory/ref_counted.h" |
[email protected] | 99c49b5 | 2012-05-02 01:50:20 | [diff] [blame] | 15 | #include "base/memory/weak_ptr.h" |
[email protected] | 08d469b2 | 2014-03-31 00:51:24 | [diff] [blame] | 16 | #include "base/observer_list.h" |
[email protected] | 41a17c5 | 2013-06-28 00:27:53 | [diff] [blame] | 17 | #include "base/time/time.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 18 | #include "content/public/browser/notification_observer.h" |
| 19 | #include "content/public/browser/notification_registrar.h" |
[email protected] | cb2edf2 | 2013-04-01 20:25:23 | [diff] [blame] | 20 | #include "extensions/common/view_type.h" |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 21 | |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 22 | class GURL; |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 23 | |
| 24 | namespace content { |
[email protected] | 7f47421 | 2013-11-05 04:26:16 | [diff] [blame] | 25 | class BrowserContext; |
[email protected] | a23f62e | 2013-04-26 13:13:02 | [diff] [blame] | 26 | class DevToolsAgentHost; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 27 | class RenderViewHost; |
[email protected] | 9dfed87 | 2013-12-30 23:08:56 | [diff] [blame] | 28 | class RenderFrameHost; |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 29 | class SiteInstance; |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 30 | }; |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 31 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 32 | namespace extensions { |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 33 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 34 | class Extension; |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 35 | class ExtensionHost; |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 36 | class ExtensionRegistry; |
| 37 | class ProcessManagerDelegate; |
[email protected] | 08d469b2 | 2014-03-31 00:51:24 | [diff] [blame] | 38 | class ProcessManagerObserver; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 39 | |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 40 | // Manages dynamic state of running Chromium extensions. There is one instance |
| 41 | // of this class per Profile. OTR Profiles have a separate instance that keeps |
| 42 | // track of split-mode extensions only. |
[email protected] | 49e7741e | 2014-07-21 01:57:42 | [diff] [blame] | 43 | class ProcessManager : public content::NotificationObserver { |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 44 | public: |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 45 | typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 46 | typedef ExtensionHostSet::const_iterator const_iterator; |
| 47 | |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 48 | static ProcessManager* Create(content::BrowserContext* context); |
| 49 | virtual ~ProcessManager(); |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 50 | |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 51 | const ExtensionHostSet& background_hosts() const { |
| 52 | return background_hosts_; |
| 53 | } |
| 54 | |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 55 | typedef std::set<content::RenderViewHost*> ViewSet; |
| 56 | const ViewSet GetAllViews() const; |
| 57 | |
[email protected] | 08d469b2 | 2014-03-31 00:51:24 | [diff] [blame] | 58 | // The typical observer interface. |
| 59 | void AddObserver(ProcessManagerObserver* observer); |
| 60 | void RemoveObserver(ProcessManagerObserver* observer); |
| 61 | |
[email protected] | 029ad37 | 2011-05-20 17:12:56 | [diff] [blame] | 62 | // Creates a new UI-less extension instance. Like CreateViewHost, but not |
[email protected] | 6ad9cdf7 | 2014-02-27 13:12:41 | [diff] [blame] | 63 | // displayed anywhere. Returns false if no background host can be created, |
| 64 | // for example for hosted apps and extensions that aren't enabled in |
| 65 | // Incognito. |
| 66 | virtual bool CreateBackgroundHost(const Extension* extension, |
| 67 | const GURL& url); |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 68 | |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 69 | // Gets the ExtensionHost for the background page for an extension, or NULL if |
| 70 | // the extension isn't running or doesn't have a background page. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 71 | ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); |
[email protected] | 4814b51 | 2009-11-07 00:12:29 | [diff] [blame] | 72 | |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 73 | // Returns the SiteInstance that the given URL belongs to. |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 74 | // TODO(aa): This only returns correct results for extensions and packaged |
| 75 | // apps, not hosted apps. |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 76 | virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url); |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 77 | |
[email protected] | 3e19499 | 2011-10-20 05:39:10 | [diff] [blame] | 78 | // Unregisters a RenderViewHost as hosting any extension. |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 79 | void UnregisterRenderViewHost(content::RenderViewHost* render_view_host); |
[email protected] | 3e19499 | 2011-10-20 05:39:10 | [diff] [blame] | 80 | |
| 81 | // Returns all RenderViewHosts that are registered for the specified |
| 82 | // extension. |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 83 | std::set<content::RenderViewHost*> GetRenderViewHostsForExtension( |
[email protected] | 3e19499 | 2011-10-20 05:39:10 | [diff] [blame] | 84 | const std::string& extension_id); |
[email protected] | 4577622 | 2009-07-15 20:21:58 | [diff] [blame] | 85 | |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 86 | // Returns the extension associated with the specified RenderViewHost, or |
| 87 | // NULL. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 88 | const Extension* GetExtensionForRenderViewHost( |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 89 | content::RenderViewHost* render_view_host); |
[email protected] | 27e469a | 2010-01-11 20:35:09 | [diff] [blame] | 90 | |
[email protected] | 7042b68 | 2012-04-19 22:57:51 | [diff] [blame] | 91 | // Returns true if the (lazy) background host for the given extension has |
| 92 | // already been sent the unload event and is shutting down. |
| 93 | bool IsBackgroundHostClosing(const std::string& extension_id); |
| 94 | |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 95 | // Getter and setter for the lazy background page's keepalive count. This is |
| 96 | // the count of how many outstanding "things" are keeping the page alive. |
| 97 | // When this reaches 0, we will begin the process of shutting down the page. |
| 98 | // "Things" include pending events, resource loads, and API calls. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 99 | int GetLazyKeepaliveCount(const Extension* extension); |
[email protected] | 38877015 | 2013-12-03 01:25:32 | [diff] [blame] | 100 | void IncrementLazyKeepaliveCount(const Extension* extension); |
| 101 | void DecrementLazyKeepaliveCount(const Extension* extension); |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 102 | |
[email protected] | d72d3a6 | 2012-05-10 03:45:08 | [diff] [blame] | 103 | void IncrementLazyKeepaliveCountForView( |
| 104 | content::RenderViewHost* render_view_host); |
| 105 | |
[email protected] | 38877015 | 2013-12-03 01:25:32 | [diff] [blame] | 106 | // Keeps a background page alive. Unlike IncrementLazyKeepaliveCount, these |
| 107 | // impulses will only keep the page alive for a limited amount of time unless |
| 108 | // called regularly. |
| 109 | void KeepaliveImpulse(const Extension* extension); |
| 110 | |
[email protected] | 584e657 | 2013-02-16 07:02:33 | [diff] [blame] | 111 | // Handles a response to the ShouldSuspend message, used for lazy background |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 112 | // pages. |
[email protected] | 77a538f | 2014-07-14 22:25:37 | [diff] [blame] | 113 | void OnShouldSuspendAck(const std::string& extension_id, uint64 sequence_id); |
[email protected] | 103f19f | 2012-04-02 19:30:12 | [diff] [blame] | 114 | |
[email protected] | 584e657 | 2013-02-16 07:02:33 | [diff] [blame] | 115 | // Same as above, for the Suspend message. |
| 116 | void OnSuspendAck(const std::string& extension_id); |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 117 | |
[email protected] | 9dfed87 | 2013-12-30 23:08:56 | [diff] [blame] | 118 | // Tracks network requests for a given RenderFrameHost, used to know |
[email protected] | 6baff0b5 | 2012-03-06 01:30:18 | [diff] [blame] | 119 | // when network activity is idle for lazy background pages. |
[email protected] | 9dfed87 | 2013-12-30 23:08:56 | [diff] [blame] | 120 | void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host); |
| 121 | void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host); |
[email protected] | 6baff0b5 | 2012-03-06 01:30:18 | [diff] [blame] | 122 | |
[email protected] | 0d475e07 | 2012-07-26 02:30:42 | [diff] [blame] | 123 | // Prevents |extension|'s background page from being closed and sends the |
| 124 | // onSuspendCanceled() event to it. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 125 | void CancelSuspend(const Extension* extension); |
[email protected] | 0d475e07 | 2012-07-26 02:30:42 | [diff] [blame] | 126 | |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 127 | // Creates background hosts if the embedder is ready and they are not already |
| 128 | // loaded. |
| 129 | void MaybeCreateStartupBackgroundHosts(); |
[email protected] | aa3dd49 | 2013-11-05 17:09:09 | [diff] [blame] | 130 | |
| 131 | // Gets the BrowserContext associated with site_instance_ and all other |
| 132 | // related SiteInstances. |
| 133 | content::BrowserContext* GetBrowserContext() const; |
| 134 | |
[email protected] | b6cd720 | 2014-01-07 17:46:55 | [diff] [blame] | 135 | // Sets callbacks for testing keepalive impulse behavior. |
| 136 | typedef base::Callback<void(const std::string& extension_id)> |
| 137 | ImpulseCallbackForTesting; |
| 138 | void SetKeepaliveImpulseCallbackForTesting( |
| 139 | const ImpulseCallbackForTesting& callback); |
| 140 | void SetKeepaliveImpulseDecrementCallbackForTesting( |
| 141 | const ImpulseCallbackForTesting& callback); |
| 142 | |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 143 | // Creates a non-incognito instance for tests. |registry| allows unit tests |
| 144 | // to inject an ExtensionRegistry that is not managed by the usual |
| 145 | // BrowserContextKeyedServiceFactory system. |
| 146 | static ProcessManager* CreateForTesting(content::BrowserContext* context, |
| 147 | ExtensionRegistry* registry); |
| 148 | |
| 149 | // Creates an incognito-context instance for tests. |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 150 | static ProcessManager* CreateIncognitoForTesting( |
| 151 | content::BrowserContext* incognito_context, |
| 152 | content::BrowserContext* original_context, |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 153 | ProcessManager* original_manager, |
| 154 | ExtensionRegistry* registry); |
| 155 | |
| 156 | bool startup_background_hosts_created_for_test() const { |
| 157 | return startup_background_hosts_created_; |
| 158 | } |
[email protected] | b9f6ba3 | 2014-03-10 18:34:08 | [diff] [blame] | 159 | |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 160 | protected: |
[email protected] | 7f47421 | 2013-11-05 04:26:16 | [diff] [blame] | 161 | // If |context| is incognito pass the master context as |original_context|. |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 162 | // Otherwise pass the same context for both. Pass the ExtensionRegistry for |
| 163 | // |context| as |registry|, or override it for testing. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 164 | ProcessManager(content::BrowserContext* context, |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 165 | content::BrowserContext* original_context, |
| 166 | ExtensionRegistry* registry); |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 167 | |
[email protected] | ae5497f | 2009-11-05 00:39:46 | [diff] [blame] | 168 | // Called on browser shutdown to close our extension hosts. |
| 169 | void CloseBackgroundHosts(); |
| 170 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 171 | // content::NotificationObserver: |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 172 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 173 | const content::NotificationSource& source, |
| 174 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | bc535ee5 | 2010-08-31 18:40:32 | [diff] [blame] | 175 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 176 | content::NotificationRegistrar registrar_; |
[email protected] | fc36895 | 2009-05-21 21:37:06 | [diff] [blame] | 177 | |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 178 | // The set of ExtensionHosts running viewless background extensions. |
[email protected] | 8a17bd5 | 2009-06-06 08:19:49 | [diff] [blame] | 179 | ExtensionHostSet background_hosts_; |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 180 | |
[email protected] | 72daaa9 | 2012-01-18 13:39:02 | [diff] [blame] | 181 | // A SiteInstance related to the SiteInstance for all extensions in |
| 182 | // this profile. We create it in such a way that a new |
| 183 | // browsing instance is created. This controls process grouping. |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 184 | scoped_refptr<content::SiteInstance> site_instance_; |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 185 | |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 186 | // Not owned. Also used by IncognitoProcessManager. |
| 187 | ExtensionRegistry* extension_registry_; |
| 188 | |
[email protected] | 3e19499 | 2011-10-20 05:39:10 | [diff] [blame] | 189 | private: |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 190 | friend class ProcessManagerTest; |
[email protected] | 7f47421 | 2013-11-05 04:26:16 | [diff] [blame] | 191 | |
[email protected] | 103f19f | 2012-04-02 19:30:12 | [diff] [blame] | 192 | // Extra information we keep for each extension's background page. |
| 193 | struct BackgroundPageData; |
| 194 | typedef std::string ExtensionId; |
| 195 | typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 196 | typedef std::map<content::RenderViewHost*, |
[email protected] | cb2edf2 | 2013-04-01 20:25:23 | [diff] [blame] | 197 | extensions::ViewType> ExtensionRenderViews; |
[email protected] | 3e19499 | 2011-10-20 05:39:10 | [diff] [blame] | 198 | |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame^] | 199 | // Load all background pages once the profile data is ready and the pages |
| 200 | // should be loaded. |
| 201 | void CreateStartupBackgroundHosts(); |
| 202 | |
[email protected] | 94de8cb | 2013-11-07 06:29:21 | [diff] [blame] | 203 | // Called just after |host| is created so it can be registered in our lists. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 204 | void OnBackgroundHostCreated(ExtensionHost* host); |
[email protected] | 94de8cb | 2013-11-07 06:29:21 | [diff] [blame] | 205 | |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 206 | // Close the given |host| iff it's a background page. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 207 | void CloseBackgroundHost(ExtensionHost* host); |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 208 | |
[email protected] | 38877015 | 2013-12-03 01:25:32 | [diff] [blame] | 209 | // Internal implementation of DecrementLazyKeepaliveCount with an |
| 210 | // |extension_id| known to have a lazy background page. |
| 211 | void DecrementLazyKeepaliveCount(const std::string& extension_id); |
| 212 | |
| 213 | // Checks if keepalive impulses have occured, and adjusts keep alive count. |
| 214 | void OnKeepaliveImpulseCheck(); |
| 215 | |
[email protected] | 6baff0b5 | 2012-03-06 01:30:18 | [diff] [blame] | 216 | // These are called when the extension transitions between idle and active. |
| 217 | // They control the process of closing the background page when idle. |
[email protected] | 99c49b5 | 2012-05-02 01:50:20 | [diff] [blame] | 218 | void OnLazyBackgroundPageIdle(const std::string& extension_id, |
[email protected] | 77a538f | 2014-07-14 22:25:37 | [diff] [blame] | 219 | uint64 sequence_id); |
[email protected] | 6baff0b5 | 2012-03-06 01:30:18 | [diff] [blame] | 220 | void OnLazyBackgroundPageActive(const std::string& extension_id); |
[email protected] | 0d475e07 | 2012-07-26 02:30:42 | [diff] [blame] | 221 | void CloseLazyBackgroundPageNow(const std::string& extension_id, |
[email protected] | 77a538f | 2014-07-14 22:25:37 | [diff] [blame] | 222 | uint64 sequence_id); |
[email protected] | 6baff0b5 | 2012-03-06 01:30:18 | [diff] [blame] | 223 | |
[email protected] | 35e0e079 | 2012-11-30 02:35:48 | [diff] [blame] | 224 | // Potentially registers a RenderViewHost, if it is associated with an |
| 225 | // extension. Does nothing if this is not an extension renderer. |
[email protected] | 96cac5e | 2014-02-18 16:22:15 | [diff] [blame] | 226 | // Returns true, if render_view_host was registered (it is associated |
| 227 | // with an extension). |
| 228 | bool RegisterRenderViewHost(content::RenderViewHost* render_view_host); |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 229 | |
[email protected] | 5b3ee85 | 2013-09-26 06:33:10 | [diff] [blame] | 230 | // Unregister RenderViewHosts and clear background page data for an extension |
| 231 | // which has been unloaded. |
| 232 | void UnregisterExtension(const std::string& extension_id); |
| 233 | |
[email protected] | caffe70 | 2012-05-03 05:30:17 | [diff] [blame] | 234 | // Clears background page data for this extension. |
| 235 | void ClearBackgroundPageData(const std::string& extension_id); |
| 236 | |
[email protected] | a23f62e | 2013-04-26 13:13:02 | [diff] [blame] | 237 | void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); |
| 238 | |
[email protected] | 35e0e079 | 2012-11-30 02:35:48 | [diff] [blame] | 239 | // Contains all active extension-related RenderViewHost instances for all |
| 240 | // extensions. We also keep a cache of the host's view type, because that |
| 241 | // information is not accessible at registration/deregistration time. |
| 242 | ExtensionRenderViews all_extension_views_; |
| 243 | |
[email protected] | 103f19f | 2012-04-02 19:30:12 | [diff] [blame] | 244 | BackgroundPageDataMap background_page_data_; |
| 245 | |
[email protected] | 99c49b5 | 2012-05-02 01:50:20 | [diff] [blame] | 246 | // The time to delay between an extension becoming idle and |
[email protected] | 584e657 | 2013-02-16 07:02:33 | [diff] [blame] | 247 | // sending a ShouldSuspend message; read from command-line switch. |
[email protected] | 99c49b5 | 2012-05-02 01:50:20 | [diff] [blame] | 248 | base::TimeDelta event_page_idle_time_; |
| 249 | |
[email protected] | 584e657 | 2013-02-16 07:02:33 | [diff] [blame] | 250 | // The time to delay between sending a ShouldSuspend message and |
| 251 | // sending a Suspend message; read from command-line switch. |
| 252 | base::TimeDelta event_page_suspending_time_; |
[email protected] | 99c49b5 | 2012-05-02 01:50:20 | [diff] [blame] | 253 | |
[email protected] | aa3dd49 | 2013-11-05 17:09:09 | [diff] [blame] | 254 | // True if we have created the startup set of background hosts. |
| 255 | bool startup_background_hosts_created_; |
| 256 | |
[email protected] | 75e7bac | 2013-11-01 23:33:42 | [diff] [blame] | 257 | base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; |
| 258 | |
[email protected] | b6cd720 | 2014-01-07 17:46:55 | [diff] [blame] | 259 | ImpulseCallbackForTesting keepalive_impulse_callback_for_testing_; |
| 260 | ImpulseCallbackForTesting keepalive_impulse_decrement_callback_for_testing_; |
| 261 | |
[email protected] | 08d469b2 | 2014-03-31 00:51:24 | [diff] [blame] | 262 | ObserverList<ProcessManagerObserver> observer_list_; |
| 263 | |
[email protected] | 77a538f | 2014-07-14 22:25:37 | [diff] [blame] | 264 | // ID Counter used to set ProcessManager::BackgroundPageData close_sequence_id |
| 265 | // members. These IDs are tracked per extension in background_page_data_ and |
| 266 | // are used to verify that nothing has interrupted the process of closing a |
| 267 | // lazy background process. |
| 268 | // |
| 269 | // Any interruption obtains a new ID by incrementing |
| 270 | // last_background_close_sequence_id_ and storing it in background_page_data_ |
| 271 | // for a particular extension. Callbacks and round-trip IPC messages store the |
| 272 | // value of the extension's close_sequence_id at the beginning of the process. |
| 273 | // Thus comparisons can be done to halt when IDs no longer match. |
| 274 | // |
| 275 | // This counter provides unique IDs even when BackgroundPageData objects are |
| 276 | // reset. |
| 277 | uint64 last_background_close_sequence_id_; |
| 278 | |
| 279 | // Must be last member, see doc on WeakPtrFactory. |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 280 | base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
[email protected] | 7f47421 | 2013-11-05 04:26:16 | [diff] [blame] | 281 | |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 282 | DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 283 | }; |
| 284 | |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 285 | } // namespace extensions |
| 286 | |
| 287 | #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |