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

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

Issue 2762513002: Remove keep-alive impulse IPCs from NaCl modules. (Closed)
Patch Set: Created 3 years, 9 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
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 // Getter and setter for the lazy background page's keepalive count. This is 116 // 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. 117 // 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. 118 // When this reaches 0, we will begin the process of shutting down the page.
119 // "Things" include pending events, resource loads, and API calls. 119 // "Things" include pending events, resource loads, and API calls.
120 // Returns -1 if |extension| does not have a lazy background page. 120 // Returns -1 if |extension| does not have a lazy background page.
121 int GetLazyKeepaliveCount(const Extension* extension); 121 int GetLazyKeepaliveCount(const Extension* extension);
122 void IncrementLazyKeepaliveCount(const Extension* extension); 122 void IncrementLazyKeepaliveCount(const Extension* extension);
123 void DecrementLazyKeepaliveCount(const Extension* extension); 123 void DecrementLazyKeepaliveCount(const Extension* extension);
124 124
125 // Keeps a background page alive. Unlike IncrementLazyKeepaliveCount, these
126 // impulses will only keep the page alive for a limited amount of time unless
127 // called regularly.
128 void KeepaliveImpulse(const Extension* extension);
129
130 // Triggers a keepalive impulse for a plugin (e.g NaCl).
131 static void OnKeepaliveFromPlugin(int render_process_id,
132 int render_frame_id,
133 const std::string& extension_id);
134
135 // Handles a response to the ShouldSuspend message, used for lazy background 125 // Handles a response to the ShouldSuspend message, used for lazy background
136 // pages. 126 // pages.
137 void OnShouldSuspendAck(const std::string& extension_id, 127 void OnShouldSuspendAck(const std::string& extension_id,
138 uint64_t sequence_id); 128 uint64_t sequence_id);
139 129
140 // Same as above, for the Suspend message. 130 // Same as above, for the Suspend message.
141 void OnSuspendAck(const std::string& extension_id); 131 void OnSuspendAck(const std::string& extension_id);
142 132
143 // Tracks network requests for a given RenderFrameHost, used to know 133 // Tracks network requests for a given RenderFrameHost, used to know
144 // when network activity is idle for lazy background pages. 134 // when network activity is idle for lazy background pages.
145 void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host, 135 void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host,
146 uint64_t request_id); 136 uint64_t request_id);
147 void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host, 137 void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host,
148 uint64_t request_id); 138 uint64_t request_id);
149 139
150 // Prevents |extension|'s background page from being closed and sends the 140 // Prevents |extension|'s background page from being closed and sends the
151 // onSuspendCanceled() event to it. 141 // onSuspendCanceled() event to it.
152 void CancelSuspend(const Extension* extension); 142 void CancelSuspend(const Extension* extension);
153 143
154 // Called on shutdown to close our extension hosts. 144 // Called on shutdown to close our extension hosts.
155 void CloseBackgroundHosts(); 145 void CloseBackgroundHosts();
156 146
157 // Sets callbacks for testing keepalive impulse behavior.
158 using ImpulseCallbackForTesting =
159 base::Callback<void(const std::string& extension_id)>;
160 void SetKeepaliveImpulseCallbackForTesting(
161 const ImpulseCallbackForTesting& callback);
162 void SetKeepaliveImpulseDecrementCallbackForTesting(
163 const ImpulseCallbackForTesting& callback);
164
165 // EventPageTracker implementation. 147 // EventPageTracker implementation.
166 bool IsEventPageSuspended(const std::string& extension_id) override; 148 bool IsEventPageSuspended(const std::string& extension_id) override;
167 bool WakeEventPage(const std::string& extension_id, 149 bool WakeEventPage(const std::string& extension_id,
168 const base::Callback<void(bool)>& callback) override; 150 const base::Callback<void(bool)>& callback) override;
169 151
170 // Sets the time in milliseconds that an extension event page can 152 // Sets the time in milliseconds that an extension event page can
171 // be idle before it is shut down; must be > 0. 153 // be idle before it is shut down; must be > 0.
172 static void SetEventPageIdleTimeForTesting(unsigned idle_time_msec); 154 static void SetEventPageIdleTimeForTesting(unsigned idle_time_msec);
173 155
174 // Sets the time in milliseconds that an extension event page has 156 // Sets the time in milliseconds that an extension event page has
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 234
253 // If the frame is keeping the lazy background page alive, decrements the 235 // If the frame is keeping the lazy background page alive, decrements the
254 // keepalive count to stop doing it. 236 // keepalive count to stop doing it.
255 void ReleaseLazyKeepaliveCountForFrame( 237 void ReleaseLazyKeepaliveCountForFrame(
256 content::RenderFrameHost* render_frame_host); 238 content::RenderFrameHost* render_frame_host);
257 239
258 // Internal implementation of DecrementLazyKeepaliveCount with an 240 // Internal implementation of DecrementLazyKeepaliveCount with an
259 // |extension_id| known to have a lazy background page. 241 // |extension_id| known to have a lazy background page.
260 void DecrementLazyKeepaliveCount(const std::string& extension_id); 242 void DecrementLazyKeepaliveCount(const std::string& extension_id);
261 243
262 // Checks if keepalive impulses have occured, and adjusts keep alive count.
263 void OnKeepaliveImpulseCheck();
264
265 // These are called when the extension transitions between idle and active. 244 // These are called when the extension transitions between idle and active.
266 // They control the process of closing the background page when idle. 245 // They control the process of closing the background page when idle.
267 void OnLazyBackgroundPageIdle(const std::string& extension_id, 246 void OnLazyBackgroundPageIdle(const std::string& extension_id,
268 uint64_t sequence_id); 247 uint64_t sequence_id);
269 void OnLazyBackgroundPageActive(const std::string& extension_id); 248 void OnLazyBackgroundPageActive(const std::string& extension_id);
270 void CloseLazyBackgroundPageNow(const std::string& extension_id, 249 void CloseLazyBackgroundPageNow(const std::string& extension_id,
271 uint64_t sequence_id); 250 uint64_t sequence_id);
272 251
273 const Extension* GetExtensionForAgentHost( 252 const Extension* GetExtensionForAgentHost(
274 content::DevToolsAgentHost* agent_host); 253 content::DevToolsAgentHost* agent_host);
(...skipping 27 matching lines...) Expand all
302 // Contains all active extension-related RenderFrameHost instances for all 281 // Contains all active extension-related RenderFrameHost instances for all
303 // extensions. We also keep a cache of the host's view type, because that 282 // extensions. We also keep a cache of the host's view type, because that
304 // information is not accessible at registration/deregistration time. 283 // information is not accessible at registration/deregistration time.
305 ExtensionRenderFrames all_extension_frames_; 284 ExtensionRenderFrames all_extension_frames_;
306 285
307 BackgroundPageDataMap background_page_data_; 286 BackgroundPageDataMap background_page_data_;
308 287
309 // True if we have created the startup set of background hosts. 288 // True if we have created the startup set of background hosts.
310 bool startup_background_hosts_created_; 289 bool startup_background_hosts_created_;
311 290
312 ImpulseCallbackForTesting keepalive_impulse_callback_for_testing_;
313 ImpulseCallbackForTesting keepalive_impulse_decrement_callback_for_testing_;
314
315 base::ObserverList<ProcessManagerObserver> observer_list_; 291 base::ObserverList<ProcessManagerObserver> observer_list_;
316 292
317 // ID Counter used to set ProcessManager::BackgroundPageData close_sequence_id 293 // ID Counter used to set ProcessManager::BackgroundPageData close_sequence_id
318 // members. These IDs are tracked per extension in background_page_data_ and 294 // members. These IDs are tracked per extension in background_page_data_ and
319 // are used to verify that nothing has interrupted the process of closing a 295 // are used to verify that nothing has interrupted the process of closing a
320 // lazy background process. 296 // lazy background process.
321 // 297 //
322 // Any interruption obtains a new ID by incrementing 298 // Any interruption obtains a new ID by incrementing
323 // last_background_close_sequence_id_ and storing it in background_page_data_ 299 // last_background_close_sequence_id_ and storing it in background_page_data_
324 // for a particular extension. Callbacks and round-trip IPC messages store the 300 // for a particular extension. Callbacks and round-trip IPC messages store the
(...skipping 13 matching lines...) Expand all
338 314
339 // Must be last member, see doc on WeakPtrFactory. 315 // Must be last member, see doc on WeakPtrFactory.
340 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; 316 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_;
341 317
342 DISALLOW_COPY_AND_ASSIGN(ProcessManager); 318 DISALLOW_COPY_AND_ASSIGN(ProcessManager);
343 }; 319 };
344 320
345 } // namespace extensions 321 } // namespace extensions
346 322
347 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ 323 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698