blob: 42fc68a5d8439197439f0e0d6dcb99c2e035a74f [file] [log] [blame]
[email protected]98b6d942013-11-10 00:34:071// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]481e1a42009-05-06 20:56:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]98b6d942013-11-10 00:34:075#ifndef EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
6#define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
[email protected]481e1a42009-05-06 20:56:057
avic9cec102015-12-23 00:39:268#include <stdint.h>
9
[email protected]45776222009-07-15 20:21:5810#include <map>
[email protected]8a17bd52009-06-06 08:19:4911#include <set>
[email protected]45776222009-07-15 20:21:5812#include <string>
David Bertoni3e1e9fa2018-08-29 20:39:3013#include <utility>
Istiaque Ahmedb744ecf2019-02-06 00:23:3214#include <vector>
[email protected]481e1a42009-05-06 20:56:0515
[email protected]a23f62e2013-04-26 13:13:0216#include "base/callback.h"
[email protected]17902752011-08-31 22:52:5417#include "base/compiler_specific.h"
avic9cec102015-12-23 00:39:2618#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1519#include "base/memory/ref_counted.h"
[email protected]99c49b52012-05-02 01:50:2020#include "base/memory/weak_ptr.h"
[email protected]08d469b22014-03-31 00:51:2421#include "base/observer_list.h"
Istiaque Ahmedd4b67ee2019-03-02 10:53:2022#include "base/scoped_observer.h"
reillyg0ea3fa902014-10-28 15:30:2323#include "components/keyed_service/core/keyed_service.h"
dgozman47679eb12016-10-17 17:30:1824#include "content/public/browser/devtools_agent_host_observer.h"
[email protected]6c2381d2011-10-19 02:52:5325#include "content/public/browser/notification_observer.h"
26#include "content/public/browser/notification_registrar.h"
Evan Stade922f3f1f2019-09-04 21:05:1327#include "content/public/browser/render_process_host.h"
Istiaque Ahmedd4b67ee2019-03-02 10:53:2028#include "content/public/browser/render_process_host_observer.h"
David Bertoni3e1e9fa2018-08-29 20:39:3029#include "extensions/browser/activity.h"
kmarshall24b29b22015-04-29 01:41:4730#include "extensions/browser/event_page_tracker.h"
limasdfe0f061b2015-02-27 00:35:0631#include "extensions/browser/extension_registry_observer.h"
Istiaque Ahmedb744ecf2019-02-06 00:23:3232#include "extensions/browser/service_worker/worker_id.h"
33#include "extensions/browser/service_worker/worker_id_set.h"
rdevlin.cronin0670b562016-07-02 02:05:4334#include "extensions/common/extension_id.h"
[email protected]cb2edf22013-04-01 20:25:2335#include "extensions/common/view_type.h"
[email protected]481e1a42009-05-06 20:56:0536
[email protected]481e1a42009-05-06 20:56:0537class GURL;
[email protected]b6583592012-01-25 19:52:3338
39namespace content {
[email protected]7f474212013-11-05 04:26:1640class BrowserContext;
[email protected]a23f62e2013-04-26 13:13:0241class DevToolsAgentHost;
[email protected]9dfed872013-12-30 23:08:5642class RenderFrameHost;
[email protected]481e1a42009-05-06 20:56:0543class SiteInstance;
rdevlin.cronin6ae04a012015-04-03 20:19:4044class WebContents;
Nico Weber210c0bc2019-02-11 22:01:0945} // namespace content
[email protected]481e1a42009-05-06 20:56:0546
[email protected]1c321ee2012-05-21 03:02:3447namespace extensions {
[email protected]98b6d942013-11-10 00:34:0748
[email protected]1c321ee2012-05-21 03:02:3449class Extension;
[email protected]3a1dc572012-07-31 22:25:1350class ExtensionHost;
[email protected]6b54fda2014-07-22 02:13:4751class ExtensionRegistry;
[email protected]08d469b22014-03-31 00:51:2452class ProcessManagerObserver;
[email protected]1c321ee2012-05-21 03:02:3453
[email protected]bc535ee52010-08-31 18:40:3254// Manages dynamic state of running Chromium extensions. There is one instance
55// of this class per Profile. OTR Profiles have a separate instance that keeps
56// track of split-mode extensions only.
reillyg0ea3fa902014-10-28 15:30:2357class ProcessManager : public KeyedService,
limasdfe0f061b2015-02-27 00:35:0658 public content::NotificationObserver,
kmarshall24b29b22015-04-29 01:41:4759 public ExtensionRegistryObserver,
dgozman47679eb12016-10-17 17:30:1860 public EventPageTracker,
Istiaque Ahmedd4b67ee2019-03-02 10:53:2061 public content::DevToolsAgentHostObserver,
62 public content::RenderProcessHostObserver {
[email protected]481e1a42009-05-06 20:56:0563 public:
rdevlin.cronin6ae04a012015-04-03 20:19:4064 using ExtensionHostSet = std::set<extensions::ExtensionHost*>;
[email protected]d1fe1352012-04-26 00:47:3265
reillyg0ea3fa902014-10-28 15:30:2366 static ProcessManager* Get(content::BrowserContext* context);
dcheng9168b2f2014-10-21 12:38:2467 ~ProcessManager() override;
[email protected]481e1a42009-05-06 20:56:0568
sense383ce0f2017-03-24 04:06:4369 // KeyedService support:
70 void Shutdown() override;
71
rdevlin.cronin6ae04a012015-04-03 20:19:4072 void RegisterRenderFrameHost(content::WebContents* web_contents,
73 content::RenderFrameHost* render_frame_host,
74 const Extension* extension);
75 void UnregisterRenderFrameHost(content::RenderFrameHost* render_frame_host);
[email protected]d1fe1352012-04-26 00:47:3276
Istiaque Ahmedb744ecf2019-02-06 00:23:3277 // Registers or unregisters a running worker state to this process manager.
78 // Note: This does not create any Service Workers.
Istiaque Ahmedb744ecf2019-02-06 00:23:3279 void RegisterServiceWorker(const WorkerId& worker_id);
80 void UnregisterServiceWorker(const WorkerId& worker_id);
81
rdevlin.cronin6ae04a012015-04-03 20:19:4082 // Returns the SiteInstance that the given URL belongs to.
83 // TODO(aa): This only returns correct results for extensions and packaged
84 // apps, not hosted apps.
85 virtual scoped_refptr<content::SiteInstance> GetSiteInstanceForURL(
86 const GURL& url);
[email protected]d1fe1352012-04-26 00:47:3287
rdevlin.cronin6ae04a012015-04-03 20:19:4088 using FrameSet = std::set<content::RenderFrameHost*>;
89 const FrameSet GetAllFrames() const;
90
91 // Returns all RenderFrameHosts that are registered for the specified
92 // extension.
93 ProcessManager::FrameSet GetRenderFrameHostsForExtension(
94 const std::string& extension_id);
95
robcdcc4b82015-12-06 12:39:4596 bool IsRenderFrameHostRegistered(content::RenderFrameHost* render_frame_host);
97
[email protected]08d469b22014-03-31 00:51:2498 void AddObserver(ProcessManagerObserver* observer);
99 void RemoveObserver(ProcessManagerObserver* observer);
100
[email protected]029ad372011-05-20 17:12:56101 // Creates a new UI-less extension instance. Like CreateViewHost, but not
[email protected]6ad9cdf72014-02-27 13:12:41102 // displayed anywhere. Returns false if no background host can be created,
103 // for example for hosted apps and extensions that aren't enabled in
104 // Incognito.
105 virtual bool CreateBackgroundHost(const Extension* extension,
106 const GURL& url);
[email protected]bc535ee52010-08-31 18:40:32107
rdevlin.cronin6ae04a012015-04-03 20:19:40108 // Creates background hosts if the embedder is ready and they are not already
109 // loaded.
110 void MaybeCreateStartupBackgroundHosts();
111
112 // Gets the ExtensionHost for the background page for an extension, or null if
[email protected]4814b512009-11-07 00:12:29113 // the extension isn't running or doesn't have a background page.
[email protected]98b6d942013-11-10 00:34:07114 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id);
[email protected]4814b512009-11-07 00:12:29115
rdevlin.croninb48a98e2015-05-01 00:00:28116 // Returns the ExtensionHost for the given |render_frame_host|, if there is
117 // one.
118 ExtensionHost* GetExtensionHostForRenderFrameHost(
119 content::RenderFrameHost* render_frame_host);
120
[email protected]7042b682012-04-19 22:57:51121 // Returns true if the (lazy) background host for the given extension has
122 // already been sent the unload event and is shutting down.
123 bool IsBackgroundHostClosing(const std::string& extension_id);
124
Devlin Cronin7a282e32017-08-10 01:54:10125 // Returns the extension associated with the specified RenderFrameHost,
126 // or null.
rdevlin.cronin6ae04a012015-04-03 20:19:40127 const Extension* GetExtensionForRenderFrameHost(
128 content::RenderFrameHost* render_frame_host);
Devlin Cronin7a282e32017-08-10 01:54:10129
130 // Returns the extension associated with the main frame of the given
131 // |web_contents|, or null if there isn't one.
rdevlin.cronin6ae04a012015-04-03 20:19:40132 const Extension* GetExtensionForWebContents(
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41133 content::WebContents* web_contents);
rdevlin.cronin6ae04a012015-04-03 20:19:40134
[email protected]720ad1312012-02-27 23:07:36135 // Getter and setter for the lazy background page's keepalive count. This is
136 // the count of how many outstanding "things" are keeping the page alive.
137 // When this reaches 0, we will begin the process of shutting down the page.
138 // "Things" include pending events, resource loads, and API calls.
wez714dde12017-02-14 22:26:03139 // Returns -1 if |extension| does not have a lazy background page.
David Bertoni3e1e9fa2018-08-29 20:39:30140 // The calls to increment and decrement the count also accept a category
141 // of activity and an extra string of data. These are kept so there is
142 // more information for the counts. See the Activity struct definition
143 // for more details regarding the extra data.
[email protected]98b6d942013-11-10 00:34:07144 int GetLazyKeepaliveCount(const Extension* extension);
David Bertoni3e1e9fa2018-08-29 20:39:30145 void IncrementLazyKeepaliveCount(const Extension* extension,
146 Activity::Type activity_type,
147 const std::string& extra_data);
148 void DecrementLazyKeepaliveCount(const Extension* extension,
149 Activity::Type activity_type,
150 const std::string& extra_data);
151
Istiaque Ahmedb744ecf2019-02-06 00:23:32152 // Methods to increment or decrement the ref-count of a specified service
153 // worker with id |worker_id|.
154 // The increment method returns the guid that needs to be passed to the
155 // decrement method.
156 std::string IncrementServiceWorkerKeepaliveCount(
157 const WorkerId& worker_id,
158 Activity::Type activity_type,
159 const std::string& extra_data);
160 // Decrements the ref-count of the specified worker with |worker_id| that
161 // had its ref-count incremented with |request_uuid|.
162 void DecrementServiceWorkerKeepaliveCount(const WorkerId& worker_id,
163 const std::string& request_uuid,
164 Activity::Type activity_type,
165 const std::string& extra_data);
166
David Bertoni3e1e9fa2018-08-29 20:39:30167 using ActivitiesMultisetPair = std::pair<Activity::Type, std::string>;
168 using ActivitiesMultiset = std::multiset<ActivitiesMultisetPair>;
169
170 // Return the current set of keep-alive activities for the extension.
171 ActivitiesMultiset GetLazyKeepaliveActivities(const Extension* extension);
[email protected]720ad1312012-02-27 23:07:36172
[email protected]584e6572013-02-16 07:02:33173 // Handles a response to the ShouldSuspend message, used for lazy background
[email protected]720ad1312012-02-27 23:07:36174 // pages.
avic9cec102015-12-23 00:39:26175 void OnShouldSuspendAck(const std::string& extension_id,
176 uint64_t sequence_id);
[email protected]103f19f2012-04-02 19:30:12177
[email protected]584e6572013-02-16 07:02:33178 // Same as above, for the Suspend message.
179 void OnSuspendAck(const std::string& extension_id);
[email protected]06024c62011-10-20 20:57:12180
[email protected]9dfed872013-12-30 23:08:56181 // Tracks network requests for a given RenderFrameHost, used to know
[email protected]6baff0b52012-03-06 01:30:18182 // when network activity is idle for lazy background pages.
chirantan79788f62015-02-02 23:57:25183 void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host,
avic9cec102015-12-23 00:39:26184 uint64_t request_id);
chirantan79788f62015-02-02 23:57:25185 void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host,
avic9cec102015-12-23 00:39:26186 uint64_t request_id);
[email protected]6baff0b52012-03-06 01:30:18187
[email protected]0d475e072012-07-26 02:30:42188 // Prevents |extension|'s background page from being closed and sends the
189 // onSuspendCanceled() event to it.
[email protected]98b6d942013-11-10 00:34:07190 void CancelSuspend(const Extension* extension);
[email protected]0d475e072012-07-26 02:30:42191
[email protected]9602db42014-07-25 05:24:37192 // Called on shutdown to close our extension hosts.
193 void CloseBackgroundHosts();
194
kmarshall24b29b22015-04-29 01:41:47195 // EventPageTracker implementation.
196 bool IsEventPageSuspended(const std::string& extension_id) override;
197 bool WakeEventPage(const std::string& extension_id,
Istiaque Ahmed28edfd22018-08-30 23:40:47198 base::OnceCallback<void(bool)> callback) override;
kmarshall24b29b22015-04-29 01:41:47199
yoza9bf5602014-09-19 02:03:31200 // Sets the time in milliseconds that an extension event page can
201 // be idle before it is shut down; must be > 0.
202 static void SetEventPageIdleTimeForTesting(unsigned idle_time_msec);
203
204 // Sets the time in milliseconds that an extension event page has
205 // between being notified of its impending unload and that unload
206 // happening.
207 static void SetEventPageSuspendingTimeForTesting(
208 unsigned suspending_time_msec);
209
[email protected]6b54fda2014-07-22 02:13:47210 // Creates a non-incognito instance for tests. |registry| allows unit tests
211 // to inject an ExtensionRegistry that is not managed by the usual
212 // BrowserContextKeyedServiceFactory system.
213 static ProcessManager* CreateForTesting(content::BrowserContext* context,
214 ExtensionRegistry* registry);
215
216 // Creates an incognito-context instance for tests.
[email protected]b9f6ba32014-03-10 18:34:08217 static ProcessManager* CreateIncognitoForTesting(
218 content::BrowserContext* incognito_context,
219 content::BrowserContext* original_context,
[email protected]6b54fda2014-07-22 02:13:47220 ExtensionRegistry* registry);
221
rdevlin.cronin6ae04a012015-04-03 20:19:40222 content::BrowserContext* browser_context() const { return browser_context_; }
223
224 const ExtensionHostSet& background_hosts() const {
225 return background_hosts_;
226 }
227
Istiaque Ahmedb744ecf2019-02-06 00:23:32228 // Returns true if this ProcessManager has registered any worker with id
229 // |worker_id|.
230 bool HasServiceWorker(const WorkerId& worker_id) const;
231
232 // Returns all the Service Worker infos that is active in the given render
233 // process for the extension with |extension_id|.
234 std::vector<WorkerId> GetServiceWorkers(const ExtensionId& extension_id,
235 int render_process_id) const;
236
Ghazale Hosseinabadib11bca622020-09-22 21:15:50237 // Returns all the Service Worker infos that is active for the extension with
238 // |extension_id|.
239 std::vector<WorkerId> GetServiceWorkersForExtension(
240 const ExtensionId& extension_id) const;
241
[email protected]6b54fda2014-07-22 02:13:47242 bool startup_background_hosts_created_for_test() const {
243 return startup_background_hosts_created_;
244 }
[email protected]b9f6ba32014-03-10 18:34:08245
Istiaque Ahmedd4b67ee2019-03-02 10:53:20246 std::vector<WorkerId> GetAllWorkersIdsForTesting();
247
[email protected]bc535ee52010-08-31 18:40:32248 protected:
reillyg0ea3fa902014-10-28 15:30:23249 static ProcessManager* Create(content::BrowserContext* context);
250
Reilly Grant58ea3832020-06-24 17:47:55251 // |context| is incognito pass the original context as |original_context|.
[email protected]6b54fda2014-07-22 02:13:47252 // Otherwise pass the same context for both. Pass the ExtensionRegistry for
253 // |context| as |registry|, or override it for testing.
[email protected]98b6d942013-11-10 00:34:07254 ProcessManager(content::BrowserContext* context,
[email protected]6b54fda2014-07-22 02:13:47255 content::BrowserContext* original_context,
256 ExtensionRegistry* registry);
[email protected]bc535ee52010-08-31 18:40:32257
rdevlin.cronin6ae04a012015-04-03 20:19:40258 // Not owned. Also used by IncognitoProcessManager.
259 ExtensionRegistry* extension_registry_;
260
261 private:
262 friend class ProcessManagerFactory;
263 friend class ProcessManagerTest;
264
[email protected]6c2381d2011-10-19 02:52:53265 // content::NotificationObserver:
dcheng9168b2f2014-10-21 12:38:24266 void Observe(int type,
267 const content::NotificationSource& source,
268 const content::NotificationDetails& details) override;
[email protected]bc535ee52010-08-31 18:40:32269
limasdfe0f061b2015-02-27 00:35:06270 // ExtensionRegistryObserver:
271 void OnExtensionLoaded(content::BrowserContext* browser_context,
272 const Extension* extension) override;
273 void OnExtensionUnloaded(content::BrowserContext* browser_context,
274 const Extension* extension,
limasdf0deef2042017-05-03 19:17:17275 UnloadedExtensionReason reason) override;
limasdfe0f061b2015-02-27 00:35:06276
Istiaque Ahmedd4b67ee2019-03-02 10:53:20277 // content::RenderProcessHostObserver:
278 void RenderProcessExited(
279 content::RenderProcessHost* host,
280 const content::ChildProcessTerminationInfo& info) override;
281
[email protected]103f19f2012-04-02 19:30:12282 // Extra information we keep for each extension's background page.
283 struct BackgroundPageData;
rdevlin.cronin6ae04a012015-04-03 20:19:40284 struct ExtensionRenderFrameData;
285 using BackgroundPageDataMap = std::map<ExtensionId, BackgroundPageData>;
286 using ExtensionRenderFrames =
287 std::map<content::RenderFrameHost*, ExtensionRenderFrameData>;
[email protected]3e194992011-10-20 05:39:10288
[email protected]6b54fda2014-07-22 02:13:47289 // Load all background pages once the profile data is ready and the pages
290 // should be loaded.
291 void CreateStartupBackgroundHosts();
292
[email protected]94de8cb2013-11-07 06:29:21293 // Called just after |host| is created so it can be registered in our lists.
[email protected]98b6d942013-11-10 00:34:07294 void OnBackgroundHostCreated(ExtensionHost* host);
[email protected]94de8cb2013-11-07 06:29:21295
[email protected]06024c62011-10-20 20:57:12296 // Close the given |host| iff it's a background page.
[email protected]98b6d942013-11-10 00:34:07297 void CloseBackgroundHost(ExtensionHost* host);
[email protected]06024c62011-10-20 20:57:12298
rdevlin.cronin6ae04a012015-04-03 20:19:40299 // If the frame isn't keeping the lazy background page alive, increments the
300 // keepalive count to do so.
301 void AcquireLazyKeepaliveCountForFrame(
302 content::RenderFrameHost* render_frame_host);
303
304 // If the frame is keeping the lazy background page alive, decrements the
305 // keepalive count to stop doing it.
306 void ReleaseLazyKeepaliveCountForFrame(
307 content::RenderFrameHost* render_frame_host);
308
[email protected]388770152013-12-03 01:25:32309 // Internal implementation of DecrementLazyKeepaliveCount with an
310 // |extension_id| known to have a lazy background page.
311 void DecrementLazyKeepaliveCount(const std::string& extension_id);
David Bertoni3e1e9fa2018-08-29 20:39:30312 void DecrementLazyKeepaliveCount(const std::string& extension_id,
313 Activity::Type activity_type,
314 const std::string& extra_data);
[email protected]388770152013-12-03 01:25:32315
[email protected]6baff0b52012-03-06 01:30:18316 // These are called when the extension transitions between idle and active.
317 // They control the process of closing the background page when idle.
[email protected]99c49b52012-05-02 01:50:20318 void OnLazyBackgroundPageIdle(const std::string& extension_id,
avic9cec102015-12-23 00:39:26319 uint64_t sequence_id);
[email protected]6baff0b52012-03-06 01:30:18320 void OnLazyBackgroundPageActive(const std::string& extension_id);
[email protected]0d475e072012-07-26 02:30:42321 void CloseLazyBackgroundPageNow(const std::string& extension_id,
avic9cec102015-12-23 00:39:26322 uint64_t sequence_id);
[email protected]6baff0b52012-03-06 01:30:18323
dgozman47679eb12016-10-17 17:30:18324 const Extension* GetExtensionForAgentHost(
325 content::DevToolsAgentHost* agent_host);
326
327 // content::DevToolsAgentHostObserver overrides.
328 void DevToolsAgentHostAttached(
329 content::DevToolsAgentHost* agent_host) override;
330 void DevToolsAgentHostDetached(
331 content::DevToolsAgentHost* agent_host) override;
[email protected]06024c62011-10-20 20:57:12332
rdevlin.cronin6ae04a012015-04-03 20:19:40333 // Unregister RenderFrameHosts and clear background page data for an extension
[email protected]5b3ee852013-09-26 06:33:10334 // which has been unloaded.
335 void UnregisterExtension(const std::string& extension_id);
336
[email protected]caffe702012-05-03 05:30:17337 // Clears background page data for this extension.
338 void ClearBackgroundPageData(const std::string& extension_id);
339
rdevlin.cronin6ae04a012015-04-03 20:19:40340 content::NotificationRegistrar registrar_;
[email protected]a23f62e2013-04-26 13:13:02341
rdevlin.cronin6ae04a012015-04-03 20:19:40342 // The set of ExtensionHosts running viewless background extensions.
343 ExtensionHostSet background_hosts_;
344
345 // A SiteInstance related to the SiteInstance for all extensions in
346 // this profile. We create it in such a way that a new
347 // browsing instance is created. This controls process grouping.
348 scoped_refptr<content::SiteInstance> site_instance_;
349
350 // The browser context associated with the |site_instance_|.
351 content::BrowserContext* browser_context_;
352
353 // Contains all active extension-related RenderFrameHost instances for all
[email protected]35e0e0792012-11-30 02:35:48354 // extensions. We also keep a cache of the host's view type, because that
355 // information is not accessible at registration/deregistration time.
rdevlin.cronin6ae04a012015-04-03 20:19:40356 ExtensionRenderFrames all_extension_frames_;
[email protected]35e0e0792012-11-30 02:35:48357
Istiaque Ahmedb744ecf2019-02-06 00:23:32358 // TaskRunner for interacting with ServiceWorkerContexts.
Matt Falkenhagend55b9282019-09-10 23:53:35359 // TODO(crbug.com/824858): This is unused when ServiceWorkerOnUI is enabled.
Istiaque Ahmedb744ecf2019-02-06 00:23:32360 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
361
362 // Contains all active extension Service Worker information for all
363 // extensions.
364 WorkerIdSet all_extension_workers_;
365
[email protected]103f19f2012-04-02 19:30:12366 BackgroundPageDataMap background_page_data_;
367
[email protected]aa3dd492013-11-05 17:09:09368 // True if we have created the startup set of background hosts.
369 bool startup_background_hosts_created_;
370
Evan Stade22e3f9b2019-10-01 21:12:17371 base::ObserverList<ProcessManagerObserver> observer_list_;
[email protected]08d469b22014-03-31 00:51:24372
[email protected]77a538f2014-07-14 22:25:37373 // ID Counter used to set ProcessManager::BackgroundPageData close_sequence_id
374 // members. These IDs are tracked per extension in background_page_data_ and
375 // are used to verify that nothing has interrupted the process of closing a
376 // lazy background process.
377 //
378 // Any interruption obtains a new ID by incrementing
379 // last_background_close_sequence_id_ and storing it in background_page_data_
380 // for a particular extension. Callbacks and round-trip IPC messages store the
381 // value of the extension's close_sequence_id at the beginning of the process.
382 // Thus comparisons can be done to halt when IDs no longer match.
383 //
384 // This counter provides unique IDs even when BackgroundPageData objects are
385 // reset.
avic9cec102015-12-23 00:39:26386 uint64_t last_background_close_sequence_id_;
[email protected]77a538f2014-07-14 22:25:37387
rockote5703292015-09-28 23:23:09388 // Tracks pending network requests by opaque ID. This is used to ensure proper
389 // keepalive counting in response to request status updates; e.g., if an
390 // extension URLRequest is constructed and then destroyed without ever
391 // starting, we can receive a completion notification without a corresponding
392 // start notification. In that case we want to avoid decrementing keepalive.
naskod13fd292016-06-07 20:33:33393 std::map<int, ExtensionHost*> pending_network_requests_;
rockote5703292015-09-28 23:23:09394
Istiaque Ahmedd4b67ee2019-03-02 10:53:20395 // Observers of Service Worker RPH this ProcessManager manages.
396 ScopedObserver<content::RenderProcessHost, content::RenderProcessHostObserver>
Evan Stade922f3f1f2019-09-04 21:05:13397 process_observer_{this};
Istiaque Ahmedd4b67ee2019-03-02 10:53:20398 // Maps render render_process_id -> extension_id for all Service Workers this
399 // ProcessManager manages.
400 std::map<int, std::set<ExtensionId>> worker_process_to_extension_ids_;
401
[email protected]77a538f2014-07-14 22:25:37402 // Must be last member, see doc on WeakPtrFactory.
Jeremy Roman9fc2de62019-07-12 14:15:03403 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_{this};
[email protected]7f474212013-11-05 04:26:16404
[email protected]98b6d942013-11-10 00:34:07405 DISALLOW_COPY_AND_ASSIGN(ProcessManager);
[email protected]481e1a42009-05-06 20:56:05406};
407
[email protected]98b6d942013-11-10 00:34:07408} // namespace extensions
409
410#endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_