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

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

Issue 23618014: This defers starting background extension page RenderViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added ENABLE_EXTENSIONS ifdef Created 7 years, 3 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 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 // Tracks network requests for a given RenderViewHost, used to know 128 // Tracks network requests for a given RenderViewHost, used to know
129 // when network activity is idle for lazy background pages. 129 // when network activity is idle for lazy background pages.
130 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); 130 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host);
131 void OnNetworkRequestDone(content::RenderViewHost* render_view_host); 131 void OnNetworkRequestDone(content::RenderViewHost* render_view_host);
132 132
133 // Prevents |extension|'s background page from being closed and sends the 133 // Prevents |extension|'s background page from being closed and sends the
134 // onSuspendCanceled() event to it. 134 // onSuspendCanceled() event to it.
135 void CancelSuspend(const extensions::Extension* extension); 135 void CancelSuspend(const extensions::Extension* extension);
136 136
137 // If |defer| is true background host creation is to be deferred until this is
138 // called again with |defer| set to false, at which point all deferred
139 // background hosts will be created. Defaults to false.
140 void DeferBackgroundHostCreation(bool defer);
141
137 protected: 142 protected:
138 explicit ExtensionProcessManager(Profile* profile); 143 explicit ExtensionProcessManager(Profile* profile);
139 144
140 // Called just after |host| is created so it can be registered in our lists. 145 // Called just after |host| is created so it can be registered in our lists.
141 void OnExtensionHostCreated(extensions::ExtensionHost* host, 146 void OnExtensionHostCreated(extensions::ExtensionHost* host,
142 bool is_background); 147 bool is_background);
143 148
144 // Called on browser shutdown to close our extension hosts. 149 // Called on browser shutdown to close our extension hosts.
145 void CloseBackgroundHosts(); 150 void CloseBackgroundHosts();
146 151
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 197
193 // Potentially registers a RenderViewHost, if it is associated with an 198 // Potentially registers a RenderViewHost, if it is associated with an
194 // extension. Does nothing if this is not an extension renderer. 199 // extension. Does nothing if this is not an extension renderer.
195 void RegisterRenderViewHost(content::RenderViewHost* render_view_host); 200 void RegisterRenderViewHost(content::RenderViewHost* render_view_host);
196 201
197 // Clears background page data for this extension. 202 // Clears background page data for this extension.
198 void ClearBackgroundPageData(const std::string& extension_id); 203 void ClearBackgroundPageData(const std::string& extension_id);
199 204
200 // Returns true if loading background pages should be deferred. This is 205 // Returns true if loading background pages should be deferred. This is
201 // true if there are no browser windows open and the browser process was 206 // true if there are no browser windows open and the browser process was
202 // started to show the app launcher. 207 // started to show the app launcher, or if DeferBackgroundHostCreation was
208 // called with true, or if the profile is not yet valid.
203 bool DeferLoadingBackgroundHosts() const; 209 bool DeferLoadingBackgroundHosts() const;
204 210
205 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); 211 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached);
206 212
207 // Contains all active extension-related RenderViewHost instances for all 213 // Contains all active extension-related RenderViewHost instances for all
208 // extensions. We also keep a cache of the host's view type, because that 214 // extensions. We also keep a cache of the host's view type, because that
209 // information is not accessible at registration/deregistration time. 215 // information is not accessible at registration/deregistration time.
210 ExtensionRenderViews all_extension_views_; 216 ExtensionRenderViews all_extension_views_;
211 217
212 BackgroundPageDataMap background_page_data_; 218 BackgroundPageDataMap background_page_data_;
213 219
214 // The time to delay between an extension becoming idle and 220 // The time to delay between an extension becoming idle and
215 // sending a ShouldSuspend message; read from command-line switch. 221 // sending a ShouldSuspend message; read from command-line switch.
216 base::TimeDelta event_page_idle_time_; 222 base::TimeDelta event_page_idle_time_;
217 223
218 // The time to delay between sending a ShouldSuspend message and 224 // The time to delay between sending a ShouldSuspend message and
219 // sending a Suspend message; read from command-line switch. 225 // sending a Suspend message; read from command-line switch.
220 base::TimeDelta event_page_suspending_time_; 226 base::TimeDelta event_page_suspending_time_;
221 227
228 // If true, then creation of background hosts is suspended.
229 bool defer_background_host_creation_;
230
222 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; 231 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_;
223 232
224 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; 233 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
225 234
226 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); 235 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
227 }; 236 };
228 237
229 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 238 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_process_manager.cc » ('j') | chrome/browser/profiles/profile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698