| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 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 "content/public/common/view_type.h" | 15 #include "content/public/common/view_type.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 | 18 |
| 19 class Browser; | 19 class Browser; |
| 20 class Extension; | 20 class Extension; |
| 21 class ExtensionHost; | 21 class ExtensionHost; |
| 22 class GURL; | 22 class GURL; |
| 23 class Profile; | 23 class Profile; |
| 24 class RenderViewHost; | |
| 25 | 24 |
| 26 namespace content { | 25 namespace content { |
| 26 class RenderViewHost; |
| 27 class SiteInstance; | 27 class SiteInstance; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // Manages dynamic state of running Chromium extensions. There is one instance | 30 // Manages dynamic state of running Chromium extensions. There is one instance |
| 31 // of this class per Profile. OTR Profiles have a separate instance that keeps | 31 // of this class per Profile. OTR Profiles have a separate instance that keeps |
| 32 // track of split-mode extensions only. | 32 // track of split-mode extensions only. |
| 33 class ExtensionProcessManager : public content::NotificationObserver { | 33 class ExtensionProcessManager : public content::NotificationObserver { |
| 34 public: | 34 public: |
| 35 static ExtensionProcessManager* Create(Profile* profile); | 35 static ExtensionProcessManager* Create(Profile* profile); |
| 36 virtual ~ExtensionProcessManager(); | 36 virtual ~ExtensionProcessManager(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // Gets the ExtensionHost for the background page for an extension, or NULL if | 68 // Gets the ExtensionHost for the background page for an extension, or NULL if |
| 69 // the extension isn't running or doesn't have a background page. | 69 // the extension isn't running or doesn't have a background page. |
| 70 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); | 70 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); |
| 71 | 71 |
| 72 // Returns the SiteInstance that the given URL belongs to. | 72 // Returns the SiteInstance that the given URL belongs to. |
| 73 // TODO(aa): This only returns correct results for extensions and packaged | 73 // TODO(aa): This only returns correct results for extensions and packaged |
| 74 // apps, not hosted apps. | 74 // apps, not hosted apps. |
| 75 virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url); | 75 virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url); |
| 76 | 76 |
| 77 // Registers a RenderViewHost as hosting a given extension. | 77 // Registers a RenderViewHost as hosting a given extension. |
| 78 void RegisterRenderViewHost(RenderViewHost* render_view_host, | 78 void RegisterRenderViewHost(content::RenderViewHost* render_view_host, |
| 79 const Extension* extension); | 79 const Extension* extension); |
| 80 | 80 |
| 81 // Unregisters a RenderViewHost as hosting any extension. | 81 // Unregisters a RenderViewHost as hosting any extension. |
| 82 void UnregisterRenderViewHost(RenderViewHost* render_view_host); | 82 void UnregisterRenderViewHost(content::RenderViewHost* render_view_host); |
| 83 | 83 |
| 84 // Returns all RenderViewHosts that are registered for the specified | 84 // Returns all RenderViewHosts that are registered for the specified |
| 85 // extension. | 85 // extension. |
| 86 std::set<RenderViewHost*> GetRenderViewHostsForExtension( | 86 std::set<content::RenderViewHost*> GetRenderViewHostsForExtension( |
| 87 const std::string& extension_id); | 87 const std::string& extension_id); |
| 88 | 88 |
| 89 // Returns true if |host| is managed by this process manager. | 89 // Returns true if |host| is managed by this process manager. |
| 90 bool HasExtensionHost(ExtensionHost* host) const; | 90 bool HasExtensionHost(ExtensionHost* host) const; |
| 91 | 91 |
| 92 // Getter and setter for the lazy background page's keepalive count. This is | 92 // Getter and setter for the lazy background page's keepalive count. This is |
| 93 // the count of how many outstanding "things" are keeping the page alive. | 93 // the count of how many outstanding "things" are keeping the page alive. |
| 94 // When this reaches 0, we will begin the process of shutting down the page. | 94 // When this reaches 0, we will begin the process of shutting down the page. |
| 95 // "Things" include pending events, resource loads, and API calls. | 95 // "Things" include pending events, resource loads, and API calls. |
| 96 int GetLazyKeepaliveCount(const Extension* extension); | 96 int GetLazyKeepaliveCount(const Extension* extension); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // The set of running viewless background extensions. | 137 // The set of running viewless background extensions. |
| 138 ExtensionHostSet background_hosts_; | 138 ExtensionHostSet background_hosts_; |
| 139 | 139 |
| 140 // A SiteInstance related to the SiteInstance for all extensions in | 140 // A SiteInstance related to the SiteInstance for all extensions in |
| 141 // this profile. We create it in such a way that a new | 141 // this profile. We create it in such a way that a new |
| 142 // browsing instance is created. This controls process grouping. | 142 // browsing instance is created. This controls process grouping. |
| 143 scoped_refptr<content::SiteInstance> site_instance_; | 143 scoped_refptr<content::SiteInstance> site_instance_; |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 // Contains all extension-related RenderViewHost instances for all extensions. | 146 // Contains all extension-related RenderViewHost instances for all extensions. |
| 147 typedef std::set<RenderViewHost*> RenderViewHostSet; | 147 typedef std::set<content::RenderViewHost*> RenderViewHostSet; |
| 148 RenderViewHostSet all_extension_views_; | 148 RenderViewHostSet all_extension_views_; |
| 149 | 149 |
| 150 // Close the given |host| iff it's a background page. | 150 // Close the given |host| iff it's a background page. |
| 151 void CloseBackgroundHost(ExtensionHost* host); | 151 void CloseBackgroundHost(ExtensionHost* host); |
| 152 | 152 |
| 153 // Excludes background page. | 153 // Excludes background page. |
| 154 bool HasVisibleViews(const std::string& extension_id); | 154 bool HasVisibleViews(const std::string& extension_id); |
| 155 | 155 |
| 156 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); | 156 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 159 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
| OLD | NEW |