| 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/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "extensions/browser/extension_registry_observer.h" |
| 20 #include "extensions/common/view_type.h" | 21 #include "extensions/common/view_type.h" |
| 21 | 22 |
| 22 class GURL; | 23 class GURL; |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class BrowserContext; | 26 class BrowserContext; |
| 26 class DevToolsAgentHost; | 27 class DevToolsAgentHost; |
| 27 class RenderViewHost; | 28 class RenderViewHost; |
| 28 class RenderFrameHost; | 29 class RenderFrameHost; |
| 29 class SiteInstance; | 30 class SiteInstance; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 namespace extensions { | 33 namespace extensions { |
| 33 | 34 |
| 34 class Extension; | 35 class Extension; |
| 35 class ExtensionHost; | 36 class ExtensionHost; |
| 36 class ExtensionRegistry; | 37 class ExtensionRegistry; |
| 37 class ProcessManagerDelegate; | 38 class ProcessManagerDelegate; |
| 38 class ProcessManagerObserver; | 39 class ProcessManagerObserver; |
| 39 | 40 |
| 40 // Manages dynamic state of running Chromium extensions. There is one instance | 41 // 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 // of this class per Profile. OTR Profiles have a separate instance that keeps |
| 42 // track of split-mode extensions only. | 43 // track of split-mode extensions only. |
| 43 class ProcessManager : public content::NotificationObserver { | 44 class ProcessManager : public content::NotificationObserver, |
| 45 public extensions::ExtensionRegistryObserver { |
| 44 public: | 46 public: |
| 45 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; | 47 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; |
| 46 typedef ExtensionHostSet::const_iterator const_iterator; | 48 typedef ExtensionHostSet::const_iterator const_iterator; |
| 47 | 49 |
| 48 static ProcessManager* Create(content::BrowserContext* context); | 50 static ProcessManager* Create(content::BrowserContext* context); |
| 49 virtual ~ProcessManager(); | 51 virtual ~ProcessManager(); |
| 50 | 52 |
| 51 const ExtensionHostSet& background_hosts() const { | 53 const ExtensionHostSet& background_hosts() const { |
| 52 return background_hosts_; | 54 return background_hosts_; |
| 53 } | 55 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // |context| as |registry|, or override it for testing. | 173 // |context| as |registry|, or override it for testing. |
| 172 ProcessManager(content::BrowserContext* context, | 174 ProcessManager(content::BrowserContext* context, |
| 173 content::BrowserContext* original_context, | 175 content::BrowserContext* original_context, |
| 174 ExtensionRegistry* registry); | 176 ExtensionRegistry* registry); |
| 175 | 177 |
| 176 // content::NotificationObserver: | 178 // content::NotificationObserver: |
| 177 virtual void Observe(int type, | 179 virtual void Observe(int type, |
| 178 const content::NotificationSource& source, | 180 const content::NotificationSource& source, |
| 179 const content::NotificationDetails& details) OVERRIDE; | 181 const content::NotificationDetails& details) OVERRIDE; |
| 180 | 182 |
| 183 // extensions::ExtensionRegistryObserver: |
| 184 virtual void OnExtensionLoaded( |
| 185 content::BrowserContext* browser_context, |
| 186 const extensions::Extension* extension) OVERRIDE; |
| 187 |
| 188 virtual void OnExtensionUnloaded( |
| 189 content::BrowserContext* browser_context, |
| 190 const extensions::Extension* extension, |
| 191 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 192 |
| 181 content::NotificationRegistrar registrar_; | 193 content::NotificationRegistrar registrar_; |
| 182 | 194 |
| 183 // The set of ExtensionHosts running viewless background extensions. | 195 // The set of ExtensionHosts running viewless background extensions. |
| 184 ExtensionHostSet background_hosts_; | 196 ExtensionHostSet background_hosts_; |
| 185 | 197 |
| 186 // A SiteInstance related to the SiteInstance for all extensions in | 198 // A SiteInstance related to the SiteInstance for all extensions in |
| 187 // this profile. We create it in such a way that a new | 199 // this profile. We create it in such a way that a new |
| 188 // browsing instance is created. This controls process grouping. | 200 // browsing instance is created. This controls process grouping. |
| 189 scoped_refptr<content::SiteInstance> site_instance_; | 201 scoped_refptr<content::SiteInstance> site_instance_; |
| 190 | 202 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 295 |
| 284 // Must be last member, see doc on WeakPtrFactory. | 296 // Must be last member, see doc on WeakPtrFactory. |
| 285 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 297 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
| 286 | 298 |
| 287 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 299 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
| 288 }; | 300 }; |
| 289 | 301 |
| 290 } // namespace extensions | 302 } // namespace extensions |
| 291 | 303 |
| 292 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 304 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
| OLD | NEW |