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; |
| 38 class ExtensionRegistry; |
36 class ProcessManagerDelegate; | 39 class ProcessManagerDelegate; |
37 class ProcessManagerObserver; | 40 class ProcessManagerObserver; |
38 | 41 |
39 // Manages dynamic state of running Chromium extensions. There is one instance | 42 // Manages dynamic state of running Chromium extensions. There is one instance |
40 // 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 |
41 // track of split-mode extensions only. | 44 // track of split-mode extensions only. |
42 class ProcessManager : public content::NotificationObserver { | 45 class ProcessManager : public content::NotificationObserver, |
| 46 public ExtensionRegistryObserver { |
43 public: | 47 public: |
44 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; | 48 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; |
45 typedef ExtensionHostSet::const_iterator const_iterator; | 49 typedef ExtensionHostSet::const_iterator const_iterator; |
46 | 50 |
47 static ProcessManager* Create(content::BrowserContext* context); | 51 static ProcessManager* Create(content::BrowserContext* context); |
48 virtual ~ProcessManager(); | 52 virtual ~ProcessManager(); |
49 | 53 |
50 const ExtensionHostSet& background_hosts() const { | 54 const ExtensionHostSet& background_hosts() const { |
51 return background_hosts_; | 55 return background_hosts_; |
52 } | 56 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 content::BrowserContext* original_context); | 161 content::BrowserContext* original_context); |
158 | 162 |
159 // Called on browser shutdown to close our extension hosts. | 163 // Called on browser shutdown to close our extension hosts. |
160 void CloseBackgroundHosts(); | 164 void CloseBackgroundHosts(); |
161 | 165 |
162 // content::NotificationObserver: | 166 // content::NotificationObserver: |
163 virtual void Observe(int type, | 167 virtual void Observe(int type, |
164 const content::NotificationSource& source, | 168 const content::NotificationSource& source, |
165 const content::NotificationDetails& details) OVERRIDE; | 169 const content::NotificationDetails& details) OVERRIDE; |
166 | 170 |
| 171 // ExtensionRegistryObserver: |
| 172 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 173 const Extension* extension) OVERRIDE; |
| 174 virtual void OnExtensionUnloaded( |
| 175 content::BrowserContext* browser_context, |
| 176 const Extension* extension, |
| 177 UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 178 |
167 content::NotificationRegistrar registrar_; | 179 content::NotificationRegistrar registrar_; |
168 | 180 |
169 // The set of ExtensionHosts running viewless background extensions. | 181 // The set of ExtensionHosts running viewless background extensions. |
170 ExtensionHostSet background_hosts_; | 182 ExtensionHostSet background_hosts_; |
171 | 183 |
172 // A SiteInstance related to the SiteInstance for all extensions in | 184 // A SiteInstance related to the SiteInstance for all extensions in |
173 // this profile. We create it in such a way that a new | 185 // this profile. We create it in such a way that a new |
174 // browsing instance is created. This controls process grouping. | 186 // browsing instance is created. This controls process grouping. |
175 scoped_refptr<content::SiteInstance> site_instance_; | 187 scoped_refptr<content::SiteInstance> site_instance_; |
176 | 188 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // value of the extension's close_sequence_id at the beginning of the process. | 272 // value of the extension's close_sequence_id at the beginning of the process. |
261 // Thus comparisons can be done to halt when IDs no longer match. | 273 // Thus comparisons can be done to halt when IDs no longer match. |
262 // | 274 // |
263 // This counter provides unique IDs even when BackgroundPageData objects are | 275 // This counter provides unique IDs even when BackgroundPageData objects are |
264 // reset. | 276 // reset. |
265 uint64 last_background_close_sequence_id_; | 277 uint64 last_background_close_sequence_id_; |
266 | 278 |
267 // Must be last member, see doc on WeakPtrFactory. | 279 // Must be last member, see doc on WeakPtrFactory. |
268 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 280 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
269 | 281 |
| 282 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 283 extension_registry_observer_; |
| 284 |
270 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 285 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
271 }; | 286 }; |
272 | 287 |
273 } // namespace extensions | 288 } // namespace extensions |
274 | 289 |
275 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 290 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
OLD | NEW |