Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: chrome/browser/extensions/extension_process_manager.h

Issue 10116017: Remove EPM::all_hosts_ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
(...skipping 14 matching lines...) Expand all
25 namespace content { 25 namespace content {
26 class RenderViewHost; 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 typedef std::set<ExtensionHost*> ExtensionHostSet;
36 typedef ExtensionHostSet::const_iterator const_iterator;
37
35 static ExtensionProcessManager* Create(Profile* profile); 38 static ExtensionProcessManager* Create(Profile* profile);
36 virtual ~ExtensionProcessManager(); 39 virtual ~ExtensionProcessManager();
37 40
41 const ExtensionHostSet& background_hosts() const {
42 return background_hosts_;
43 }
44
45 typedef std::set<content::RenderViewHost*> ViewSet;
46 const ViewSet GetAllViews() const;
47
38 // Creates a new ExtensionHost with its associated view, grouping it in the 48 // Creates a new ExtensionHost with its associated view, grouping it in the
39 // appropriate SiteInstance (and therefore process) based on the URL and 49 // appropriate SiteInstance (and therefore process) based on the URL and
40 // profile. 50 // profile.
41 virtual ExtensionHost* CreateViewHost(const Extension* extension, 51 virtual ExtensionHost* CreateViewHost(const Extension* extension,
42 const GURL& url, 52 const GURL& url,
43 Browser* browser, 53 Browser* browser,
44 content::ViewType view_type); 54 content::ViewType view_type);
45 ExtensionHost* CreateViewHost(const GURL& url, 55 ExtensionHost* CreateViewHost(const GURL& url,
46 Browser* browser, 56 Browser* browser,
47 content::ViewType view_type); 57 content::ViewType view_type);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const Extension* extension); 89 const Extension* extension);
80 90
81 // Unregisters a RenderViewHost as hosting any extension. 91 // Unregisters a RenderViewHost as hosting any extension.
82 void UnregisterRenderViewHost(content::RenderViewHost* render_view_host); 92 void UnregisterRenderViewHost(content::RenderViewHost* render_view_host);
83 93
84 // Returns all RenderViewHosts that are registered for the specified 94 // Returns all RenderViewHosts that are registered for the specified
85 // extension. 95 // extension.
86 std::set<content::RenderViewHost*> GetRenderViewHostsForExtension( 96 std::set<content::RenderViewHost*> GetRenderViewHostsForExtension(
87 const std::string& extension_id); 97 const std::string& extension_id);
88 98
89 // Returns true if |host| is managed by this process manager. 99 // Returns the extension associated with the specified RenderViewHost, or
90 bool HasExtensionHost(ExtensionHost* host) const; 100 // NULL.
101 const Extension* GetExtensionForRenderViewHost(
102 content::RenderViewHost* render_view_host);
91 103
92 // Getter and setter for the lazy background page's keepalive count. This is 104 // 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. 105 // 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. 106 // When this reaches 0, we will begin the process of shutting down the page.
95 // "Things" include pending events, resource loads, and API calls. 107 // "Things" include pending events, resource loads, and API calls.
96 int GetLazyKeepaliveCount(const Extension* extension); 108 int GetLazyKeepaliveCount(const Extension* extension);
97 int IncrementLazyKeepaliveCount(const Extension* extension); 109 int IncrementLazyKeepaliveCount(const Extension* extension);
98 int DecrementLazyKeepaliveCount(const Extension* extension); 110 int DecrementLazyKeepaliveCount(const Extension* extension);
99 111
100 // Handles a response to the ShouldUnload message, used for lazy background 112 // Handles a response to the ShouldUnload message, used for lazy background
101 // pages. 113 // pages.
102 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id); 114 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id);
103 115
104 // Same as above, for the Unload message. 116 // Same as above, for the Unload message.
105 void OnUnloadAck(const std::string& extension_id); 117 void OnUnloadAck(const std::string& extension_id);
106 118
107 // Tracks network requests for a given RenderViewHost, used to know 119 // Tracks network requests for a given RenderViewHost, used to know
108 // when network activity is idle for lazy background pages. 120 // when network activity is idle for lazy background pages.
109 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); 121 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host);
110 void OnNetworkRequestDone(content::RenderViewHost* render_view_host); 122 void OnNetworkRequestDone(content::RenderViewHost* render_view_host);
111 123
112 typedef std::set<ExtensionHost*> ExtensionHostSet;
113 typedef ExtensionHostSet::const_iterator const_iterator;
114 const_iterator begin() const { return all_hosts_.begin(); }
115 const_iterator end() const { return all_hosts_.end(); }
116
117 protected: 124 protected:
118 explicit ExtensionProcessManager(Profile* profile); 125 explicit ExtensionProcessManager(Profile* profile);
119 126
120 // Called just after |host| is created so it can be registered in our lists. 127 // Called just after |host| is created so it can be registered in our lists.
121 void OnExtensionHostCreated(ExtensionHost* host, bool is_background); 128 void OnExtensionHostCreated(ExtensionHost* host, bool is_background);
122 129
123 // Called on browser shutdown to close our extension hosts. 130 // Called on browser shutdown to close our extension hosts.
124 void CloseBackgroundHosts(); 131 void CloseBackgroundHosts();
125 132
126 // content::NotificationObserver: 133 // content::NotificationObserver:
127 virtual void Observe(int type, 134 virtual void Observe(int type,
128 const content::NotificationSource& source, 135 const content::NotificationSource& source,
129 const content::NotificationDetails& details) OVERRIDE; 136 const content::NotificationDetails& details) OVERRIDE;
130 137
131 // Gets the profile associated with site_instance_ and all other 138 // Gets the profile associated with site_instance_ and all other
132 // related SiteInstances. 139 // related SiteInstances.
133 Profile* GetProfile() const; 140 Profile* GetProfile() const;
134 141
135 content::NotificationRegistrar registrar_; 142 content::NotificationRegistrar registrar_;
136 143
137 // The set of all ExtensionHosts managed by this process manager.
138 ExtensionHostSet all_hosts_;
139
140 // The set of running viewless background extensions. 144 // The set of running viewless background extensions.
141 ExtensionHostSet background_hosts_; 145 ExtensionHostSet background_hosts_;
142 146
143 // A SiteInstance related to the SiteInstance for all extensions in 147 // A SiteInstance related to the SiteInstance for all extensions in
144 // this profile. We create it in such a way that a new 148 // this profile. We create it in such a way that a new
145 // browsing instance is created. This controls process grouping. 149 // browsing instance is created. This controls process grouping.
146 scoped_refptr<content::SiteInstance> site_instance_; 150 scoped_refptr<content::SiteInstance> site_instance_;
147 151
148 private: 152 private:
149 // Extra information we keep for each extension's background page. 153 // Extra information we keep for each extension's background page.
(...skipping 24 matching lines...) Expand all
174 // associated with a WebContents. This allows us to gather information that 178 // associated with a WebContents. This allows us to gather information that
175 // was not available when the host was first registered. 179 // was not available when the host was first registered.
176 void UpdateRegisteredRenderView(content::RenderViewHost* render_view_host); 180 void UpdateRegisteredRenderView(content::RenderViewHost* render_view_host);
177 181
178 BackgroundPageDataMap background_page_data_; 182 BackgroundPageDataMap background_page_data_;
179 183
180 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); 184 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
181 }; 185 };
182 186
183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 187 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698