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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/scoped_observer.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 21 #include "extensions/browser/extension_registry_observer.h" |
20 #include "extensions/common/view_type.h" | 22 #include "extensions/common/view_type.h" |
21 | 23 |
22 class GURL; | 24 class GURL; |
23 | 25 |
24 namespace content { | 26 namespace content { |
25 class BrowserContext; | 27 class BrowserContext; |
26 class DevToolsAgentHost; | 28 class DevToolsAgentHost; |
27 class RenderViewHost; | 29 class RenderViewHost; |
28 class RenderFrameHost; | 30 class RenderFrameHost; |
29 class SiteInstance; | 31 class SiteInstance; |
30 }; | 32 }; |
31 | 33 |
32 namespace extensions { | 34 namespace extensions { |
33 | 35 |
34 class Extension; | 36 class Extension; |
35 class ExtensionHost; | 37 class ExtensionHost; |
36 class ExtensionRegistry; | 38 class ExtensionRegistry; |
37 class ProcessManagerDelegate; | 39 class ProcessManagerDelegate; |
38 class ProcessManagerObserver; | 40 class ProcessManagerObserver; |
39 | 41 |
40 // Manages dynamic state of running Chromium extensions. There is one instance | 42 // 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 | 43 // of this class per Profile. OTR Profiles have a separate instance that keeps |
42 // track of split-mode extensions only. | 44 // track of split-mode extensions only. |
43 class ProcessManager : public content::NotificationObserver { | 45 class ProcessManager : public content::NotificationObserver, |
| 46 public ExtensionRegistryObserver { |
44 public: | 47 public: |
45 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; | 48 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; |
46 typedef ExtensionHostSet::const_iterator const_iterator; | 49 typedef ExtensionHostSet::const_iterator const_iterator; |
47 | 50 |
48 static ProcessManager* Create(content::BrowserContext* context); | 51 static ProcessManager* Create(content::BrowserContext* context); |
49 virtual ~ProcessManager(); | 52 virtual ~ProcessManager(); |
50 | 53 |
51 const ExtensionHostSet& background_hosts() const { | 54 const ExtensionHostSet& background_hosts() const { |
52 return background_hosts_; | 55 return background_hosts_; |
53 } | 56 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // |context| as |registry|, or override it for testing. | 169 // |context| as |registry|, or override it for testing. |
167 ProcessManager(content::BrowserContext* context, | 170 ProcessManager(content::BrowserContext* context, |
168 content::BrowserContext* original_context, | 171 content::BrowserContext* original_context, |
169 ExtensionRegistry* registry); | 172 ExtensionRegistry* registry); |
170 | 173 |
171 // content::NotificationObserver: | 174 // content::NotificationObserver: |
172 virtual void Observe(int type, | 175 virtual void Observe(int type, |
173 const content::NotificationSource& source, | 176 const content::NotificationSource& source, |
174 const content::NotificationDetails& details) OVERRIDE; | 177 const content::NotificationDetails& details) OVERRIDE; |
175 | 178 |
| 179 // ExtensionRegistryObserver: |
| 180 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 181 const Extension* extension) OVERRIDE; |
| 182 virtual void OnExtensionUnloaded( |
| 183 content::BrowserContext* browser_context, |
| 184 const Extension* extension, |
| 185 UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 186 |
176 content::NotificationRegistrar registrar_; | 187 content::NotificationRegistrar registrar_; |
177 | 188 |
178 // The set of ExtensionHosts running viewless background extensions. | 189 // The set of ExtensionHosts running viewless background extensions. |
179 ExtensionHostSet background_hosts_; | 190 ExtensionHostSet background_hosts_; |
180 | 191 |
181 // A SiteInstance related to the SiteInstance for all extensions in | 192 // A SiteInstance related to the SiteInstance for all extensions in |
182 // this profile. We create it in such a way that a new | 193 // this profile. We create it in such a way that a new |
183 // browsing instance is created. This controls process grouping. | 194 // browsing instance is created. This controls process grouping. |
184 scoped_refptr<content::SiteInstance> site_instance_; | 195 scoped_refptr<content::SiteInstance> site_instance_; |
185 | 196 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // value of the extension's close_sequence_id at the beginning of the process. | 283 // 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. | 284 // Thus comparisons can be done to halt when IDs no longer match. |
274 // | 285 // |
275 // This counter provides unique IDs even when BackgroundPageData objects are | 286 // This counter provides unique IDs even when BackgroundPageData objects are |
276 // reset. | 287 // reset. |
277 uint64 last_background_close_sequence_id_; | 288 uint64 last_background_close_sequence_id_; |
278 | 289 |
279 // Must be last member, see doc on WeakPtrFactory. | 290 // Must be last member, see doc on WeakPtrFactory. |
280 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 291 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
281 | 292 |
| 293 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 294 extension_registry_observer_; |
| 295 |
282 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 296 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
283 }; | 297 }; |
284 | 298 |
285 } // namespace extensions | 299 } // namespace extensions |
286 | 300 |
287 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 301 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
OLD | NEW |