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

Side by Side Diff: extensions/browser/process_manager.h

Issue 689833005: Add a way to kill apps without killing windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win compile Created 6 years, 1 month 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
« no previous file with comments | « no previous file | extensions/browser/process_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // Gets the ExtensionHost for the background page for an extension, or NULL if 71 // Gets the ExtensionHost for the background page for an extension, or NULL if
72 // the extension isn't running or doesn't have a background page. 72 // the extension isn't running or doesn't have a background page.
73 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); 73 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id);
74 74
75 // Returns the SiteInstance that the given URL belongs to. 75 // Returns the SiteInstance that the given URL belongs to.
76 // TODO(aa): This only returns correct results for extensions and packaged 76 // TODO(aa): This only returns correct results for extensions and packaged
77 // apps, not hosted apps. 77 // apps, not hosted apps.
78 virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url); 78 virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url);
79 79
80 // If the view isn't keeping the lazy background page alive, increments the
81 // keepalive count to do so.
82 void AcquireLazyKeepaliveCountForView(
83 content::RenderViewHost* render_view_host);
84
85 // If the view is keeping the lazy background page alive, decrements the
86 // keepalive count to stop doing it.
87 void ReleaseLazyKeepaliveCountForView(
88 content::RenderViewHost* render_view_host);
89
80 // Unregisters a RenderViewHost as hosting any extension. 90 // Unregisters a RenderViewHost as hosting any extension.
81 void UnregisterRenderViewHost(content::RenderViewHost* render_view_host); 91 void UnregisterRenderViewHost(content::RenderViewHost* render_view_host);
82 92
83 // Returns all RenderViewHosts that are registered for the specified 93 // Returns all RenderViewHosts that are registered for the specified
84 // extension. 94 // extension.
85 std::set<content::RenderViewHost*> GetRenderViewHostsForExtension( 95 std::set<content::RenderViewHost*> GetRenderViewHostsForExtension(
86 const std::string& extension_id); 96 const std::string& extension_id);
87 97
88 // Returns the extension associated with the specified RenderViewHost, or 98 // Returns the extension associated with the specified RenderViewHost, or
89 // NULL. 99 // NULL.
90 const Extension* GetExtensionForRenderViewHost( 100 const Extension* GetExtensionForRenderViewHost(
91 content::RenderViewHost* render_view_host); 101 content::RenderViewHost* render_view_host);
92 102
93 // Returns true if the (lazy) background host for the given extension has 103 // Returns true if the (lazy) background host for the given extension has
94 // already been sent the unload event and is shutting down. 104 // already been sent the unload event and is shutting down.
95 bool IsBackgroundHostClosing(const std::string& extension_id); 105 bool IsBackgroundHostClosing(const std::string& extension_id);
96 106
97 // Getter and setter for the lazy background page's keepalive count. This is 107 // Getter and setter for the lazy background page's keepalive count. This is
98 // the count of how many outstanding "things" are keeping the page alive. 108 // the count of how many outstanding "things" are keeping the page alive.
99 // When this reaches 0, we will begin the process of shutting down the page. 109 // When this reaches 0, we will begin the process of shutting down the page.
100 // "Things" include pending events, resource loads, and API calls. 110 // "Things" include pending events, resource loads, and API calls.
101 int GetLazyKeepaliveCount(const Extension* extension); 111 int GetLazyKeepaliveCount(const Extension* extension);
102 void IncrementLazyKeepaliveCount(const Extension* extension); 112 void IncrementLazyKeepaliveCount(const Extension* extension);
103 void DecrementLazyKeepaliveCount(const Extension* extension); 113 void DecrementLazyKeepaliveCount(const Extension* extension);
104 114
105 void IncrementLazyKeepaliveCountForView(
106 content::RenderViewHost* render_view_host);
107
108 // Keeps a background page alive. Unlike IncrementLazyKeepaliveCount, these 115 // Keeps a background page alive. Unlike IncrementLazyKeepaliveCount, these
109 // impulses will only keep the page alive for a limited amount of time unless 116 // impulses will only keep the page alive for a limited amount of time unless
110 // called regularly. 117 // called regularly.
111 void KeepaliveImpulse(const Extension* extension); 118 void KeepaliveImpulse(const Extension* extension);
112 119
113 // Triggers a keepalive impulse for a plug-in (e.g NaCl). 120 // Triggers a keepalive impulse for a plug-in (e.g NaCl).
114 static void OnKeepaliveFromPlugin(int render_process_id, 121 static void OnKeepaliveFromPlugin(int render_process_id,
115 int render_frame_id, 122 int render_frame_id,
116 const std::string& extension_id); 123 const std::string& extension_id);
117 124
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 210
204 // Not owned. Also used by IncognitoProcessManager. 211 // Not owned. Also used by IncognitoProcessManager.
205 ExtensionRegistry* extension_registry_; 212 ExtensionRegistry* extension_registry_;
206 213
207 private: 214 private:
208 friend class ProcessManagerFactory; 215 friend class ProcessManagerFactory;
209 friend class ProcessManagerTest; 216 friend class ProcessManagerTest;
210 217
211 // Extra information we keep for each extension's background page. 218 // Extra information we keep for each extension's background page.
212 struct BackgroundPageData; 219 struct BackgroundPageData;
220 struct ExtensionRenderViewData;
213 typedef std::string ExtensionId; 221 typedef std::string ExtensionId;
214 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; 222 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap;
215 typedef std::map<content::RenderViewHost*, 223 typedef std::map<content::RenderViewHost*, ExtensionRenderViewData>
216 extensions::ViewType> ExtensionRenderViews; 224 ExtensionRenderViews;
217 225
218 // Load all background pages once the profile data is ready and the pages 226 // Load all background pages once the profile data is ready and the pages
219 // should be loaded. 227 // should be loaded.
220 void CreateStartupBackgroundHosts(); 228 void CreateStartupBackgroundHosts();
221 229
222 // Called just after |host| is created so it can be registered in our lists. 230 // Called just after |host| is created so it can be registered in our lists.
223 void OnBackgroundHostCreated(ExtensionHost* host); 231 void OnBackgroundHostCreated(ExtensionHost* host);
224 232
225 // Close the given |host| iff it's a background page. 233 // Close the given |host| iff it's a background page.
226 void CloseBackgroundHost(ExtensionHost* host); 234 void CloseBackgroundHost(ExtensionHost* host);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 297
290 // Must be last member, see doc on WeakPtrFactory. 298 // Must be last member, see doc on WeakPtrFactory.
291 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; 299 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_;
292 300
293 DISALLOW_COPY_AND_ASSIGN(ProcessManager); 301 DISALLOW_COPY_AND_ASSIGN(ProcessManager);
294 }; 302 };
295 303
296 } // namespace extensions 304 } // namespace extensions
297 305
298 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ 306 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698