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

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

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

Powered by Google App Engine
This is Rietveld 408576698