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

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

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add comments Created 8 years, 5 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 18 matching lines...) Expand all
29 29
30 namespace extensions { 30 namespace extensions {
31 class Extension; 31 class Extension;
32 } 32 }
33 33
34 // Manages dynamic state of running Chromium extensions. There is one instance 34 // Manages dynamic state of running Chromium extensions. There is one instance
35 // of this class per Profile. OTR Profiles have a separate instance that keeps 35 // of this class per Profile. OTR Profiles have a separate instance that keeps
36 // track of split-mode extensions only. 36 // track of split-mode extensions only.
37 class ExtensionProcessManager : public content::NotificationObserver { 37 class ExtensionProcessManager : public content::NotificationObserver {
38 public: 38 public:
39 enum ShouldCancelSuspend {
40 CANCEL_SUSPEND,
41 DONT_CANCEL_SUSPEND
42 };
43 typedef std::set<ExtensionHost*> ExtensionHostSet; 39 typedef std::set<ExtensionHost*> ExtensionHostSet;
44 typedef ExtensionHostSet::const_iterator const_iterator; 40 typedef ExtensionHostSet::const_iterator const_iterator;
45 41
46 static ExtensionProcessManager* Create(Profile* profile); 42 static ExtensionProcessManager* Create(Profile* profile);
47 virtual ~ExtensionProcessManager(); 43 virtual ~ExtensionProcessManager();
48 44
49 const ExtensionHostSet& background_hosts() const { 45 const ExtensionHostSet& background_hosts() const {
50 return background_hosts_; 46 return background_hosts_;
51 } 47 }
52 48
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 content::RenderViewHost* render_view_host); 106 content::RenderViewHost* render_view_host);
111 107
112 // Returns true if the (lazy) background host for the given extension has 108 // Returns true if the (lazy) background host for the given extension has
113 // already been sent the unload event and is shutting down. 109 // already been sent the unload event and is shutting down.
114 bool IsBackgroundHostClosing(const std::string& extension_id); 110 bool IsBackgroundHostClosing(const std::string& extension_id);
115 111
116 // Getter and setter for the lazy background page's keepalive count. This is 112 // Getter and setter for the lazy background page's keepalive count. This is
117 // the count of how many outstanding "things" are keeping the page alive. 113 // the count of how many outstanding "things" are keeping the page alive.
118 // When this reaches 0, we will begin the process of shutting down the page. 114 // When this reaches 0, we will begin the process of shutting down the page.
119 // "Things" include pending events, resource loads, and API calls. 115 // "Things" include pending events, resource loads, and API calls.
120 // The |cancel_suspend| option defaults to false and indicates whether
121 // incrementing the keepalive count should prevent it from being suspended.
122 int GetLazyKeepaliveCount(const extensions::Extension* extension); 116 int GetLazyKeepaliveCount(const extensions::Extension* extension);
123 int IncrementLazyKeepaliveCount(const extensions::Extension* extension, 117 int IncrementLazyKeepaliveCount(const extensions::Extension* extension);
124 ShouldCancelSuspend should_cancel_suspend);
125 int DecrementLazyKeepaliveCount(const extensions::Extension* extension); 118 int DecrementLazyKeepaliveCount(const extensions::Extension* extension);
126 119
127 void IncrementLazyKeepaliveCountForView( 120 void IncrementLazyKeepaliveCountForView(
128 content::RenderViewHost* render_view_host); 121 content::RenderViewHost* render_view_host);
129 122
130 // Handles a response to the ShouldUnload message, used for lazy background 123 // Handles a response to the ShouldUnload message, used for lazy background
131 // pages. 124 // pages.
132 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id); 125 void OnShouldUnloadAck(const std::string& extension_id, int sequence_id);
133 126
134 // Same as above, for the Unload message. 127 // Same as above, for the Unload message.
135 void OnUnloadAck(const std::string& extension_id); 128 void OnUnloadAck(const std::string& extension_id);
136 129
137 // Tracks network requests for a given RenderViewHost, used to know 130 // Tracks network requests for a given RenderViewHost, used to know
138 // when network activity is idle for lazy background pages. 131 // when network activity is idle for lazy background pages.
139 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host); 132 void OnNetworkRequestStarted(content::RenderViewHost* render_view_host);
140 void OnNetworkRequestDone(content::RenderViewHost* render_view_host); 133 void OnNetworkRequestDone(content::RenderViewHost* render_view_host);
141 134
135 // Prevents |extension|'s background page from being closed and sends the
136 // onSuspendCanceled() event to it.
137 void CancelSuspend(const extensions::Extension* extension);
138
142 protected: 139 protected:
143 explicit ExtensionProcessManager(Profile* profile); 140 explicit ExtensionProcessManager(Profile* profile);
144 141
145 // Called just after |host| is created so it can be registered in our lists. 142 // Called just after |host| is created so it can be registered in our lists.
146 void OnExtensionHostCreated(ExtensionHost* host, bool is_background); 143 void OnExtensionHostCreated(ExtensionHost* host, bool is_background);
147 144
148 // Called on browser shutdown to close our extension hosts. 145 // Called on browser shutdown to close our extension hosts.
149 void CloseBackgroundHosts(); 146 void CloseBackgroundHosts();
150 147
151 // content::NotificationObserver: 148 // content::NotificationObserver:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // The time to delay between sending a ShouldUnload message and 209 // The time to delay between sending a ShouldUnload message and
213 // sending a Unload message; read from command-line switch. 210 // sending a Unload message; read from command-line switch.
214 base::TimeDelta event_page_unloading_time_; 211 base::TimeDelta event_page_unloading_time_;
215 212
216 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; 213 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_;
217 214
218 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); 215 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
219 }; 216 };
220 217
221 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 218 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698