OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 virtual void CreateBackgroundHost(const Extension* extension, | 61 virtual void CreateBackgroundHost(const Extension* extension, |
62 const GURL& url); | 62 const GURL& url); |
63 | 63 |
64 // Gets the ExtensionHost for the background page for an extension, or NULL if | 64 // Gets the ExtensionHost for the background page for an extension, or NULL if |
65 // the extension isn't running or doesn't have a background page. | 65 // the extension isn't running or doesn't have a background page. |
66 ExtensionHost* GetBackgroundHostForExtension(const Extension* extension); | 66 ExtensionHost* GetBackgroundHostForExtension(const Extension* extension); |
67 | 67 |
68 // Returns the SiteInstance that the given URL belongs to. | 68 // Returns the SiteInstance that the given URL belongs to. |
69 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); | 69 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); |
70 | 70 |
71 // Registers an extension process by |extension_id| and specifying which | 71 // Registers a SiteInstance with |site_instance_id| as hosting the extension |
72 // |process_id| it belongs to. | 72 // with |extension_id|. |
73 void RegisterExtensionProcess(const std::string& extension_id, | 73 void RegisterExtensionSiteInstance(int site_instance_id, |
74 int process_id); | 74 const std::string& extension_id); |
75 | 75 |
76 // Unregisters an extension process with specified |process_id|. | 76 // Unregisters the extension associated with |site_instance_id|. |
77 void UnregisterExtensionProcess(int process_id); | 77 void UnregisterExtensionSiteInstance(int site_instance_id); |
78 | 78 |
79 // Returns the extension process that |url| is associated with if it exists. | 79 // Returns the extension process that |url| is associated with if it exists. |
| 80 // This is not valid for hosted apps without the background permission, since |
| 81 // such apps may have multiple processes. |
80 virtual RenderProcessHost* GetExtensionProcess(const GURL& url); | 82 virtual RenderProcessHost* GetExtensionProcess(const GURL& url); |
81 | 83 |
82 // Returns the process that the extension with the given ID is running in. | 84 // Returns the process that the extension with the given ID is running in. |
83 RenderProcessHost* GetExtensionProcess(const std::string& extension_id); | 85 RenderProcessHost* GetExtensionProcess(const std::string& extension_id); |
84 | 86 |
| 87 // Returns the Extension associated with the given SiteInstance id, if any. |
| 88 virtual const Extension* GetExtensionForSiteInstance(int site_instance_id); |
| 89 |
85 // Returns true if |host| is managed by this process manager. | 90 // Returns true if |host| is managed by this process manager. |
86 bool HasExtensionHost(ExtensionHost* host) const; | 91 bool HasExtensionHost(ExtensionHost* host) const; |
87 | 92 |
88 typedef std::set<ExtensionHost*> ExtensionHostSet; | 93 typedef std::set<ExtensionHost*> ExtensionHostSet; |
89 typedef ExtensionHostSet::const_iterator const_iterator; | 94 typedef ExtensionHostSet::const_iterator const_iterator; |
90 const_iterator begin() const { return all_hosts_.begin(); } | 95 const_iterator begin() const { return all_hosts_.begin(); } |
91 const_iterator end() const { return all_hosts_.end(); } | 96 const_iterator end() const { return all_hosts_.end(); } |
92 | 97 |
93 protected: | 98 protected: |
94 explicit ExtensionProcessManager(Profile* profile); | 99 explicit ExtensionProcessManager(Profile* profile); |
(...skipping 14 matching lines...) Expand all Loading... |
109 // The set of all ExtensionHosts managed by this process manager. | 114 // The set of all ExtensionHosts managed by this process manager. |
110 ExtensionHostSet all_hosts_; | 115 ExtensionHostSet all_hosts_; |
111 | 116 |
112 // The set of running viewless background extensions. | 117 // The set of running viewless background extensions. |
113 ExtensionHostSet background_hosts_; | 118 ExtensionHostSet background_hosts_; |
114 | 119 |
115 // The BrowsingInstance shared by all extensions in this profile. This | 120 // The BrowsingInstance shared by all extensions in this profile. This |
116 // controls process grouping. | 121 // controls process grouping. |
117 scoped_refptr<BrowsingInstance> browsing_instance_; | 122 scoped_refptr<BrowsingInstance> browsing_instance_; |
118 | 123 |
119 // A map of extension ID to the render_process_id that the extension lives in. | 124 // A map of site instance ID to the ID of the extension it hosts. |
120 typedef std::map<std::string, int> ProcessIDMap; | 125 typedef std::map<int, std::string> SiteInstanceIDMap; |
121 ProcessIDMap process_ids_; | 126 SiteInstanceIDMap extension_ids_; |
122 | 127 |
123 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); | 128 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); |
124 }; | 129 }; |
125 | 130 |
126 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 131 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
OLD | NEW |